diff options
Diffstat (limited to 'drivers/power/reset/restart-poweroff.c')
| -rw-r--r-- | drivers/power/reset/restart-poweroff.c | 39 |
1 files changed, 12 insertions, 27 deletions
diff --git a/drivers/power/reset/restart-poweroff.c b/drivers/power/reset/restart-poweroff.c index 5758033e0c16..fcd588f9ae9d 100644 --- a/drivers/power/reset/restart-poweroff.c +++ b/drivers/power/reset/restart-poweroff.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: GPL-2.0-only /* * Power off by restarting and let u-boot keep hold of the machine * until the user presses a button for example. @@ -5,10 +6,6 @@ * Andrew Lunn <andrew@lunn.ch> * * Copyright (C) 2012 Andrew Lunn - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License version 2 as - * published by the Free Software Foundation. */ #include <linux/kernel.h> #include <linux/init.h> @@ -16,45 +13,34 @@ #include <linux/of_platform.h> #include <linux/module.h> #include <linux/reboot.h> -#include <asm/system_misc.h> -static void restart_poweroff_do_poweroff(void) +static int restart_poweroff_do_poweroff(struct sys_off_data *data) { - arm_pm_restart(REBOOT_HARD, NULL); + reboot_mode = REBOOT_HARD; + machine_restart(NULL); + return NOTIFY_DONE; } static int restart_poweroff_probe(struct platform_device *pdev) { - /* If a pm_power_off function has already been added, leave it alone */ - if (pm_power_off != NULL) { - dev_err(&pdev->dev, - "pm_power_off function already registered"); - return -EBUSY; - } - - pm_power_off = &restart_poweroff_do_poweroff; - return 0; -} - -static int restart_poweroff_remove(struct platform_device *pdev) -{ - if (pm_power_off == &restart_poweroff_do_poweroff) - pm_power_off = NULL; - - return 0; + /* Set this handler to low priority to not override an existing handler */ + return devm_register_sys_off_handler(&pdev->dev, + SYS_OFF_MODE_POWER_OFF, + SYS_OFF_PRIO_LOW, + restart_poweroff_do_poweroff, + NULL); } static const struct of_device_id of_restart_poweroff_match[] = { { .compatible = "restart-poweroff", }, {}, }; +MODULE_DEVICE_TABLE(of, of_restart_poweroff_match); static struct platform_driver restart_poweroff_driver = { .probe = restart_poweroff_probe, - .remove = restart_poweroff_remove, .driver = { .name = "poweroff-restart", - .owner = THIS_MODULE, .of_match_table = of_restart_poweroff_match, }, }; @@ -62,5 +48,4 @@ module_platform_driver(restart_poweroff_driver); MODULE_AUTHOR("Andrew Lunn <andrew@lunn.ch"); MODULE_DESCRIPTION("restart poweroff driver"); -MODULE_LICENSE("GPLv2"); MODULE_ALIAS("platform:poweroff-restart"); |
