macintosh/adb: Change platform power management to use dev_pm_ops
authorShuah Khan <shuah.kh@samsung.com>
Mon, 10 Feb 2014 16:12:27 +0000 (09:12 -0700)
committerBenjamin Herrenschmidt <benh@kernel.crashing.org>
Fri, 7 Mar 2014 04:54:48 +0000 (15:54 +1100)
Change adb platform driver to register pm ops using dev_pm_ops instead of
legacy pm_ops. .pm hooks call existing legacy suspend and resume interfaces
by passing in the right pm state.

Signed-off-by: Shuah Khan <shuah.kh@samsung.com>
Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
drivers/macintosh/adb.c

index 53611de7a4574b174e9cb25401283701a6125ae5..9e9c56758a0897ab5c7e7b0dfc14ac690e1bb043 100644 (file)
@@ -262,7 +262,7 @@ adb_reset_bus(void)
 /*
  * notify clients before sleep
  */
-static int adb_suspend(struct platform_device *dev, pm_message_t state)
+static int __adb_suspend(struct platform_device *dev, pm_message_t state)
 {
        adb_got_sleep = 1;
        /* We need to get a lock on the probe thread */
@@ -275,10 +275,25 @@ static int adb_suspend(struct platform_device *dev, pm_message_t state)
        return 0;
 }
 
+static int adb_suspend(struct device *dev)
+{
+       return __adb_suspend(to_platform_device(dev), PMSG_SUSPEND);
+}
+
+static int adb_freeze(struct device *dev)
+{
+       return __adb_suspend(to_platform_device(dev), PMSG_FREEZE);
+}
+
+static int adb_poweroff(struct device *dev)
+{
+       return __adb_suspend(to_platform_device(dev), PMSG_HIBERNATE);
+}
+
 /*
  * reset bus after sleep
  */
-static int adb_resume(struct platform_device *dev)
+static int __adb_resume(struct platform_device *dev)
 {
        adb_got_sleep = 0;
        up(&adb_probe_mutex);
@@ -286,6 +301,11 @@ static int adb_resume(struct platform_device *dev)
 
        return 0;
 }
+
+static int adb_resume(struct device *dev)
+{
+       return __adb_resume(to_platform_device(dev));
+}
 #endif /* CONFIG_PM */
 
 static int __init adb_init(void)
@@ -829,14 +849,25 @@ static const struct file_operations adb_fops = {
        .release        = adb_release,
 };
 
+#ifdef CONFIG_PM
+static const struct dev_pm_ops adb_dev_pm_ops = {
+       .suspend = adb_suspend,
+       .resume = adb_resume,
+       /* Hibernate hooks */
+       .freeze = adb_freeze,
+       .thaw = adb_resume,
+       .poweroff = adb_poweroff,
+       .restore = adb_resume,
+};
+#endif
+
 static struct platform_driver adb_pfdrv = {
        .driver = {
                .name = "adb",
-       },
 #ifdef CONFIG_PM
-       .suspend = adb_suspend,
-       .resume = adb_resume,
+               .pm = &adb_dev_pm_ops,
 #endif
+       },
 };
 
 static struct platform_device adb_pfdev = {