[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-Id: <20250619035355.33402-5-zhangzihuan@kylinos.cn>
Date: Thu, 19 Jun 2025 11:53:55 +0800
From: Zihuan Zhang <zhangzihuan@...inos.cn>
To: rafael@...nel.org,
pavel@...nel.org,
len.brown@...el.com
Cc: linux-pm@...r.kernel.org,
linux-kernel@...r.kernel.org,
Zihuan Zhang <zhangzihuan@...inos.cn>
Subject: [PATCH v2 4/4] PM: suspend: Simplify state check using sleep_state_supported()
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@...inos.cn>
---
kernel/power/suspend.c | 14 ++++----------
1 file changed, 4 insertions(+), 10 deletions(-)
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;
--
2.25.1
Powered by blists - more mailing lists