Commit 0d045e1f authored by Patrick Mochel's avatar Patrick Mochel

[power] Move suspend()/resume() methods.

Instead of putting them in struct device_driver (which few, if any drivers
use directly), put them in the controlling bus_type of the device (which
are currently responsible for claiming the methods and forwarding the calls
to the bus-specific driver anyway).

This will save 8 bytes per driver instance, which isn't that much, but it's
something. It also makes it more obvious to the reader what is going on. 
And, it makes for easier bus-level defaults in the case the device has no
driver attached. 

The old calls remain until all instances have been fixed up.
parent 54050a4e
......@@ -22,10 +22,8 @@ extern int sysdev_resume(void);
int resume_device(struct device * dev)
{
struct device_driver * drv = dev->driver;
if (drv && drv->resume)
return drv->resume(dev,RESUME_RESTORE_STATE);
if (dev->bus && dev->bus->resume)
return dev->bus->resume(dev);
return 0;
}
......@@ -49,19 +47,6 @@ void device_pm_resume(void)
}
/**
* power_up_device - Power one device on.
* @dev: Device.
*/
void power_up_device(struct device * dev)
{
struct device_driver * drv = dev->driver;
if (drv && drv->resume)
drv->resume(dev,RESUME_POWER_ON);
}
/**
* device_power_up_irq - Power on some devices.
*
......@@ -78,7 +63,7 @@ void dpm_power_up(void)
while(!list_empty(&dpm_off_irq)) {
struct list_head * entry = dpm_off_irq.next;
list_del_init(entry);
power_up_device(to_device(entry));
resume_device(to_device(entry));
list_add_tail(entry,&dpm_active);
}
}
......
......@@ -37,11 +37,10 @@ extern int sysdev_suspend(u32 state);
int suspend_device(struct device * dev, u32 state)
{
struct device_driver * drv = dev->driver;
int error = 0;
if (drv && drv->suspend)
error = drv->suspend(dev,state,SUSPEND_SAVE_STATE);
if (dev->bus && dev->bus->suspend)
error = dev->bus->suspend(dev,state);
if (!error) {
list_del(&dev->power.entry);
......@@ -96,23 +95,6 @@ int device_pm_suspend(u32 state)
}
/**
* dpm_power_down - Power down devices without interrupts.
* @state: State to enter.
*
* Walk the dpm_off_irq list (built by device_pm_suspend) and power
* down each device that requires the call to be made with interrupts
* disabled.
*/
static int dpm_power_down(u32 state)
{
int error = 0;
return error;
}
/**
* device_pm_power_down - Shut down special devices.
* @state: Power state to enter.
......
......@@ -58,7 +58,8 @@ struct bus_type {
struct device * (*add) (struct device * parent, char * bus_id);
int (*hotplug) (struct device *dev, char **envp,
int num_envp, char *buffer, int buffer_size);
int (*suspend)(struct device * dev, u32 state);
int (*resume)(struct device * dev);
};
extern int bus_register(struct bus_type * bus);
......
......@@ -118,7 +118,7 @@ static int power_down(u32 mode)
int error = 0;
local_irq_save(flags);
device_pm_power_down();
device_pm_power_down(PM_SUSPEND_DISK);
switch(mode) {
case PM_DISK_PLATFORM:
error = pm_ops->enter(PM_SUSPEND_DISK);
......
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