PM: sleep: core: Simplify the SMART_SUSPEND flag handling
authorRafael J. Wysocki <rafael.j.wysocki@intel.com>
Sat, 18 Apr 2020 16:29:30 +0000 (18:29 +0200)
committerRafael J. Wysocki <rafael.j.wysocki@intel.com>
Mon, 20 Apr 2020 08:32:15 +0000 (10:32 +0200)
commit107d47b2b95ef478d71f3bf36201886d7475427a
treeecd20ea7a19f73977a0c4b513939ecf34cf95c05
parentae83d0b416db002fe95601e7f97f64b59514d936
PM: sleep: core: Simplify the SMART_SUSPEND flag handling

The code to handle the SMART_SUSPEND driver PM flag is hard to follow
and somewhat inconsistent with respect to devices without middle-layer
(subsystem) callbacks.

Namely, for those devices the core takes the role of a middle layer
in providing the expected ordering of execution of callbacks (under
the assumption that the drivers setting SMART_SUSPEND can reuse their
PM-runtime callbacks directly for system-wide suspend).  To that end,
it prevents driver ->suspend_late and ->suspend_noirq callbacks from
being executed for devices that are still runtime-suspended in
__device_suspend_late(), because running the same callback funtion
that was previously run by PM-runtime for them may be invalid.

However, it does that only for devices without any middle-layer
callbacks for the late/noirq/early suspend/resume phases even
though it would be simpler and more consistent to skip the
driver-lavel callbacks for all devices with SMART_SUSPEND set
that are runtime-suspended in __device_suspend_late().

Simplify the code in accordance with the above observation.

Suggested-by: Alan Stern <stern@rowland.harvard.edu>
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Acked-by: Alan Stern <stern@rowland.harvard.edu>
drivers/base/power/main.c