diff mbox series

[v2,4/4] PM: suspend: Simplify state check using sleep_state_supported()

Message ID 20250619035355.33402-5-zhangzihuan@kylinos.cn
State New
Headers show
Series PM: freezer: Add retry stats and D-state task logging for debugging | expand

Commit Message

Zihuan Zhang June 19, 2025, 3:53 a.m. UTC
Currently enter_state() open-codes state validation using
`if (state == PM_SUSPEND_TO_IDLE) ... else if (!valid_state(state)) ...`.

This can be simplified by calling sleep_state_supported(), which already
encodes this logic. This improves clarity and reduces duplication.

Signed-off-by: Zihuan Zhang <zhangzihuan@kylinos.cn>
---
 kernel/power/suspend.c | 14 ++++----------
 1 file changed, 4 insertions(+), 10 deletions(-)
diff mbox series

Patch

diff --git a/kernel/power/suspend.c b/kernel/power/suspend.c
index 16172ca22f21..b95c7a80ef20 100644
--- a/kernel/power/suspend.c
+++ b/kernel/power/suspend.c
@@ -571,16 +571,10 @@  static int enter_state(suspend_state_t state)
 	int error;
 
 	trace_suspend_resume(TPS("suspend_enter"), state, true);
-	if (state == PM_SUSPEND_TO_IDLE) {
-#ifdef CONFIG_PM_DEBUG
-		if (pm_test_level != TEST_NONE && pm_test_level <= TEST_CPUS) {
-			pr_warn("Unsupported test mode for suspend to idle, please choose none/freezer/devices/platform.\n");
-			return -EAGAIN;
-		}
-#endif
-	} else if (!valid_state(state)) {
-		return -EINVAL;
-	}
+
+	if (!sleep_state_supported(state))
+		return -ENOSYS;
+
 	if (!mutex_trylock(&system_transition_mutex))
 		return -EBUSY;