patch-2.4.0-test7 linux/drivers/char/joystick/ns558.c

Next file: linux/drivers/char/joystick/sidewinder.c
Previous file: linux/drivers/char/joystick/iforce.c
Back to the patch index
Back to the overall index

diff -u --recursive --new-file v2.4.0-test6/linux/drivers/char/joystick/ns558.c linux/drivers/char/joystick/ns558.c
@@ -1,5 +1,5 @@
 /*
- * $Id: ns558.c,v 1.11 2000/06/20 23:35:03 vojtech Exp $
+ * $Id: ns558.c,v 1.16 2000/08/17 20:03:56 vojtech Exp $
  *
  *  Copyright (c) 1999-2000 Vojtech Pavlik
  *  Copyright (c) 1999 Brian Gerst
@@ -138,7 +138,7 @@
 	
 	port->next = next;
 	port->type = NS558_ISA;
-	port->gameport.io = io;
+	port->gameport.io = io & (-1 << i);
 	port->gameport.size = (1 << i);
 
 	request_region(port->gameport.io, port->gameport.size, "ns558-isa");
@@ -182,6 +182,7 @@
 
 	if (!(port = kmalloc(sizeof(struct ns558), GFP_KERNEL))) {
 		printk(KERN_ERR "Memory allocation failed.\n");
+		release_region(ioport, iolen);
 		return -ENOMEM;
 	}
 	memset(port, 0, sizeof(struct ns558));
@@ -208,6 +209,7 @@
 {
 	struct ns558 *port = (struct ns558 *)pdev->driver_data;
 	release_region(port->gameport.io, port->gameport.size);
+	kfree(port);
 }
 
 static struct pci_driver ns558_pci_driver = {
@@ -216,10 +218,16 @@
         probe:          ns558_pci_probe,
         remove:         ns558_pci_remove,
 };
+#else
+static struct pci_driver ns558_pci_driver;
 #endif /* CONFIG_PCI */
 
 
-#ifdef CONFIG_ISAPNP
+#if defined(CONFIG_ISAPNP) || (defined(CONFIG_ISAPNP_MODULE) && defined(MODULE))
+#define NSS558_ISAPNP
+#endif
+
+#ifdef NSS558_ISAPNP
 /*
  * PnP IDs:
  *
@@ -297,7 +305,7 @@
 int __init ns558_init(void)
 {
 	int i = 0;
-#ifdef CONFIG_ISAPNP
+#ifdef NSS558_ISAPNP
 	struct pci_dev *dev = NULL;
 	struct pnp_devid *devid;
 #endif
@@ -310,17 +318,10 @@
 		ns558 = ns558_isa_probe(ns558_isa_portlist[i++], ns558);
 
 /*
- * Probe for PCI ports.
- */
-#ifdef CONFIG_PCI
-	pci_register_driver(&ns558_pci_driver);
-#endif
-
-/*
  * Probe for PnP ports.
  */
 
-#ifdef CONFIG_ISAPNP
+#ifdef NSS558_ISAPNP
 	for (devid = pnp_devids; devid->vendor; devid++) {
 		while ((dev = isapnp_find_dev(NULL, devid->vendor, devid->device, dev))) {
 			ns558 = ns558_pnp_probe(dev, ns558);
@@ -328,7 +329,14 @@
 	}
 #endif
 
-	return -!ns558;
+/*
+ * Probe for PCI ports.
+ */
+
+	if (!ns558 && pci_module_init(&ns558_pci_driver))
+		return -ENODEV;
+
+	return 0;
 }
 
 void __exit ns558_exit(void)
@@ -339,7 +347,7 @@
 		gameport_unregister_port(&port->gameport);
 		switch (port->type) {
 
-#ifdef CONFIG_ISAPNP
+#ifdef NSS558_ISAPNP
 			case NS558_PNP:
 				if (port->dev->deactivate)
 					port->dev->deactivate(port->dev);
@@ -357,9 +365,7 @@
 		port = port->next;
 	}
 
-#ifdef CONFIG_PCI
 	pci_unregister_driver(&ns558_pci_driver);
-#endif
 }
 
 module_init(ns558_init);

FUNET's LINUX-ADM group, linux-adm@nic.funet.fi
TCL-scripts by Sam Shen (who was at: slshen@lbl.gov)