Commit 222192df authored by Patrick Mochel's avatar Patrick Mochel

[power] Update PCI to set PM methods in bus_type

Instead of setting them manually in each driver, as they are registered. 
parent 85dab9cd
...@@ -160,32 +160,23 @@ static int pci_device_remove(struct device * dev) ...@@ -160,32 +160,23 @@ static int pci_device_remove(struct device * dev)
return 0; return 0;
} }
static int pci_device_suspend(struct device * dev, u32 state, u32 level) static int pci_device_suspend(struct device * dev, u32 state)
{ {
struct pci_dev * pci_dev = to_pci_dev(dev); struct pci_dev * pci_dev = to_pci_dev(dev);
int error = 0; struct pci_driver * drv = pci_dev->driver;
if (pci_dev->driver) { if (drv && drv->suspend)
if (level == SUSPEND_SAVE_STATE && pci_dev->driver->save_state) return drv->suspend(pci_dev,state);
error = pci_dev->driver->save_state(pci_dev,state); return 0;
else if (level == SUSPEND_POWER_DOWN && pci_dev->driver->suspend)
error = pci_dev->driver->suspend(pci_dev,state);
}
return error;
} }
static int pci_device_resume(struct device * dev, u32 level) static int pci_device_resume(struct device * dev)
{ {
struct pci_dev * pci_dev = to_pci_dev(dev); struct pci_dev * pci_dev = to_pci_dev(dev);
struct pci_driver * drv = pci_dev->driver;
if (pci_dev->driver) { if (drv && drv->resume)
/* We may not call PCI drivers resume at drv->resume(pci_dev);
RESUME_POWER_ON because interrupts are not yet
working at that point. Calling resume at
RESUME_RESTORE_STATE seems like solution. */
if (level == RESUME_RESTORE_STATE && pci_dev->driver->resume)
pci_dev->driver->resume(pci_dev);
}
return 0; return 0;
} }
...@@ -351,8 +342,6 @@ pci_register_driver(struct pci_driver *drv) ...@@ -351,8 +342,6 @@ pci_register_driver(struct pci_driver *drv)
drv->driver.name = drv->name; drv->driver.name = drv->name;
drv->driver.bus = &pci_bus_type; drv->driver.bus = &pci_bus_type;
drv->driver.probe = pci_device_probe; drv->driver.probe = pci_device_probe;
drv->driver.resume = pci_device_resume;
drv->driver.suspend = pci_device_suspend;
drv->driver.remove = pci_device_remove; drv->driver.remove = pci_device_remove;
drv->driver.kobj.ktype = &pci_driver_kobj_type; drv->driver.kobj.ktype = &pci_driver_kobj_type;
pci_init_dynids(&drv->dynids); pci_init_dynids(&drv->dynids);
...@@ -498,6 +487,8 @@ struct bus_type pci_bus_type = { ...@@ -498,6 +487,8 @@ struct bus_type pci_bus_type = {
.name = "pci", .name = "pci",
.match = pci_bus_match, .match = pci_bus_match,
.hotplug = pci_hotplug, .hotplug = pci_hotplug,
.suspend = pci_device_suspend,
.resume = pci_device_resume,
}; };
static int __init pci_driver_init(void) static int __init pci_driver_init(void)
......
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