Skip to content

Commit

Permalink
PM / runtime: Allow no callbacks in pm_runtime_force_suspend|resume()
Browse files Browse the repository at this point in the history
The pm_runtime_force_suspend|resume() helpers currently requires the device
to at some level (PM domain, bus, etc), have the ->runtime_suspend|resume()
callbacks assigned for it, else -ENOSYS is returned as an error.

However, there are no reason for this requirement, so let's simply remove
it by allowing these callbacks to be NULL.

Signed-off-by: Ulf Hansson <[email protected]>
Signed-off-by: Rafael J. Wysocki <[email protected]>
  • Loading branch information
storulf authored and rafaeljw committed Jan 17, 2018
1 parent 1f5c685 commit 617fcb6
Showing 1 changed file with 3 additions and 8 deletions.
11 changes: 3 additions & 8 deletions drivers/base/power/runtime.c
Original file line number Diff line number Diff line change
Expand Up @@ -1640,20 +1640,15 @@ static bool pm_runtime_need_not_resume(struct device *dev)
int pm_runtime_force_suspend(struct device *dev)
{
int (*callback)(struct device *);
int ret = 0;
int ret;

pm_runtime_disable(dev);
if (pm_runtime_status_suspended(dev))
return 0;

callback = RPM_GET_CALLBACK(dev, runtime_suspend);

if (!callback) {
ret = -ENOSYS;
goto err;
}

ret = callback(dev);
ret = callback ? callback(dev) : 0;
if (ret)
goto err;

Expand Down Expand Up @@ -1704,7 +1699,7 @@ int pm_runtime_force_resume(struct device *dev)

callback = RPM_GET_CALLBACK(dev, runtime_resume);

ret = callback ? callback(dev) : -ENOSYS;
ret = callback ? callback(dev) : 0;
if (ret) {
pm_runtime_set_suspended(dev);
goto out;
Expand Down

0 comments on commit 617fcb6

Please sign in to comment.