[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20241219-hw_protection-reboot-v1-1-263a0c1df802@pengutronix.de>
Date: Thu, 19 Dec 2024 08:31:22 +0100
From: Ahmad Fatoum <a.fatoum@...gutronix.de>
To: Daniel Lezcano <daniel.lezcano@...aro.org>,
Fabio Estevam <festevam@...x.de>, "Rafael J. Wysocki" <rafael@...nel.org>,
Zhang Rui <rui.zhang@...el.com>, Lukasz Luba <lukasz.luba@....com>,
Jonathan Corbet <corbet@....net>, Serge Hallyn <serge@...lyn.com>,
Liam Girdwood <lgirdwood@...il.com>, Mark Brown <broonie@...nel.org>,
Matti Vaittinen <mazziesaccount@...il.com>,
Benson Leung <bleung@...omium.org>, Tzung-Bi Shih <tzungbi@...nel.org>,
Guenter Roeck <groeck@...omium.org>, Rob Herring <robh@...nel.org>,
Krzysztof Kozlowski <krzk+dt@...nel.org>,
Conor Dooley <conor+dt@...nel.org>
Cc: linux-kernel@...r.kernel.org, linux-pm@...r.kernel.org,
linux-doc@...r.kernel.org, linux-security-module@...r.kernel.org,
chrome-platform@...ts.linux.dev, devicetree@...r.kernel.org,
kernel@...gutronix.de, Ahmad Fatoum <a.fatoum@...gutronix.de>
Subject: [PATCH 01/11] reboot: replace __hw_protection_shutdown bool action
parameter with an enum
Currently __hw_protection_shutdown() either reboots or shuts down the
system according to its shutdown argument.
To make the logic easier to follow, both inside __hw_protection_shutdown
and at caller sites, lets replace the bool parameter with an enum.
This will be extra useful, when in a later commit, a third action is
added to the enumeration.
No functional change.
Signed-off-by: Ahmad Fatoum <a.fatoum@...gutronix.de>
---
include/linux/reboot.h | 10 +++++++---
kernel/reboot.c | 9 +++++----
2 files changed, 12 insertions(+), 7 deletions(-)
diff --git a/include/linux/reboot.h b/include/linux/reboot.h
index abcdde4df697969a8027bcb052efc00daabbbf6a..d6780fbf51535e1f98b576da0a06701402dfd447 100644
--- a/include/linux/reboot.h
+++ b/include/linux/reboot.h
@@ -177,16 +177,20 @@ void ctrl_alt_del(void);
extern void orderly_poweroff(bool force);
extern void orderly_reboot(void);
-void __hw_protection_shutdown(const char *reason, int ms_until_forced, bool shutdown);
+
+enum hw_protection_action { HWPROT_ACT_SHUTDOWN, HWPROT_ACT_REBOOT };
+
+void __hw_protection_shutdown(const char *reason, int ms_until_forced,
+ enum hw_protection_action action);
static inline void hw_protection_reboot(const char *reason, int ms_until_forced)
{
- __hw_protection_shutdown(reason, ms_until_forced, false);
+ __hw_protection_shutdown(reason, ms_until_forced, HWPROT_ACT_REBOOT);
}
static inline void hw_protection_shutdown(const char *reason, int ms_until_forced)
{
- __hw_protection_shutdown(reason, ms_until_forced, true);
+ __hw_protection_shutdown(reason, ms_until_forced, HWPROT_ACT_SHUTDOWN);
}
/*
diff --git a/kernel/reboot.c b/kernel/reboot.c
index a701000bab3470df28665e8c9591cd82a033c6c2..f92aa66cbfec0f57ded43ba352a39c54d0c24a25 100644
--- a/kernel/reboot.c
+++ b/kernel/reboot.c
@@ -994,7 +994,8 @@ static void hw_failure_emergency_poweroff(int poweroff_delay_ms)
* pending even if the previous request has given a large timeout for forced
* shutdown/reboot.
*/
-void __hw_protection_shutdown(const char *reason, int ms_until_forced, bool shutdown)
+void __hw_protection_shutdown(const char *reason, int ms_until_forced,
+ enum hw_protection_action action)
{
static atomic_t allow_proceed = ATOMIC_INIT(1);
@@ -1009,10 +1010,10 @@ void __hw_protection_shutdown(const char *reason, int ms_until_forced, bool shut
* orderly_poweroff failure
*/
hw_failure_emergency_poweroff(ms_until_forced);
- if (shutdown)
- orderly_poweroff(true);
- else
+ if (action == HWPROT_ACT_REBOOT)
orderly_reboot();
+ else
+ orderly_poweroff(true);
}
EXPORT_SYMBOL_GPL(__hw_protection_shutdown);
--
2.39.5
Powered by blists - more mailing lists