Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

[PATCH] amiga: fix driver_register() return handling, remove zorro_module_init()

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>

authored by

Bjorn Helgaas and committed by
Linus Torvalds
33d8675e c2f6fabb

+7 -45
+1 -1
drivers/net/a2065.c
··· 829 829 830 830 static int __init a2065_init_module(void) 831 831 { 832 - return zorro_module_init(&a2065_driver); 832 + return zorro_register_driver(&a2065_driver); 833 833 } 834 834 835 835 static void __exit a2065_cleanup_module(void)
+1 -1
drivers/net/ariadne.c
··· 864 864 865 865 static int __init ariadne_init_module(void) 866 866 { 867 - return zorro_module_init(&ariadne_driver); 867 + return zorro_register_driver(&ariadne_driver); 868 868 } 869 869 870 870 static void __exit ariadne_cleanup_module(void)
+1 -1
drivers/net/hydra.c
··· 242 242 243 243 static int __init hydra_init_module(void) 244 244 { 245 - return zorro_module_init(&hydra_driver); 245 + return zorro_register_driver(&hydra_driver); 246 246 } 247 247 248 248 static void __exit hydra_cleanup_module(void)
+1 -1
drivers/net/zorro8390.c
··· 426 426 427 427 static int __init zorro8390_init_module(void) 428 428 { 429 - return zorro_module_init(&zorro8390_driver); 429 + return zorro_register_driver(&zorro8390_driver); 430 430 } 431 431 432 432 static void __exit zorro8390_cleanup_module(void)
+1 -1
drivers/video/cirrusfb.c
··· 2622 2622 #endif 2623 2623 2624 2624 #ifdef CONFIG_ZORRO 2625 - error |= zorro_module_init(&cirrusfb_zorro_driver); 2625 + error |= zorro_register_driver(&cirrusfb_zorro_driver); 2626 2626 #endif 2627 2627 #ifdef CONFIG_PCI 2628 2628 error |= pci_register_driver(&cirrusfb_pci_driver);
+2 -7
drivers/zorro/zorro-driver.c
··· 65 65 * @drv: the driver structure to register 66 66 * 67 67 * Adds the driver structure to the list of registered drivers 68 - * Returns the number of Zorro devices which were claimed by the driver 69 - * during registration. The driver remains registered even if the 70 - * return value is zero. 68 + * Returns zero or a negative error value. 71 69 */ 72 70 73 71 int zorro_register_driver(struct zorro_driver *drv) 74 72 { 75 - int count = 0; 76 - 77 73 /* initialize common driver fields */ 78 74 drv->driver.name = drv->name; 79 75 drv->driver.bus = &zorro_bus_type; 80 76 81 77 /* register with core */ 82 - count = driver_register(&drv->driver); 83 - return count ? count : 1; 78 + return driver_register(&drv->driver); 84 79 } 85 80 86 81
-33
include/linux/zorro.h
··· 271 271 } 272 272 273 273 274 - /* 275 - * A helper function which helps ensure correct zorro_driver 276 - * setup and cleanup for commonly-encountered hotplug/modular cases 277 - * 278 - * This MUST stay in a header, as it checks for -DMODULE 279 - */ 280 - static inline int zorro_module_init(struct zorro_driver *drv) 281 - { 282 - int rc = zorro_register_driver(drv); 283 - 284 - if (rc > 0) 285 - return 0; 286 - 287 - /* iff CONFIG_HOTPLUG and built into kernel, we should 288 - * leave the driver around for future hotplug events. 289 - * For the module case, a hotplug daemon of some sort 290 - * should load a module in response to an insert event. */ 291 - #if defined(CONFIG_HOTPLUG) && !defined(MODULE) 292 - if (rc == 0) 293 - return 0; 294 - #else 295 - if (rc == 0) 296 - rc = -ENODEV; 297 - #endif 298 - 299 - /* if we get here, we need to clean up Zorro driver instance 300 - * and return some sort of error */ 301 - zorro_unregister_driver(drv); 302 - 303 - return rc; 304 - } 305 - 306 - 307 274 /* 308 275 * Bitmask indicating portions of available Zorro II RAM that are unused 309 276 * by the system. Every bit represents a 64K chunk, for a maximum of 8MB