Skip to content

Commit b5252a6

Browse files
committed
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 <[email protected]> Signed-off-by: Rafael J. Wysocki <[email protected]>
1 parent 3704a6a commit b5252a6

File tree

1 file changed

+1
-6
lines changed

1 file changed

+1
-6
lines changed

drivers/base/power/main.c

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1922,10 +1922,6 @@ static int device_prepare(struct device *dev, pm_message_t state)
19221922
if (dev->power.syscore)
19231923
return 0;
19241924

1925-
WARN_ON(!pm_runtime_enabled(dev) &&
1926-
dev_pm_test_driver_flags(dev, DPM_FLAG_SMART_SUSPEND |
1927-
DPM_FLAG_LEAVE_SUSPENDED));
1928-
19291925
/*
19301926
* If a device's parent goes into runtime suspend at the wrong time,
19311927
* it won't be possible to resume the device. To prevent this we
@@ -1973,8 +1969,7 @@ static int device_prepare(struct device *dev, pm_message_t state)
19731969
*/
19741970
spin_lock_irq(&dev->power.lock);
19751971
dev->power.direct_complete = state.event == PM_EVENT_SUSPEND &&
1976-
((pm_runtime_suspended(dev) && ret > 0) ||
1977-
dev->power.no_pm_callbacks) &&
1972+
(ret > 0 || dev->power.no_pm_callbacks) &&
19781973
!dev_pm_test_driver_flags(dev, DPM_FLAG_NEVER_SKIP);
19791974
spin_unlock_irq(&dev->power.lock);
19801975
return 0;

0 commit comments

Comments
 (0)