--- joystick.c~	Thu Apr  4 04:54:57 1996
+++ joystick.c	Tue Jan  7 02:02:23 1997
@@ -40,12 +40,26 @@
 				to compile correctly under 1.3 in kernel or as module
 */
 
+/* check for 2.1.x */
+#include <linux/version.h>
+#if LINUX_VERSION_CODE >= (2*65536 + 1*256)
+#define NEW_LINUX
+#endif
+
+#ifdef NEW_LINUX         /* needed for 2.1.x */
+#include <linux/config.h>
+#endif
+
 #include <linux/module.h>
 #include <linux/joystick.h>
 #include <linux/mm.h>
 #include <linux/ioport.h>
 #include <asm/io.h>
 
+#ifdef NEW_LINUX         /* needed for 2.1.x */
+#include <asm/uaccess.h>
+#endif
+
 static struct JS_DATA_SAVE_TYPE JS_DATA[JS_MAX];	/* misc data */
 static int JS_EXIST;			/* which joysticks' axis exist? */
 static int JS_READ_SEMAPHORE;	/* to prevent two processes from trying
@@ -110,49 +124,77 @@
 			     sizeof (struct JS_DATA_TYPE));
 		c = (char *) &JS_DATA[minor].JS_CORR;
 		for (i = 0; i < sizeof (struct JS_DATA_TYPE); i++)
-			*c++ = get_fs_byte ((char *) arg++);
+#ifndef NEW_LINUX
+                        *c++ = get_fs_byte ((char *) arg++);
+#else
+                        get_user(*c++,(char *) arg++);
+#endif
 		break;
 	case JS_GET_CAL:	/*to struct *arg from JS_DATA[minor]*/
 		verify_area (VERIFY_WRITE, (void *) arg,
 			     sizeof (struct JS_DATA_TYPE));
 		c = (char *) &JS_DATA[minor].JS_CORR;
 		for (i = 0; i < sizeof (struct JS_DATA_TYPE); i++)
-			put_fs_byte (*c++, (char *) arg++);
+#ifndef NEW_LINUX
+                        put_fs_byte (*c++, (char *) arg++);
+#else
+                        put_user(*c++, (char *) arg++);
+#endif
 		break;
 	case JS_SET_TIMEOUT:
 		verify_area (VERIFY_READ, (void *) arg,
 			     sizeof (JS_DATA[0].JS_TIMEOUT));
 		c = (char *) &JS_DATA[minor].JS_TIMEOUT;
 		for (i = 0; i < sizeof (JS_DATA[0].JS_TIMEOUT); i++)
-			*c++ = get_fs_byte ((char *) arg++);
+#ifndef NEW_LINUX
+                        *c++ = get_fs_byte ((char *) arg++);
+#else
+                        get_user(*c++,(char *) arg++);
+#endif
 		break;
 	case JS_GET_TIMEOUT:
 		verify_area (VERIFY_WRITE, (void *) arg,
 			     sizeof (JS_DATA[0].JS_TIMEOUT));
 		c = (char *) &JS_DATA[minor].JS_TIMEOUT;
 		for (i = 0; i < sizeof (JS_DATA[0].JS_TIMEOUT); i++)
-			put_fs_byte (*c++, (char *) arg++);
+#ifndef NEW_LINUX
+                        put_fs_byte (*c++, (char *) arg++);
+#else
+		        put_user(*c++, (char *) arg++);
+#endif
 		break;
 	case JS_SET_TIMELIMIT:
 		verify_area (VERIFY_READ, (void *) arg,
 			     sizeof (JS_DATA[0].JS_TIMELIMIT));
 		c = (char *) &JS_DATA[minor].JS_TIMELIMIT;
 		for (i = 0; i < sizeof (JS_DATA[0].JS_TIMELIMIT); i++)
-			*c++ = get_fs_byte ((char *) arg++);
+#ifndef NEW_LINUX
+                        *c++ = get_fs_byte ((char *) arg++);
+#else
+			get_user(*c++,(char *) arg++);
+#endif
 		break;
 	case JS_GET_TIMELIMIT:
 		verify_area (VERIFY_WRITE, (void *) arg,
 			     sizeof (JS_DATA[0].JS_TIMELIMIT));
 		c = (char *) &JS_DATA[minor].JS_TIMELIMIT;
 		for (i = 0; i < sizeof (JS_DATA[0].JS_TIMELIMIT); i++)
-			put_fs_byte (*c++, (char *) arg++);
+#ifndef NEW_LINUX
+                        put_fs_byte (*c++, (char *) arg++);
+#else
+			put_user(*c++, (char *) arg++);
+#endif
 		break;
 	case JS_GET_ALL:
 		verify_area (VERIFY_WRITE, (void *) arg,
 			     sizeof (struct JS_DATA_SAVE_TYPE));
 		c = (char *) &JS_DATA[minor];
 		for (i = 0; i < sizeof (struct JS_DATA_SAVE_TYPE); i++)
-			put_fs_byte (*c++, (char *) arg++);
+#ifndef NEW_LINUX
+                        put_fs_byte (*c++, (char *) arg++);
+#else
+			put_user(*c++, (char *) arg++);
+#endif
 		break;
 	case JS_SET_ALL:
 		verify_area (VERIFY_READ, (void *) arg,
@@ -160,7 +202,11 @@
 		save_busy = JS_DATA[minor].BUSY;
 		c = (char *) &JS_DATA[minor];
 		for (i = 0; i < sizeof (struct JS_DATA_SAVE_TYPE); i++)
-			*c++ = get_fs_byte ((char *) arg++);
+#ifndef NEW_LINUX
+                        *c++ = get_fs_byte ((char *) arg++);
+#else
+			get_user(*c++,(char *) arg++);
+#endif
 		JS_DATA[minor].BUSY = save_busy;
 		break;
 	default:
@@ -302,7 +348,12 @@
 	}
 
 	for (c = (char *) &JS_DATA[minor].JS_SAVE, j = 0; j < JS_RETURN; j++)
-		put_fs_byte (*c++, buf++);	/*copy to user space*/
+
+#ifndef NEW_LINUX
+                put_fs_byte (*c++, buf++);     /*copy to user space*/
+#else
+                put_user (*c++, buf++);        /*copy to user space*/
+#endif
 	return JS_RETURN;
 }
 
--- Makefile~	Thu Apr  4 04:48:51 1996
+++ Makefile	Tue Jan  7 02:07:49 1997
@@ -5,6 +5,7 @@
 PROGS		= js jscal
 BINDIR		= /usr/local/bin
 MANDIR		= /usr/man
+MODDIR		= /lib/modules/current/misc
 
 all: joystick.o $(PROGS)
 
@@ -28,9 +29,11 @@
 install: all devs install.man
 	install -d $(BINDIR)
 	install $(PROGS) $(BINDIR)
-	install -d $(MANDIR)/man4
+	install -d $(MODDIR)
+	install joystick.o $(MODDIR)
 
 install.man:
+	install -d $(MANDIR)/man4
 	install -m 644 js.4 $(MANDIR)/man4
 	
 dist:	clean
