]> pilppa.com Git - linux-2.6-omap-h63xx.git/commitdiff
tifm_core: add suspend/resume infrastructure for tifm devices
authorAlex Dubov <oakad@yahoo.com>
Sun, 10 Dec 2006 14:55:37 +0000 (01:55 +1100)
committerPierre Ossman <drzeus@drzeus.cx>
Sun, 4 Feb 2007 19:54:10 +0000 (20:54 +0100)
Signed-off-by: Alex Dubov <oakad@yahoo.com>
Signed-off-by: Pierre Ossman <drzeus@drzeus.cx>
drivers/misc/tifm_core.c
include/linux/tifm.h

index 4d62dab2ada3d1f7ba1c391f56dab90f9253d4ee..6b10ebe9d9365d89bc40d1487c24a9ed86bf91e8 100644 (file)
@@ -14,7 +14,7 @@
 #include <linux/idr.h>
 
 #define DRIVER_NAME "tifm_core"
-#define DRIVER_VERSION "0.6"
+#define DRIVER_VERSION "0.7"
 
 static DEFINE_IDR(tifm_adapter_idr);
 static DEFINE_SPINLOCK(tifm_adapter_lock);
@@ -60,10 +60,41 @@ static int tifm_uevent(struct device *dev, char **envp, int num_envp,
        return 0;
 }
 
+#ifdef CONFIG_PM
+
+static int tifm_device_suspend(struct device *dev, pm_message_t state)
+{
+       struct tifm_dev *fm_dev = container_of(dev, struct tifm_dev, dev);
+       struct tifm_driver *drv = fm_dev->drv;
+
+       if (drv && drv->suspend)
+               return drv->suspend(fm_dev, state);
+       return 0;
+}
+
+static int tifm_device_resume(struct device *dev)
+{
+       struct tifm_dev *fm_dev = container_of(dev, struct tifm_dev, dev);
+       struct tifm_driver *drv = fm_dev->drv;
+
+       if (drv && drv->resume)
+               return drv->resume(fm_dev);
+       return 0;
+}
+
+#else
+
+#define tifm_device_suspend NULL
+#define tifm_device_resume NULL
+
+#endif /* CONFIG_PM */
+
 static struct bus_type tifm_bus_type = {
        .name    = "tifm",
        .match   = tifm_match,
        .uevent  = tifm_uevent,
+       .suspend = tifm_device_suspend,
+       .resume  = tifm_device_resume
 };
 
 static void tifm_free(struct class_device *cdev)
@@ -233,6 +264,8 @@ int tifm_register_driver(struct tifm_driver *drv)
        drv->driver.bus = &tifm_bus_type;
        drv->driver.probe = tifm_device_probe;
        drv->driver.remove = tifm_device_remove;
+       drv->driver.suspend = tifm_device_suspend;
+       drv->driver.resume = tifm_device_resume;
 
        return driver_register(&drv->driver);
 }
index e5a8295f9fbc1cf24b4804720916eedf03d5fc45..3deb0a6c13708b7e6158dc52583982185a7c7003 100644 (file)
@@ -101,6 +101,9 @@ struct tifm_driver {
        tifm_media_id        *id_table;
        int                  (*probe)(struct tifm_dev *dev);
        void                 (*remove)(struct tifm_dev *dev);
+       int                  (*suspend)(struct tifm_dev *dev,
+                                        pm_message_t state);
+       int                  (*resume)(struct tifm_dev *dev);
 
        struct device_driver driver;
 };