diff options
author | Rafael J. Wysocki <rafael.j.wysocki@intel.com> | 2020-03-29 16:11:18 +0200 |
---|---|---|
committer | Rafael J. Wysocki <rafael.j.wysocki@intel.com> | 2020-04-01 11:38:49 +0200 |
commit | b5252a6cbbdaefb2648abe8807beda8a28ec7603 (patch) | |
tree | 15d9a5b183e146696dc2ca542b00e918cdd30edb /drivers | |
parent | PM: hibernate: Propagate the return value of hibernation_restore() (diff) | |
download | linux-b5252a6cbbdaefb2648abe8807beda8a28ec7603.tar.xz linux-b5252a6cbbdaefb2648abe8807beda8a28ec7603.zip |
PM: sleep: core: Drop racy and redundant checks from device_prepare()
Alan Stern points out that the WARN_ON() check in device_prepare()
is racy (because the PM-runtime API can be disabled briefly for any
device at any time and system suspend can start at any time too) and
the pm_runtime_suspended() check in the computation of the
direct_complete flag value is redundant (because it will be
repeated later anyway).
Drop both these checks accordingly.
Reported-by: Alan Stern <stern@rowland.harvard.edu>
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Diffstat (limited to 'drivers')
-rw-r--r-- | drivers/base/power/main.c | 7 |
1 files changed, 1 insertions, 6 deletions
diff --git a/drivers/base/power/main.c b/drivers/base/power/main.c index 6d1dee7051eb..fdd508a78ffd 100644 --- a/drivers/base/power/main.c +++ b/drivers/base/power/main.c @@ -1922,10 +1922,6 @@ static int device_prepare(struct device *dev, pm_message_t state) if (dev->power.syscore) return 0; - WARN_ON(!pm_runtime_enabled(dev) && - dev_pm_test_driver_flags(dev, DPM_FLAG_SMART_SUSPEND | - DPM_FLAG_LEAVE_SUSPENDED)); - /* * If a device's parent goes into runtime suspend at the wrong time, * it won't be possible to resume the device. To prevent this we @@ -1973,8 +1969,7 @@ unlock: */ spin_lock_irq(&dev->power.lock); dev->power.direct_complete = state.event == PM_EVENT_SUSPEND && - ((pm_runtime_suspended(dev) && ret > 0) || - dev->power.no_pm_callbacks) && + (ret > 0 || dev->power.no_pm_callbacks) && !dev_pm_test_driver_flags(dev, DPM_FLAG_NEVER_SKIP); spin_unlock_irq(&dev->power.lock); return 0; |