patch-2.4.10 linux/drivers/char/joystick/ns558.c
Next file: linux/drivers/char/joystick/pcigame.c
Previous file: linux/drivers/char/joystick/magellan.c
Back to the patch index
Back to the overall index
- Lines: 256
- Date:
Wed Sep 12 15:34:06 2001
- Orig file:
v2.4.9/linux/drivers/char/joystick/ns558.c
- Orig date:
Wed Apr 11 19:02:30 2001
diff -u --recursive --new-file v2.4.9/linux/drivers/char/joystick/ns558.c linux/drivers/char/joystick/ns558.c
@@ -1,7 +1,7 @@
/*
- * $Id: ns558.c,v 1.27 2001/03/28 09:25:05 vojtech Exp $
+ * $Id: ns558.c,v 1.29 2001/04/24 07:48:56 vojtech Exp $
*
- * Copyright (c) 1999-2000 Vojtech Pavlik
+ * Copyright (c) 1999-2001 Vojtech Pavlik
* Copyright (c) 1999 Brian Gerst
*
* Sponsored by SuSE
@@ -42,23 +42,23 @@
#include <linux/isapnp.h>
MODULE_AUTHOR("Vojtech Pavlik <vojtech@ucw.cz>");
+MODULE_LICENSE("GPL");
#define NS558_ISA 1
#define NS558_PNP 2
-#define NS558_PCI 3
static int ns558_isa_portlist[] = { 0x200, 0x201, 0x202, 0x203, 0x204, 0x205, 0x207, 0x209,
0x20b, 0x20c, 0x20e, 0x20f, 0x211, 0x219, 0x101, 0 };
struct ns558 {
int type;
+ int size;
struct pci_dev *dev;
struct ns558 *next;
struct gameport gameport;
};
static struct ns558 *ns558;
-static int ns558_pci;
/*
* ns558_isa_probe() tries to find an isa gameport at the
@@ -132,122 +132,43 @@
i--;
if (!(port = kmalloc(sizeof(struct ns558), GFP_KERNEL))) {
- printk(KERN_ERR "Memory allocation failed.\n");
+ printk(KERN_ERR "ns558: Memory allocation failed.\n");
return next;
}
memset(port, 0, sizeof(struct ns558));
port->next = next;
port->type = NS558_ISA;
+ port->size = (1 << i);
port->gameport.io = io & (-1 << i);
- port->gameport.size = (1 << i);
- request_region(port->gameport.io, port->gameport.size, "ns558-isa");
+ request_region(port->gameport.io, (1 << i), "ns558-isa");
gameport_register_port(&port->gameport);
printk(KERN_INFO "gameport%d: NS558 ISA at %#x", port->gameport.number, port->gameport.io);
- if (port->gameport.size > 1) printk(" size %d", port->gameport.size);
+ if (port->size > 1) printk(" size %d", port->size);
printk(" speed %d kHz\n", port->gameport.speed);
return port;
}
-#ifdef CONFIG_PCI
-static struct pci_device_id ns558_pci_tbl[] __devinitdata = {
- { 0x1102, 0x7002, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0 }, /* SB Live! gameport */
- { 0x125d, 0x1969, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 4 }, /* ESS Solo 1 */
- { 0x5333, 0xca00, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 4 }, /* S3 SonicVibes */
- { 0, }
-};
-MODULE_DEVICE_TABLE(pci, ns558_pci_tbl);
-
-static int __devinit ns558_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
-{
- int ioport, iolen;
- int rc;
- struct ns558 *port;
-
- rc = pci_enable_device(pdev);
- if (rc) {
- printk(KERN_ERR "ns558: Cannot enable PCI gameport (bus %d, devfn %d) error=%d\n",
- pdev->bus->number, pdev->devfn, rc);
- return rc;
- }
-
- ioport = pci_resource_start(pdev, ent->driver_data);
- iolen = pci_resource_len(pdev, ent->driver_data);
-
- if (!request_region(ioport, iolen, "ns558-pci"))
- return -EBUSY;
-
- 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));
-
- port->type = NS558_PCI;
- port->gameport.io = ioport;
- port->gameport.size = iolen;
- port->dev = pdev;
-
- pdev->driver_data = port;
-
- gameport_register_port(&port->gameport);
-
- printk(KERN_INFO "gameport%d: NS558 PCI at %#x", port->gameport.number, port->gameport.io);
- if (port->gameport.size > 1) printk(" size %d", port->gameport.size);
- printk(" speed %d kHz\n", port->gameport.speed);
-
- return 0;
-}
-
-static void __devexit ns558_pci_remove(struct pci_dev *pdev)
-{
- 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 = {
- name: "PCI Gameport",
- id_table: ns558_pci_tbl,
- probe: ns558_pci_probe,
- remove: ns558_pci_remove,
-};
-#else
-static struct pci_driver ns558_pci_driver;
-#endif /* CONFIG_PCI */
-
-
#if defined(CONFIG_ISAPNP) || (defined(CONFIG_ISAPNP_MODULE) && defined(MODULE))
#define NSS558_ISAPNP
#endif
#ifdef NSS558_ISAPNP
-/*
- * PnP IDs:
- *
- * @P@0001 - ALS 100 (no comp. ID)
- * CTL00c1 - SB AWE32 PnP
- * CTL00c3 - SB AWE64 PnP
- * CTL00f0 - SB16 PnP / Vibra 16x
- * CTL7001 - SB Vibra16C PnP (no comp. ID)
- * CTL7002 - SB AWE32 (no comp. ID)
- * CSC0b35 - Crystal (no comp. ID)
- * TER1141 - Terratec AD1818
- * YMM0800 - Yamaha OPL3-SA3
- *
- * PNPb02f - Generic gameport
- */
static struct isapnp_device_id pnp_devids[] = {
{ ISAPNP_ANY_ID, ISAPNP_ANY_ID, ISAPNP_VENDOR('@','P','@'), ISAPNP_DEVICE(0x0001), 0 },
+ { ISAPNP_ANY_ID, ISAPNP_ANY_ID, ISAPNP_VENDOR('@','P','@'), ISAPNP_DEVICE(0x2001), 0 },
{ ISAPNP_ANY_ID, ISAPNP_ANY_ID, ISAPNP_VENDOR('C','T','L'), ISAPNP_DEVICE(0x7001), 0 },
{ ISAPNP_ANY_ID, ISAPNP_ANY_ID, ISAPNP_VENDOR('C','T','L'), ISAPNP_DEVICE(0x7002), 0 },
+ { ISAPNP_ANY_ID, ISAPNP_ANY_ID, ISAPNP_VENDOR('C','S','C'), ISAPNP_DEVICE(0x0010), 0 },
+ { ISAPNP_ANY_ID, ISAPNP_ANY_ID, ISAPNP_VENDOR('C','S','C'), ISAPNP_DEVICE(0x0110), 0 },
{ ISAPNP_ANY_ID, ISAPNP_ANY_ID, ISAPNP_VENDOR('C','S','C'), ISAPNP_DEVICE(0x0b35), 0 },
+ { ISAPNP_ANY_ID, ISAPNP_ANY_ID, ISAPNP_VENDOR('C','S','C'), ISAPNP_DEVICE(0x0010), 0 },
+ { ISAPNP_ANY_ID, ISAPNP_ANY_ID, ISAPNP_VENDOR('C','S','C'), ISAPNP_DEVICE(0x0110), 0 },
{ ISAPNP_ANY_ID, ISAPNP_ANY_ID, ISAPNP_VENDOR('P','N','P'), ISAPNP_DEVICE(0xb02f), 0 },
{ 0, },
};
@@ -263,12 +184,12 @@
return next;
if (!(dev->resource[0].flags & IORESOURCE_IO)) {
- printk(KERN_WARNING "No i/o ports on a gameport? Weird\n");
+ printk(KERN_WARNING "ns558: No i/o ports on a gameport? Weird\n");
return next;
}
if (dev->activate && dev->activate(dev) < 0) {
- printk(KERN_ERR "PnP resource allocation failed\n");
+ printk(KERN_ERR "ns558: PnP resource allocation failed\n");
return next;
}
@@ -279,7 +200,7 @@
goto deactivate;
if (!(port = kmalloc(sizeof(struct ns558), GFP_KERNEL))) {
- printk(KERN_ERR "Memory allocation failed.\n");
+ printk(KERN_ERR "ns558: Memory allocation failed.\n");
goto deactivate;
}
memset(port, 0, sizeof(struct ns558));
@@ -287,13 +208,13 @@
port->next = next;
port->type = NS558_PNP;
port->gameport.io = ioport;
- port->gameport.size = iolen;
+ port->size = iolen;
port->dev = dev;
gameport_register_port(&port->gameport);
printk(KERN_INFO "gameport%d: NS558 PnP at %#x", port->gameport.number, port->gameport.io);
- if (port->gameport.size > 1) printk(" size %d", port->gameport.size);
+ if (iolen > 1) printk(" size %d", iolen);
printk(" speed %d kHz\n", port->gameport.speed);
return port;
@@ -309,18 +230,11 @@
{
int i = 0;
#ifdef NSS558_ISAPNP
- struct pci_dev *dev = NULL;
struct isapnp_device_id *devid;
+ struct pci_dev *dev = NULL;
#endif
/*
- * Probe for PCI ports. Always probe for PCI first,
- * it is the least-invasive probe.
- */
-
- ns558_pci = !pci_module_init(&ns558_pci_driver);
-
-/*
* Probe for ISA ports.
*/
@@ -339,7 +253,7 @@
}
#endif
- return (ns558 || ns558_pci) ? 0 : -ENODEV;
+ return ns558 ? 0 : -ENODEV;
}
void __exit ns558_exit(void)
@@ -358,7 +272,7 @@
#endif
case NS558_ISA:
- release_region(port->gameport.io, port->gameport.size);
+ release_region(port->gameport.io, port->size);
break;
default:
@@ -369,9 +283,6 @@
kfree(port);
port = next;
}
-
- if (ns558_pci)
- pci_unregister_driver(&ns558_pci_driver);
}
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)