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)
static int pci_device_probe(struct device * dev)
{
int error = 0;
struct pci_driver *drv;
struct pci_dev *pci_dev;
struct pci_driver * drv = list_entry(dev->driver,struct pci_driver,driver);
struct pci_dev * pci_dev = list_entry(dev,struct pci_dev,dev);
drv = list_entry(dev->driver, struct pci_driver, driver);
pci_dev = list_entry(dev, struct pci_dev, dev);
if (drv->probe) {
const struct pci_device_id *id;
if (drv->probe)
error = drv->probe(pci_dev,drv->id_table);
return error > 0 ? 0 : -ENODEV;
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)
{
struct pci_dev * pci_dev = list_entry(dev,struct pci_dev,dev);
struct pci_driver * drv = pci_dev->driver;
if (dev->driver) {
struct pci_driver * drv = list_entry(dev->driver,struct pci_driver,driver);
if (drv) {
if (drv->remove)
drv->remove(pci_dev);
pci_dev->driver = NULL;
}
return 0;
}
......@@ -124,7 +136,7 @@ pci_register_driver(struct pci_driver *drv)
void
pci_unregister_driver(struct pci_driver *drv)
{
put_driver(&drv->driver);
remove_driver(&drv->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