diff mbox series

um: register power-off handler

Message ID 20240703173839.fcbb538c6686.I3d333f4773cff93c4337c4d128ee0b1b501b3dfa@changeid
State Accepted
Headers show
Series um: register power-off handler | expand

Commit Message

Johannes Berg July 3, 2024, 3:38 p.m. UTC
From: Johannes Berg <johannes.berg@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@intel.com>
---
 arch/um/kernel/reboot.c | 15 +++++++++++++++
 1 file changed, 15 insertions(+)

Comments

Anton Ivanov July 4, 2024, 6:58 a.m. UTC | #1
On 03/07/2024 16:38, Johannes Berg wrote:
> From: Johannes Berg <johannes.berg@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@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.ivanov@cambridgegreys.com>
Johannes Berg July 4, 2024, 9:21 a.m. UTC | #2
On Thu, 2024-07-04 at 07:58 +0100, Anton Ivanov wrote:
> 
> > +__initcall(register_power_off);
> 
> Anton Ivanov <anton.ivanov@cambridgegreys.com>

Heh, I thought I saw an Acked-by from you but then patchwork didn't seem
to pick it up, I guess I'll treat it as one anyway? :)

johannes
Anton Ivanov July 4, 2024, 9:46 a.m. UTC | #3
On 04/07/2024 10:21, Johannes Berg wrote:
> On Thu, 2024-07-04 at 07:58 +0100, Anton Ivanov wrote:
>>> +__initcall(register_power_off);
>> Anton Ivanov <anton.ivanov@cambridgegreys.com>
> Heh, I thought I saw an Acked-by from you but then patchwork didn't seem
> to pick it up, I guess I'll treat it as one anyway? :)

Yes. Sorry. Too high blood level in the coffee circulatory system.


>
> johannes
>
diff mbox series

Patch

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);