[PATCH] amiga: fix driver_register() return handling, remove zorro_module_init()
authorBjorn Helgaas <bjorn.helgaas@hp.com>
Sat, 25 Mar 2006 11:07:20 +0000 (03:07 -0800)
committerLinus Torvalds <torvalds@g5.osdl.org>
Sat, 25 Mar 2006 16:22:53 +0000 (08:22 -0800)
Remove the assumption that driver_register() returns the number of devices
bound to the driver.  In fact, it returns zero for success or a negative
error value.

zorro_module_init() used the device count to automatically unregister and
unload drivers that found no devices.  That might have worked at one time,
but has been broken for some time because zorro_register_driver() returned
either a negative error or a positive count (never zero).  So it could only
unregister on failure, when it's not needed anyway.

This functionality could be resurrected in individual drivers by counting
devices in their .probe() methods.

Signed-off-by: Bjorn Helgaas <bjorn.helgaas@hp.com>
Cc: Geert Uytterhoeven <geert@linux-m68k.org>
Cc: Roman Zippel <zippel@linux-m68k.org>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
drivers/net/a2065.c
drivers/net/ariadne.c
drivers/net/hydra.c
drivers/net/zorro8390.c
drivers/video/cirrusfb.c
drivers/zorro/zorro-driver.c
include/linux/zorro.h

index 8e538a6d7d9793565e3095c8daa3ad755ec630d5..79bb56b8dcef00fa283284497004c0f7ba3a5dcd 100644 (file)
@@ -829,7 +829,7 @@ static void __devexit a2065_remove_one(struct zorro_dev *z)
 
 static int __init a2065_init_module(void)
 {
-       return zorro_module_init(&a2065_driver);
+       return zorro_register_driver(&a2065_driver);
 }
 
 static void __exit a2065_cleanup_module(void)
index 9fe93acfc8efa5adfcc86aef7c9186108d9b1c41..d1b6b1f794e214ced2db99c3d14c8a68fd9ae480 100644 (file)
@@ -864,7 +864,7 @@ static void __devexit ariadne_remove_one(struct zorro_dev *z)
 
 static int __init ariadne_init_module(void)
 {
-    return zorro_module_init(&ariadne_driver);
+    return zorro_register_driver(&ariadne_driver);
 }
 
 static void __exit ariadne_cleanup_module(void)
index 6e0ca7340a8fd9126d2837e94ddf4730e7e214e3..d9fb8e74e631d7e019e9d61fb30a04412b3c3be9 100644 (file)
@@ -242,7 +242,7 @@ static void __devexit hydra_remove_one(struct zorro_dev *z)
 
 static int __init hydra_init_module(void)
 {
-    return zorro_module_init(&hydra_driver);
+    return zorro_register_driver(&hydra_driver);
 }
 
 static void __exit hydra_cleanup_module(void)
index 761021603597036b041fe8f3ce9a1b8540249af6..8037e5806d0a48b33a28815cdd828cb90cfe77eb 100644 (file)
@@ -426,7 +426,7 @@ static void __devexit zorro8390_remove_one(struct zorro_dev *z)
 
 static int __init zorro8390_init_module(void)
 {
-    return zorro_module_init(&zorro8390_driver);
+    return zorro_register_driver(&zorro8390_driver);
 }
 
 static void __exit zorro8390_cleanup_module(void)
index e0dbdfc0c8b4289178d5dff1419992acd325cb78..66d6f2f0a219595833f425faa80fc16676b7c0dd 100644 (file)
@@ -2622,7 +2622,7 @@ static int __init cirrusfb_init(void)
 #endif
 
 #ifdef CONFIG_ZORRO
-       error |= zorro_module_init(&cirrusfb_zorro_driver);
+       error |= zorro_register_driver(&cirrusfb_zorro_driver);
 #endif
 #ifdef CONFIG_PCI
        error |= pci_register_driver(&cirrusfb_pci_driver);
index fcbee748c59227b2f344ab483be2558d93e749c5..067c07be928ce3a27512731799b14081a8cbd272 100644 (file)
@@ -65,22 +65,17 @@ static int zorro_device_probe(struct device *dev)
      *  @drv: the driver structure to register
      *
      *  Adds the driver structure to the list of registered drivers
-     *  Returns the number of Zorro devices which were claimed by the driver
-     *  during registration.  The driver remains registered even if the
-     *  return value is zero.
+     *  Returns zero or a negative error value.
      */
 
 int zorro_register_driver(struct zorro_driver *drv)
 {
-       int count = 0;
-
        /* initialize common driver fields */
        drv->driver.name = drv->name;
        drv->driver.bus = &zorro_bus_type;
 
        /* register with core */
-       count = driver_register(&drv->driver);
-       return count ? count : 1;
+       return driver_register(&drv->driver);
 }
 
 
index ba5b72768bbe54de9aa6af922017c013971684c8..2f135cf6eef1600c947e983d59846fe7dedca4e6 100644 (file)
@@ -271,39 +271,6 @@ static inline void zorro_set_drvdata (struct zorro_dev *z, void *data)
 }
 
 
-/*
- * A helper function which helps ensure correct zorro_driver
- * setup and cleanup for commonly-encountered hotplug/modular cases
- *
- * This MUST stay in a header, as it checks for -DMODULE
- */
-static inline int zorro_module_init(struct zorro_driver *drv)
-{
-       int rc = zorro_register_driver(drv);
-
-       if (rc > 0)
-               return 0;
-
-       /* iff CONFIG_HOTPLUG and built into kernel, we should
-        * leave the driver around for future hotplug events.
-        * For the module case, a hotplug daemon of some sort
-        * should load a module in response to an insert event. */
-#if defined(CONFIG_HOTPLUG) && !defined(MODULE)
-       if (rc == 0)
-               return 0;
-#else
-       if (rc == 0)
-               rc = -ENODEV;
-#endif
-
-       /* if we get here, we need to clean up Zorro driver instance
-        * and return some sort of error */
-       zorro_unregister_driver(drv);
-
-       return rc;
-}
-
-
     /*
      *  Bitmask indicating portions of available Zorro II RAM that are unused
      *  by the system. Every bit represents a 64K chunk, for a maximum of 8MB