mirror of
https://github.com/Fishwaldo/linux-bl808.git
synced 2025-06-17 20:25:19 +00:00
[PATCH] hp300: fix driver_register() return handling, remove dio_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. dio_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 dio_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: Philip Blundell <philb@gnu.org> Cc: Jochen Friedrich <jochen@scram.de> Cc: "Antonino A. Daplas" <adaplas@pol.net> Cc: Jeff Garzik <jeff@garzik.org> Signed-off-by: Andrew Morton <akpm@osdl.org> Signed-off-by: Linus Torvalds <torvalds@osdl.org>
This commit is contained in:
parent
5930860296
commit
e51c01b084
5 changed files with 11 additions and 46 deletions
|
@ -276,37 +276,5 @@ static inline void dio_set_drvdata (struct dio_dev *d, void *data)
|
|||
dev_set_drvdata(&d->dev, data);
|
||||
}
|
||||
|
||||
/*
|
||||
* A helper function which helps ensure correct dio_driver
|
||||
* setup and cleanup for commonly-encountered hotplug/modular cases
|
||||
*
|
||||
* This MUST stay in a header, as it checks for -DMODULE
|
||||
*/
|
||||
static inline int dio_module_init(struct dio_driver *drv)
|
||||
{
|
||||
int rc = dio_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 DIO driver instance
|
||||
* and return some sort of error */
|
||||
dio_unregister_driver(drv);
|
||||
|
||||
return rc;
|
||||
}
|
||||
|
||||
#endif /* __KERNEL__ */
|
||||
#endif /* ndef _LINUX_DIO_H */
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue