Skip to content

Commit 783ea7d

Browse files
Magnus Dammrjwysocki
authored andcommitted
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>
1 parent 0072578 commit 783ea7d

1 file changed

Lines changed: 12 additions & 24 deletions

File tree

‎drivers/base/platform.c‎

Lines changed: 12 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -469,22 +469,6 @@ static void platform_drv_shutdown(struct device *_dev)
469469
drv->shutdown(dev);
470470
}
471471

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-
488472
/**
489473
* platform_driver_register
490474
* @drv: platform driver structure
@@ -498,10 +482,10 @@ int platform_driver_register(struct platform_driver *drv)
498482
drv->driver.remove = platform_drv_remove;
499483
if (drv->shutdown)
500484
drv->driver.shutdown = platform_drv_shutdown;
501-
if (drv->suspend)
502-
drv->driver.suspend = platform_drv_suspend;
503-
if (drv->resume)
504-
drv->driver.resume = platform_drv_resume;
485+
if (drv->suspend || drv->resume)
486+
pr_warning("Platform driver '%s' needs updating - please use "
487+
"dev_pm_ops\n", drv->driver.name);
488+
505489
return driver_register(&drv->driver);
506490
}
507491
EXPORT_SYMBOL_GPL(platform_driver_register);
@@ -633,10 +617,12 @@ static int platform_match(struct device *dev, struct device_driver *drv)
633617

634618
static int platform_legacy_suspend(struct device *dev, pm_message_t mesg)
635619
{
620+
struct platform_driver *pdrv = to_platform_driver(dev->driver);
621+
struct platform_device *pdev = to_platform_device(dev);
636622
int ret = 0;
637623

638-
if (dev->driver && dev->driver->suspend)
639-
ret = dev->driver->suspend(dev, mesg);
624+
if (dev->driver && pdrv->suspend)
625+
ret = pdrv->suspend(pdev, mesg);
640626

641627
return ret;
642628
}
@@ -667,10 +653,12 @@ static int platform_legacy_resume_early(struct device *dev)
667653

668654
static int platform_legacy_resume(struct device *dev)
669655
{
656+
struct platform_driver *pdrv = to_platform_driver(dev->driver);
657+
struct platform_device *pdev = to_platform_device(dev);
670658
int ret = 0;
671659

672-
if (dev->driver && dev->driver->resume)
673-
ret = dev->driver->resume(dev);
660+
if (dev->driver && pdrv->resume)
661+
ret = pdrv->resume(pdev);
674662

675663
return ret;
676664
}

0 commit comments

Comments
 (0)