diff mbox

regulator: core: Fix s2idle

Message ID 1517308346-25299-1-git-send-email-geert+renesas@glider.be (mailing list archive)
State Not Applicable, archived
Headers show

Commit Message

Geert Uytterhoeven Jan. 30, 2018, 10:32 a.m. UTC
Systems using regulators can no longer be frozen:

$ echo 0 > /sys/module/printk/parameters/console_suspend
$ echo freeze > /sys/power/state

    PM: suspend entry (s2idle)
    PM: Syncing filesystems ... done.
    Freezing user space processes ... (elapsed 0.011 seconds) done.
    OOM killer disabled.
    Freezing remaining freezable tasks ... (elapsed 0.009 seconds) done.
    dpm_run_callback(): regulator_suspend_late+0x0/0x44 returns -22
    PM: Device regulator.7 failed to suspend late: error -22
    PM: late suspend of devices failed

Fix this by adding the missing case for s2idle.  Treat s2idle the same
as standby, as there are no separate constraints defined for s2idle.

Fixes: f7efad10b5c49289 ("regulator: add PM suspend and resume hooks")
Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be>
---
regulator_check_states() also considers PM_SUSPEND_TO_IDLE an invalid
state:

    /* return 0 if the state is valid */
    static int regulator_check_states(suspend_state_t state)
    {
	    return (state > PM_SUSPEND_MAX || state == PM_SUSPEND_TO_IDLE);
    }

But I have no idea what impact it has.  So far it doesn't seem to hurt,
though.

 drivers/regulator/core.c | 1 +
 1 file changed, 1 insertion(+)
diff mbox

Patch

diff --git a/drivers/regulator/core.c b/drivers/regulator/core.c
index 42681c10cbe4fa9f..5f411b0cca9aa838 100644
--- a/drivers/regulator/core.c
+++ b/drivers/regulator/core.c
@@ -333,6 +333,7 @@  regulator_get_suspend_state(struct regulator_dev *rdev, suspend_state_t state)
 		return NULL;
 
 	switch (state) {
+	case PM_SUSPEND_TO_IDLE:
 	case PM_SUSPEND_STANDBY:
 		return &rdev->constraints->state_standby;
 	case PM_SUSPEND_MEM: