Thread (42 messages) 42 messages, 8 authors, 2017-09-12
STALE3206d

[PATCH 4/9] PM / ACPI: Split code validating need for runtime resume in ->prepare()

From: rafael@kernel.org (Rafael J. Wysocki)
Date: 2017-06-21 21:35:14
Also in: linux-acpi, linux-i2c, linux-pm

On Wed, Jun 21, 2017 at 9:21 PM, Ulf Hansson [off-list ref] wrote:
quoted hunk ↗ jump to hunk
Move the code dealing with validation of whether runtime resuming the
device is needed during system suspend.

In this way it becomes more clear for what circumstances ACPI is prevented
from trying the direct_complete path.

Signed-off-by: Ulf Hansson <redacted>
---
 drivers/acpi/device_pm.c | 37 ++++++++++++++++++++++++-------------
 1 file changed, 24 insertions(+), 13 deletions(-)
diff --git a/drivers/acpi/device_pm.c b/drivers/acpi/device_pm.c
index d38acbc..ee51e75 100644
--- a/drivers/acpi/device_pm.c
+++ b/drivers/acpi/device_pm.c
@@ -933,6 +933,27 @@ int acpi_dev_resume_early(struct device *dev)
 }
 EXPORT_SYMBOL_GPL(acpi_dev_resume_early);

+static bool acpi_dev_needs_resume(struct device *dev, struct acpi_device *adev)
+{
+       u32 sys_target = acpi_target_system_state();
+       int ret, state;
+
+       if (device_may_wakeup(dev) != !!adev->wakeup.prepare_count)
+               return true;
+
+       if (sys_target == ACPI_STATE_S0)
+               return false;
+
+       if (adev->power.flags.dsw_present)
+               return true;
+
+       ret = acpi_dev_pm_get_state(dev, adev, sys_target, NULL, &state);
+       if (ret)
+               return true;
+
+       return !(state == adev->power.state);
Nit: I would write this as

  return state != adev->power.state;

Thanks,
Rafael
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help