Re: [PATCH] Handling failure of pci_register_driver().

From: Jeff Garzik (jgarzik@mandrakesoft.com)
Date: Sun Feb 20 2000 - 20:26:39 EST


The attached patch against 2.3.47-pre7 was recently sent up the
ladder...

-- 
Jeff Garzik              | Teutonic:
Building 1024            |        Not enough gin.
MandrakeSoft, Inc.       |

Index: include/linux/pci.h =================================================================== RCS file: /g/cvslan/linux_2_3/include/linux/pci.h,v retrieving revision 1.1.1.28 retrieving revision 1.1.1.28.6.1 diff -u -r1.1.1.28 -r1.1.1.28.6.1 --- include/linux/pci.h 2000/02/19 00:15:26 1.1.1.28 +++ include/linux/pci.h 2000/02/20 23:47:54 1.1.1.28.6.1 @@ -574,7 +574,39 @@ { return NULL; } extern inline void pci_set_master(struct pci_dev *dev) { } -extern inline int pci_enable_device(struct pci_dev *dev) { return 0; } +extern inline int pci_enable_device(struct pci_dev *dev) { return -EIO; } +extern inline int pci_module_init(struct pci_driver *drv) { return -ENODEV; } + +#else + +/* + * a helper function which helps ensure correct pci_driver + * setup and cleanup for commonly-encountered hotplug/modular cases + * + * This MUST stay in a header, as it checks for -DMODULE + */ +extern inline int pci_module_init(struct pci_driver *drv) +{ + int rc = pci_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; +#endif + + /* if we get here, we need to clean up pci driver instance + * and return some sort of error */ + pci_unregister_driver (drv); + + return -ENODEV; +} #endif /* !CONFIG_PCI */

- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.rutgers.edu Please read the FAQ at http://www.tux.org/lkml/



This archive was generated by hypermail 2b29 : Wed Feb 23 2000 - 21:00:26 EST