]> git.hungrycats.org Git - linux/commitdiff
[PATCH] I2C: i2c bus power management support
authorGerd Knorr <kraxel@bytesex.org>
Tue, 19 Oct 2004 09:19:10 +0000 (02:19 -0700)
committerGreg Kroah-Hartman <greg@kroah.com>
Tue, 19 Oct 2004 09:19:10 +0000 (02:19 -0700)
The patch below adds power management support to the i2c bus.
It adds just two small functions which call down to the devices
power management functions if they are present, so the i2c device
drivers will receive the suspend and resume events.

From: Gerd Knorr <kraxel@bytesex.org>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Greg Kroah-Hartman <greg@kroah.com>
drivers/i2c/i2c-core.c

index 2583ecaa95a1762a5bef519bc004f14f118d1cfc..1f67737cab726f2ee67a841872fa9294ae580a2e 100644 (file)
@@ -517,9 +517,29 @@ static int i2c_device_match(struct device *dev, struct device_driver *drv)
        return 1;
 }
 
+static int i2c_bus_suspend(struct device * dev, u32 state)
+{
+       int rc = 0;
+
+       if (dev->driver && dev->driver->suspend)
+               rc = dev->driver->suspend(dev,state,0);
+       return rc;
+}
+
+static int i2c_bus_resume(struct device * dev)
+{
+       int rc = 0;
+       
+       if (dev->driver && dev->driver->resume)
+               rc = dev->driver->resume(dev,0);
+       return rc;
+}
+
 struct bus_type i2c_bus_type = {
        .name =         "i2c",
        .match =        i2c_device_match,
+       .suspend =      i2c_bus_suspend,
+       .resume =       i2c_bus_resume,
 };
 
 static int __init i2c_init(void)