On 03/07/2024 16:38, Johannes Berg wrote:
From: Johannes Berg <johannes.b...@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.b...@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);

Anton Ivanov <anton.iva...@cambridgegreys.com>

--
Anton R. Ivanov
https://www.kot-begemot.co.uk/

Reply via email to