Commit 783ea7d4 authored by Magnus Damm's avatar Magnus Damm Committed by Rafael J. Wysocki

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: default avatarMagnus Damm <damm@igel.co.jp>
Acked-by: default avatarGreg Kroah-Hartman <gregkh@suse.de>
Signed-off-by: default avatarRafael J. Wysocki <rjw@sisk.pl>
parent 00725787
...@@ -469,22 +469,6 @@ static void platform_drv_shutdown(struct device *_dev) ...@@ -469,22 +469,6 @@ static void platform_drv_shutdown(struct device *_dev)
drv->shutdown(dev); drv->shutdown(dev);
} }
static int platform_drv_suspend(struct device *_dev, pm_message_t state)
{
struct platform_driver *drv = to_platform_driver(_dev->driver);
struct platform_device *dev = to_platform_device(_dev);
return drv->suspend(dev, state);
}
static int platform_drv_resume(struct device *_dev)
{
struct platform_driver *drv = to_platform_driver(_dev->driver);
struct platform_device *dev = to_platform_device(_dev);
return drv->resume(dev);
}
/** /**
* platform_driver_register * platform_driver_register
* @drv: platform driver structure * @drv: platform driver structure
...@@ -498,10 +482,10 @@ int platform_driver_register(struct platform_driver *drv) ...@@ -498,10 +482,10 @@ int platform_driver_register(struct platform_driver *drv)
drv->driver.remove = platform_drv_remove; drv->driver.remove = platform_drv_remove;
if (drv->shutdown) if (drv->shutdown)
drv->driver.shutdown = platform_drv_shutdown; drv->driver.shutdown = platform_drv_shutdown;
if (drv->suspend) if (drv->suspend || drv->resume)
drv->driver.suspend = platform_drv_suspend; pr_warning("Platform driver '%s' needs updating - please use "
if (drv->resume) "dev_pm_ops\n", drv->driver.name);
drv->driver.resume = platform_drv_resume;
return driver_register(&drv->driver); return driver_register(&drv->driver);
} }
EXPORT_SYMBOL_GPL(platform_driver_register); EXPORT_SYMBOL_GPL(platform_driver_register);
...@@ -633,10 +617,12 @@ static int platform_match(struct device *dev, struct device_driver *drv) ...@@ -633,10 +617,12 @@ static int platform_match(struct device *dev, struct device_driver *drv)
static int platform_legacy_suspend(struct device *dev, pm_message_t mesg) static int platform_legacy_suspend(struct device *dev, pm_message_t mesg)
{ {
struct platform_driver *pdrv = to_platform_driver(dev->driver);
struct platform_device *pdev = to_platform_device(dev);
int ret = 0; int ret = 0;
if (dev->driver && dev->driver->suspend) if (dev->driver && pdrv->suspend)
ret = dev->driver->suspend(dev, mesg); ret = pdrv->suspend(pdev, mesg);
return ret; return ret;
} }
...@@ -667,10 +653,12 @@ static int platform_legacy_resume_early(struct device *dev) ...@@ -667,10 +653,12 @@ static int platform_legacy_resume_early(struct device *dev)
static int platform_legacy_resume(struct device *dev) static int platform_legacy_resume(struct device *dev)
{ {
struct platform_driver *pdrv = to_platform_driver(dev->driver);
struct platform_device *pdev = to_platform_device(dev);
int ret = 0; int ret = 0;
if (dev->driver && dev->driver->resume) if (dev->driver && pdrv->resume)
ret = dev->driver->resume(dev); ret = pdrv->resume(pdev);
return ret; return ret;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment