diff options
author | Helge Deller <deller@gmx.de> | 2023-10-17 22:19:53 +0200 |
---|---|---|
committer | Helge Deller <deller@gmx.de> | 2023-10-30 14:54:40 +0100 |
commit | d0c219472980d15f5cbc5c8aec736848bda3f235 (patch) | |
tree | a52fe0a2c9bb73e8af76b5c58f6a2cfb3ac071f9 | |
parent | 01fef8267390ccb6e763a8aa90b6a10385aa3145 (diff) |
parisc/power: Add power soft-off when running on qemu
Signed-off-by: Helge Deller <deller@gmx.de>
Cc: stable@vger.kernel.org # v6.0+
-rw-r--r-- | drivers/parisc/power.c | 16 |
1 files changed, 15 insertions, 1 deletions
diff --git a/drivers/parisc/power.c b/drivers/parisc/power.c index 6f5e5f0230d3..6ee0717e34ec 100644 --- a/drivers/parisc/power.c +++ b/drivers/parisc/power.c @@ -197,6 +197,14 @@ static struct notifier_block parisc_panic_block = { .priority = INT_MAX, }; +/* qemu soft power-off function */ +static int qemu_power_off(struct sys_off_data *data) +{ + /* this turns the system off via SeaBIOS */ + *(int *)data->cb_data = 0; + pdc_soft_power_button(1); + return NOTIFY_DONE; +} static int __init power_init(void) { @@ -226,7 +234,13 @@ static int __init power_init(void) soft_power_reg); } - power_task = kthread_run(kpowerswd, (void*)soft_power_reg, KTHREAD_NAME); + power_task = NULL; + if (running_on_qemu && soft_power_reg) + register_sys_off_handler(SYS_OFF_MODE_POWER_OFF, SYS_OFF_PRIO_DEFAULT, + qemu_power_off, (void *)soft_power_reg); + else + power_task = kthread_run(kpowerswd, (void*)soft_power_reg, + KTHREAD_NAME); if (IS_ERR(power_task)) { printk(KERN_ERR DRIVER_NAME ": thread creation failed. Driver not loaded.\n"); pdc_soft_power_button(0); |