lkml.org 
[lkml]   [2000]   [Feb]   [20]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
Date
From
SubjectRe: [PATCH] Handling failure of pci_register_driver().
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 */
\
 
 \ /
  Last update: 2005-03-22 13:56    [W:0.029 / U:0.388 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site