RE: PCMCIA for 2.1.x, x>=8

Al Longyear (longyear@sii.com)
Wed, 13 Nov 1996 16:03:19 -0800


I did some patches for my system. I sent them to David, but it seems
like everthing else that I send to him, ends up in a black hole. I get
no response; not even "no I don't like them." He must be taking lessons
from some of the FSF people.

So, anyway, here are the changes to permit the code to work with the 2.1
series kernels -- or any of the 2.x for that matter since they detect
the kernel version and make the appropriate changes:

The changes to ds.c are merly cosmetic. The parameters changed in the
2.1 series
kernel from 'int' to 'unsigned long'. For the iNTEL (and Motorolla 68K)
platforms, they are the same size.

The 'real' changes are in the k_compat.h header file. These changes are
perhaps not the best in the world. What I strove to achive was
compatibility with the existing code and to make as few changes as
possible. This means that the functions favor the older style of memory
management rather than the newer one.

diff --unified=5 --recursive pcmcia-cs-2.8.23.orig/modules/ds.c
pcmcia-cs-2.8.23/modules/ds.c
--- pcmcia-cs-2.8.23.orig/modules/ds.c Wed Nov 13 15:50:03 1996
+++ pcmcia-cs-2.8.23/modules/ds.c Fri Oct 18 06:45:13 1996
@@ -39,18 +39,34 @@
"ds.c 1.57 1996/09/08 22:07:27 (David Hinds)";
#endif

/*====================================================================*
/

+#if LINUX_VERSION_CODE >= VERSION(2,1,4)
+#define FS_WRITE(name,inodep,filep,buf,count) \
+ static long name (struct inode *inodep, struct file *filep, \
+ CONST char *buf, unsigned long count)
+#define FS_READ(name,inodep,filep,buf,count) \
+ static long name (struct inode *inodep, struct file *filep, \
+ char *buf, unsigned long count)
+#else
+#define FS_WRITE(name,inodep,filep,buf,count) \
+ static int name (struct inode *inodep, struct file *filep, \
+ CONST char *buf, int count)
+#define FS_READ(name,inodep,filep,buf,count) \
+ static int name (struct inode *inodep, struct file *filep, \
+ char *buf, int count)
+#endif
+
+/*====================================================================*
/
+
static void handle_removal(u_long i);

static int ds_event(event_t event, int priority,
event_callback_args_t *args);
-static int ds_read(struct inode *inode, struct file *file,
- char *buf, int count);
-static int ds_write(struct inode *inode, struct file *file,
- CONST char *buf, int count);
+FS_READ(ds_read, inode, file, buf, count);
+FS_WRITE(ds_write, inode, file, buf, count);
static int ds_select(struct inode *inode, struct file *file,
int sel_type, select_table *wait);
static int ds_ioctl(struct inode * inode, struct file * file,
u_int cmd, u_long arg);
static int ds_open(struct inode * inode, struct file * file);
@@ -552,12 +568,11 @@
MOD_DEC_USE_COUNT;
} /* ds_release */

/*====================================================================*
/

-static int ds_read(struct inode *inode, struct file *file,
- char *buf, int count)
+FS_READ (ds_read, inode, file, buf, count)
{
socket_t i = MINOR(inode->i_rdev);
socket_info_t *s;
user_info_t *user;
int val;
@@ -586,12 +601,11 @@
return 4;
} /* ds_read */

/*====================================================================*
/

-static int ds_write(struct inode *inode, struct file *file,
- CONST char *buf, int count)
+FS_WRITE (ds_write, inode, file, buf, count)
{
socket_t i = MINOR(inode->i_rdev);
socket_info_t *s;
user_info_t *user;

diff --unified=5 --recursive pcmcia-cs-2.8.23.orig/modules/k_compat.h
pcmcia-cs-2.8.23/modules/k_compat.h
--- pcmcia-cs-2.8.23.orig/modules/k_compat.h Wed Nov 13 15:51:03 1996
+++ pcmcia-cs-2.8.23/modules/k_compat.h Sat Nov 2 12:52:19 1996
@@ -85,6 +85,40 @@
#define FREE_IRQ(i) free_irq(i)
#define REQUEST_IRQ(i,h,f,n) request_irq(i,h,f,n)
#define IRQ(a,b,c) (a,c)
#endif

+#if (LINUX_VERSION_CODE >= VERSION(2,1,4))
+#include <linux/mm.h>
+#include <asm/segment.h>
+#if (LINUX_VERSION_CODE >= VERSION(2,1,7))
+#include <asm/uaccess.h>
+#endif
+#define put_fs_long(val, buf) (void) put_user (val, (int *) buf)
+#define put_fs_word(val, buf) (void) put_user (val, (short *) buf)
+#define put_fs_byte(val, buf) (void) put_user (val, (char *) buf)
+#define memcpy_tofs(dest,src,size) copy_to_user(dest,src,size)
+#define memcpy_fromfs(dest,src,size) copy_from_user(dest,src,size)
+
+extern inline int get_fs_long (const int *buf)
+{
+ int value;
+ (void) get_user(value, buf);
+ return value;
+}
+
+extern inline short get_fs_word (const short *buf)
+{
+ short int value;
+ (void) get_user(value, buf);
+ return value;
+}
+
+extern inline char get_fs_byte (const char *buf)
+{
+ char value;
+ (void) get_user(value, buf);
+ return value;
+}
+#endif
+
#endif /* _LINUX_K_COMPAT_H */

From: Klaus Lichtenwalder <klaus@gaston.m.isar.de>
Date: Wed, 13 Nov 1996 14:31:06 +0000 (WET)
Subject: PCMCIA for 2.1.x, x>=8

>Did anyone already patch the pcmcia modules for the new kernel
>functions, e.g., the verify_area thingies?

--
Al Longyear                     longyear@sii.com