patch-2.1.126 linux/drivers/char/joystick/joy-turbografx.c

Next file: linux/drivers/char/joystick/joystick.c
Previous file: linux/drivers/char/joystick/joy-thrustmaster.c
Back to the patch index
Back to the overall index

diff -u --recursive --new-file v2.1.125/linux/drivers/char/joystick/joy-turbografx.c linux/drivers/char/joystick/joy-turbografx.c
@@ -61,8 +61,6 @@
 struct js_tg_info {
 #ifdef USE_PARPORT
 	struct pardevice *port;	/* parport device */
-	int use;		/* use count */
-	int wanted;		/* parport wanted */
 #else
 	int port;		/* hw port */
 #endif
@@ -99,19 +97,11 @@
 
 int js_tg_open(struct js_dev *dev)
 {
-	MOD_INC_USE_COUNT;
-
 #ifdef USE_PARPORT
-	{
-		struct js_tg_info *info = dev->port->info;
-		if (!info->use && parport_claim(info->port)) {
-			printk(KERN_WARNING "joy-tg: parport busy\n");		/* port currently not available ... */
-			info->wanted++;						/* we'll claim it on wakeup */
-			return 0;
-		}
-		info->use++;
-	}
+	struct js_tg_info *info = dev->port->info;
+	if (!MOD_IN_USE && parport_claim(info->port)) return -EBUSY; 
 #endif
+	MOD_INC_USE_COUNT;
 	return 0;
 }
 
@@ -122,33 +112,14 @@
 int js_tg_close(struct js_dev *dev)
 {
 #ifdef USE_PARPORT
-	struct js_tg_info *info = dev->port->info;
-
-	if (!--info->use)
-		parport_release(info->port);
+        struct js_tg_info *info = dev->port->info;
 #endif
-	MOD_DEC_USE_COUNT;
-
-	return 0;
-}
-
-/*
- * parport wakeup callback: claim the port!
- */
-
+        MOD_DEC_USE_COUNT;
 #ifdef USE_PARPORT
-static void js_tg_wakeup(void *v)
-{
-	struct js_tg_info *info = js_tg_port->info;	/* FIXME! We can have more than 1 port! */
-
-	if (!info->use && info->wanted)
-	{
-		parport_claim(info->port);
-		info->use++;
-		info->wanted--;
-	}
-}
+        if (!MOD_IN_USE) parport_release(info->port);
 #endif
+        return 0;
+}
 
 #ifdef MODULE
 void cleanup_module(void)
@@ -217,9 +188,9 @@
 			return port;
 		}
 
-		info.port = parport_register_device(pp, "joystick (turbografx)", NULL, js_tg_wakeup, NULL, 0, NULL);
-		info.wanted = 0;
-		info.use = 0;
+		info.port = parport_register_device(pp, "joystick (turbografx)", NULL, NULL, NULL, PARPORT_DEV_EXCL, NULL);
+		if (!info.port)
+			return port;
 	}
 #else
 	info.port = config[0];

FUNET's LINUX-ADM group, linux-adm@nic.funet.fi
TCL-scripts by Sam Shen, slshen@lbl.gov