vserver 2.0 rc7
[linux-2.6.git] / drivers / pci / pci-driver.c
index 8a09a95..cf2cff7 100644 (file)
@@ -49,13 +49,6 @@ pci_device_probe_dynamic(struct pci_driver *drv, struct pci_dev *pci_dev)
        return error;
 }
 
-static inline void
-dynid_init(struct dynid *dynid)
-{
-       memset(dynid, 0, sizeof(*dynid));
-       INIT_LIST_HEAD(&dynid->node);
-}
-
 /**
  * store_new_id
  *
@@ -82,8 +75,9 @@ store_new_id(struct device_driver *driver, const char *buf, size_t count)
        dynid = kmalloc(sizeof(*dynid), GFP_KERNEL);
        if (!dynid)
                return -ENOMEM;
-       dynid_init(dynid);
 
+       memset(dynid, 0, sizeof(*dynid));
+       INIT_LIST_HEAD(&dynid->node);
        dynid->id.vendor = vendor;
        dynid->id.device = device;
        dynid->id.subvendor = subvendor;
@@ -115,7 +109,6 @@ static DRIVER_ATTR(new_id, S_IWUSR, NULL, store_new_id);
 static inline void
 pci_init_dynids(struct pci_dynids *dynids)
 {
-       memset(dynids, 0, sizeof(*dynids));
        spin_lock_init(&dynids->lock);
        INIT_LIST_HEAD(&dynids->list);
 }
@@ -168,7 +161,6 @@ static inline int pci_device_probe_dynamic(struct pci_driver *drv, struct pci_de
 {
        return -ENODEV;
 }
-static inline void dynid_init(struct dynid *dynid) {}
 static inline void pci_init_dynids(struct pci_dynids *dynids) {}
 static inline void pci_free_dynids(struct pci_driver *drv) {}
 static inline int pci_create_newid_file(struct pci_driver *drv)
@@ -326,6 +318,14 @@ static int pci_device_resume(struct device * dev)
        return 0;
 }
 
+static void pci_device_shutdown(struct device *dev)
+{
+       struct pci_dev *pci_dev = to_pci_dev(dev);
+       struct pci_driver *drv = pci_dev->driver;
+
+       if (drv && drv->shutdown)
+               drv->shutdown(pci_dev);
+}
 
 #define kobj_to_pci_driver(obj) container_of(obj, struct device_driver, kobj)
 #define attr_to_driver_attribute(obj) container_of(obj, struct driver_attribute, attr)
@@ -381,7 +381,7 @@ pci_populate_driver_dir(struct pci_driver *drv)
  * 
  * Adds the driver structure to the list of registered drivers.
  * Returns a negative value on error, otherwise 0. 
- * If no error occured, the driver remains registered even if 
+ * If no error occurred, the driver remains registered even if 
  * no device was claimed during registration.
  */
 int pci_register_driver(struct pci_driver *drv)
@@ -393,6 +393,10 @@ int pci_register_driver(struct pci_driver *drv)
        drv->driver.bus = &pci_bus_type;
        drv->driver.probe = pci_device_probe;
        drv->driver.remove = pci_device_remove;
+       /* FIXME, once all of the existing PCI drivers have been fixed to set
+        * the pci shutdown function, this test can go away. */
+       if (!drv->driver.shutdown)
+               drv->driver.shutdown = pci_device_shutdown;
        drv->driver.owner = drv->owner;
        drv->driver.kobj.ktype = &pci_driver_kobj_type;
        pci_init_dynids(&drv->dynids);