]> git.hungrycats.org Git - linux/commitdiff
[power] Move suspend()/resume() methods.
authorPatrick Mochel <mochel@osdl.org>
Tue, 19 Aug 2003 16:36:46 +0000 (09:36 -0700)
committerPatrick Mochel <mochel@osdl.org>
Tue, 19 Aug 2003 16:36:46 +0000 (09:36 -0700)
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.

drivers/base/power/resume.c
drivers/base/power/suspend.c
include/linux/device.h
kernel/power/main.c

index a34f66a1b42c1b9298201eef41d18f5e326c310f..a022a0cdedd5d9cf9a2b06c7cc4cb6ab452e520f 100644 (file)
@@ -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);
        }
 }
index 8e5842521d4d2c9e44b5c164cb0e9def783c6ef0..5e154218801ee9ed57caa91de271682925ca4b2f 100644 (file)
@@ -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.
index c99ad50c67848dd339dcaef46ae2cdbced75fc2e..8d6266f2e3c3e2c54bf329a9bfc14fc7e287df3a 100644 (file)
@@ -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);
index 4d1476ba8156eed3ed465f8879f5ff306b5e52ce..422d5131fbf6848bf0302087ee0733e5fa2e7f22 100644 (file)
@@ -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);