Commit 52d16b41 authored by Patrick Mochel's avatar Patrick Mochel

PCI driver mgmt:

- Make sure proper pci id is passed to probe()
- make sure pci_dev->driver is set and reset on driver registration/unregistration
- call remove_driver to force unload of driver on unregistration
parent 96d36ec0
...@@ -38,23 +38,35 @@ pci_match_device(const struct pci_device_id *ids, const struct pci_dev *dev) ...@@ -38,23 +38,35 @@ pci_match_device(const struct pci_device_id *ids, const struct pci_dev *dev)
static int pci_device_probe(struct device * dev) static int pci_device_probe(struct device * dev)
{ {
int error = 0; int error = 0;
struct pci_driver *drv;
struct pci_driver * drv = list_entry(dev->driver,struct pci_driver,driver); struct pci_dev *pci_dev;
struct pci_dev * pci_dev = list_entry(dev,struct pci_dev,dev);
drv = list_entry(dev->driver, struct pci_driver, driver);
if (drv->probe) pci_dev = list_entry(dev, struct pci_dev, dev);
error = drv->probe(pci_dev,drv->id_table);
return error > 0 ? 0 : -ENODEV; if (drv->probe) {
const struct pci_device_id *id;
id = pci_match_device(drv->id_table, pci_dev);
if (id)
error = drv->probe(pci_dev, id);
if (error >= 0) {
pci_dev->driver = drv;
error = 0;
}
}
return error;
} }
static int pci_device_remove(struct device * dev) static int pci_device_remove(struct device * dev)
{ {
struct pci_dev * pci_dev = list_entry(dev,struct pci_dev,dev); struct pci_dev * pci_dev = list_entry(dev,struct pci_dev,dev);
struct pci_driver * drv = pci_dev->driver;
if (dev->driver) { if (drv) {
struct pci_driver * drv = list_entry(dev->driver,struct pci_driver,driver);
if (drv->remove) if (drv->remove)
drv->remove(pci_dev); drv->remove(pci_dev);
pci_dev->driver = NULL;
} }
return 0; return 0;
} }
...@@ -124,7 +136,7 @@ pci_register_driver(struct pci_driver *drv) ...@@ -124,7 +136,7 @@ pci_register_driver(struct pci_driver *drv)
void void
pci_unregister_driver(struct pci_driver *drv) pci_unregister_driver(struct pci_driver *drv)
{ {
put_driver(&drv->driver); remove_driver(&drv->driver);
} }
static struct pci_driver pci_compat_driver = { static struct pci_driver pci_compat_driver = {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment