diff options
author | Magnus Damm <damm@igel.co.jp> | 2009-06-04 16:13:33 -0400 |
---|---|---|
committer | Rafael J. Wysocki <rjw@sisk.pl> | 2009-06-12 15:32:32 -0400 |
commit | 783ea7d4eeefe895f2731fe73ac951e94418927b (patch) | |
tree | 175b7ec1684d55710a7a921d4bd81e549ae4ed52 /drivers/base/platform.c | |
parent | 00725787511e20dbd1fdc1fb233606120ae5c8cf (diff) |
Driver Core: Rework platform suspend/resume, print warning
This patch reworks the platform driver code for legacy
suspend and resume to avoid installing callbacks in
struct device_driver. A warning is also added telling
users to update the platform driver to use dev_pm_ops.
The functions platform_legacy_suspend()/resume() directly
call suspend and resume callbacks in struct platform_driver
instead of wrapping things in platform_drv_suspend()/resume().
Signed-off-by: Magnus Damm <damm@igel.co.jp>
Acked-by: Greg Kroah-Hartman <gregkh@suse.de>
Signed-off-by: Rafael J. Wysocki <rjw@sisk.pl>
Diffstat (limited to 'drivers/base/platform.c')
-rw-r--r-- | drivers/base/platform.c | 36 |
1 files changed, 12 insertions, 24 deletions
diff --git a/drivers/base/platform.c b/drivers/base/platform.c index 8b4708e06244..ead3f64c41d0 100644 --- a/drivers/base/platform.c +++ b/drivers/base/platform.c | |||
@@ -469,22 +469,6 @@ static void platform_drv_shutdown(struct device *_dev) | |||
469 | drv->shutdown(dev); | 469 | drv->shutdown(dev); |
470 | } | 470 | } |
471 | 471 | ||
472 | static int platform_drv_suspend(struct device *_dev, pm_message_t state) | ||
473 | { | ||
474 | struct platform_driver *drv = to_platform_driver(_dev->driver); | ||
475 | struct platform_device *dev = to_platform_device(_dev); | ||
476 | |||
477 | return drv->suspend(dev, state); | ||
478 | } | ||
479 | |||
480 | static int platform_drv_resume(struct device *_dev) | ||
481 | { | ||
482 | struct platform_driver *drv = to_platform_driver(_dev->driver); | ||
483 | struct platform_device *dev = to_platform_device(_dev); | ||
484 | |||
485 | return drv->resume(dev); | ||
486 | } | ||
487 | |||
488 | /** | 472 | /** |
489 | * platform_driver_register | 473 | * platform_driver_register |
490 | * @drv: platform driver structure | 474 | * @drv: platform driver structure |
@@ -498,10 +482,10 @@ int platform_driver_register(struct platform_driver *drv) | |||
498 | drv->driver.remove = platform_drv_remove; | 482 | drv->driver.remove = platform_drv_remove; |
499 | if (drv->shutdown) | 483 | if (drv->shutdown) |
500 | drv->driver.shutdown = platform_drv_shutdown; | 484 | drv->driver.shutdown = platform_drv_shutdown; |
501 | if (drv->suspend) | 485 | if (drv->suspend || drv->resume) |
502 | drv->driver.suspend = platform_drv_suspend; | 486 | pr_warning("Platform driver '%s' needs updating - please use " |
503 | if (drv->resume) | 487 | "dev_pm_ops\n", drv->driver.name); |
504 | drv->driver.resume = platform_drv_resume; | 488 | |
505 | return driver_register(&drv->driver); | 489 | return driver_register(&drv->driver); |
506 | } | 490 | } |
507 | EXPORT_SYMBOL_GPL(platform_driver_register); | 491 | EXPORT_SYMBOL_GPL(platform_driver_register); |
@@ -633,10 +617,12 @@ static int platform_match(struct device *dev, struct device_driver *drv) | |||
633 | 617 | ||
634 | static int platform_legacy_suspend(struct device *dev, pm_message_t mesg) | 618 | static int platform_legacy_suspend(struct device *dev, pm_message_t mesg) |
635 | { | 619 | { |
620 | struct platform_driver *pdrv = to_platform_driver(dev->driver); | ||
621 | struct platform_device *pdev = to_platform_device(dev); | ||
636 | int ret = 0; | 622 | int ret = 0; |
637 | 623 | ||
638 | if (dev->driver && dev->driver->suspend) | 624 | if (dev->driver && pdrv->suspend) |
639 | ret = dev->driver->suspend(dev, mesg); | 625 | ret = pdrv->suspend(pdev, mesg); |
640 | 626 | ||
641 | return ret; | 627 | return ret; |
642 | } | 628 | } |
@@ -667,10 +653,12 @@ static int platform_legacy_resume_early(struct device *dev) | |||
667 | 653 | ||
668 | static int platform_legacy_resume(struct device *dev) | 654 | static int platform_legacy_resume(struct device *dev) |
669 | { | 655 | { |
656 | struct platform_driver *pdrv = to_platform_driver(dev->driver); | ||
657 | struct platform_device *pdev = to_platform_device(dev); | ||
670 | int ret = 0; | 658 | int ret = 0; |
671 | 659 | ||
672 | if (dev->driver && dev->driver->resume) | 660 | if (dev->driver && pdrv->resume) |
673 | ret = dev->driver->resume(dev); | 661 | ret = pdrv->resume(pdev); |
674 | 662 | ||
675 | return ret; | 663 | return ret; |
676 | } | 664 | } |