[PATCH] um: register power-off handler

Johannes Berg johannes at sipsolutions.net
Wed Jul 3 08:38:40 PDT 2024


From: Johannes Berg <johannes.berg at intel.com>

Otherwise we always get

 reboot: Power off not available: System halted instead

which is really quite pointless.

Signed-off-by: Johannes Berg <johannes.berg at intel.com>
---
 arch/um/kernel/reboot.c | 15 +++++++++++++++
 1 file changed, 15 insertions(+)

diff --git a/arch/um/kernel/reboot.c b/arch/um/kernel/reboot.c
index 25840eee1068..3736bca626ba 100644
--- a/arch/um/kernel/reboot.c
+++ b/arch/um/kernel/reboot.c
@@ -59,3 +59,18 @@ void machine_halt(void)
 {
 	machine_power_off();
 }
+
+static int sys_power_off_handler(struct sys_off_data *data)
+{
+	machine_power_off();
+	return 0;
+}
+
+static int register_power_off(void)
+{
+	register_sys_off_handler(SYS_OFF_MODE_POWER_OFF,
+				 SYS_OFF_PRIO_DEFAULT,
+				 sys_power_off_handler, NULL);
+	return 0;
+}
+__initcall(register_power_off);
-- 
2.45.2




More information about the linux-um mailing list