Commit 639291f263c14dd20938dca296ab04b535cafd37

Authored by Shuah Khan
Committed by Benjamin Herrenschmidt
1 parent 3c8464a9b1

macintosh/adb: Change platform power management to use dev_pm_ops

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>

Showing 1 changed file with 36 additions and 5 deletions Side-by-side Diff

drivers/macintosh/adb.c
... ... @@ -262,7 +262,7 @@
262 262 /*
263 263 * notify clients before sleep
264 264 */
265   -static int adb_suspend(struct platform_device *dev, pm_message_t state)
  265 +static int __adb_suspend(struct platform_device *dev, pm_message_t state)
266 266 {
267 267 adb_got_sleep = 1;
268 268 /* We need to get a lock on the probe thread */
269 269  
... ... @@ -275,10 +275,25 @@
275 275 return 0;
276 276 }
277 277  
  278 +static int adb_suspend(struct device *dev)
  279 +{
  280 + return __adb_suspend(to_platform_device(dev), PMSG_SUSPEND);
  281 +}
  282 +
  283 +static int adb_freeze(struct device *dev)
  284 +{
  285 + return __adb_suspend(to_platform_device(dev), PMSG_FREEZE);
  286 +}
  287 +
  288 +static int adb_poweroff(struct device *dev)
  289 +{
  290 + return __adb_suspend(to_platform_device(dev), PMSG_HIBERNATE);
  291 +}
  292 +
278 293 /*
279 294 * reset bus after sleep
280 295 */
281   -static int adb_resume(struct platform_device *dev)
  296 +static int __adb_resume(struct platform_device *dev)
282 297 {
283 298 adb_got_sleep = 0;
284 299 up(&adb_probe_mutex);
... ... @@ -286,6 +301,11 @@
286 301  
287 302 return 0;
288 303 }
  304 +
  305 +static int adb_resume(struct device *dev)
  306 +{
  307 + return __adb_resume(to_platform_device(dev));
  308 +}
289 309 #endif /* CONFIG_PM */
290 310  
291 311 static int __init adb_init(void)
292 312  
293 313  
294 314  
... ... @@ -829,14 +849,25 @@
829 849 .release = adb_release,
830 850 };
831 851  
  852 +#ifdef CONFIG_PM
  853 +static const struct dev_pm_ops adb_dev_pm_ops = {
  854 + .suspend = adb_suspend,
  855 + .resume = adb_resume,
  856 + /* Hibernate hooks */
  857 + .freeze = adb_freeze,
  858 + .thaw = adb_resume,
  859 + .poweroff = adb_poweroff,
  860 + .restore = adb_resume,
  861 +};
  862 +#endif
  863 +
832 864 static struct platform_driver adb_pfdrv = {
833 865 .driver = {
834 866 .name = "adb",
835   - },
836 867 #ifdef CONFIG_PM
837   - .suspend = adb_suspend,
838   - .resume = adb_resume,
  868 + .pm = &adb_dev_pm_ops,
839 869 #endif
  870 + },
840 871 };
841 872  
842 873 static struct platform_device adb_pfdev = {