public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* ns558 pci/isa change
@ 2000-11-13 23:15 Pete Wyckoff
  2000-11-13 23:52 ` Jeff Garzik
  0 siblings, 1 reply; 2+ messages in thread
From: Pete Wyckoff @ 2000-11-13 23:15 UTC (permalink / raw)
  To: vojtech; +Cc: linux-kernel

My joystick stopped working at 2.4.0-test10 due to a patch to
drivers/char/joystick/ns558.c that moves pci probing ahead of
isa probing.

The problem is that pci_module_init can return -ENODEV into i,
which is then used to index the ISA portlist.  ISA probing assumes
that i is initialized to zero.

Trivial fix attached, with plenty of context.

		-- Pete

--- drivers/char/joystick/ns558.c.orig	Mon Nov 13 18:04:16 2000
+++ drivers/char/joystick/ns558.c	Mon Nov 13 18:11:41 2000
@@ -299,37 +299,38 @@
 deactivate:
 	if (dev->deactivate)
 		dev->deactivate(dev);
 	return next;
 }
 #endif
 
 int __init ns558_init(void)
 {
-	int i = 0;
+	int i;
 #ifdef NSS558_ISAPNP
 	struct pci_dev *dev = NULL;
 	struct pnp_devid *devid;
 #endif
 
 /*
  * Probe for PCI ports.  Always probe for PCI first,
  * it is the least-invasive probe.
  */
 
 	i = pci_module_init(&ns558_pci_driver);
 	if (i == 0)
 		have_pci_devices = 1;
 
 /*
  * Probe for ISA ports.
  */
 
+	i = 0;
 	while (ns558_isa_portlist[i]) 
 		ns558 = ns558_isa_probe(ns558_isa_portlist[i++], ns558);
 
 /*
  * Probe for PnP ports.
  */
 
 #ifdef NSS558_ISAPNP
 	for (devid = pnp_devids; devid->vendor; devid++) {
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
Please read the FAQ at http://www.tux.org/lkml/

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: ns558 pci/isa change
  2000-11-13 23:15 ns558 pci/isa change Pete Wyckoff
@ 2000-11-13 23:52 ` Jeff Garzik
  0 siblings, 0 replies; 2+ messages in thread
From: Jeff Garzik @ 2000-11-13 23:52 UTC (permalink / raw)
  To: Pete Wyckoff; +Cc: vojtech, linux-kernel

[-- Attachment #1: Type: text/plain, Size: 444 bytes --]

Pete Wyckoff wrote:
>         i = pci_module_init(&ns558_pci_driver);
>         if (i == 0)
>                 have_pci_devices = 1;
> 
>  /*
>   * Probe for ISA ports.
>   */
> 
> +       i = 0;

you don't want to lose the error code.  what you want to do is something
like the attached patch...

-- 
Jeff Garzik             |
Building 1024           | The chief enemy of creativity is "good" sense
MandrakeSoft            |          -- Picasso

[-- Attachment #2: ns558.patch --]
[-- Type: text/plain, Size: 1040 bytes --]

Index: drivers/char/joystick/ns558.c
===================================================================
RCS file: /cvsroot/gkernel/linux_2_4/drivers/char/joystick/ns558.c,v
retrieving revision 1.1.1.3
diff -u -r1.1.1.3 ns558.c
--- drivers/char/joystick/ns558.c	2000/10/22 23:21:03	1.1.1.3
+++ drivers/char/joystick/ns558.c	2000/11/13 23:51:49
@@ -58,7 +58,6 @@
 };
 	
 static struct ns558 *ns558;
-static int have_pci_devices;
 
 /*
  * ns558_isa_probe() tries to find an isa gameport at the
@@ -316,9 +315,8 @@
  * it is the least-invasive probe.
  */
 
-	i = pci_module_init(&ns558_pci_driver);
-	if (i == 0)
-		have_pci_devices = 1;
+	i = pci_register_driver(&ns558_pci_driver);
+	if (i < 0) return i;
 
 /*
  * Probe for ISA ports.
@@ -339,7 +337,7 @@
 	}
 #endif
 
-	return ns558 ? 0 : -ENODEV;
+	return 0;
 }
 
 void __exit ns558_exit(void)
@@ -368,8 +366,7 @@
 		port = port->next;
 	}
 
-	if (have_pci_devices)
-		pci_unregister_driver(&ns558_pci_driver);
+	pci_unregister_driver(&ns558_pci_driver);
 }
 
 module_init(ns558_init);

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2000-11-14  0:22 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2000-11-13 23:15 ns558 pci/isa change Pete Wyckoff
2000-11-13 23:52 ` Jeff Garzik

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox