@@ -15,34 +15,24 @@
#include <linux/platform_device.h>
#include <linux/of_platform.h>
#include <linux/module.h>
+#include <linux/pm.h>
#include <linux/reboot.h>
-#include <asm/system_misc.h>
-static void restart_poweroff_do_poweroff(void)
+static void restart_poweroff_do_poweroff(struct power_off_handler_block *this)
{
reboot_mode = REBOOT_HARD;
machine_restart(NULL);
}
-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 struct power_off_handler_block restart_power_off_handler = {
+ .handler = restart_poweroff_do_poweroff,
+ .priority = POWER_OFF_PRIORITY_FALLBACK,
+};
-static int restart_poweroff_remove(struct platform_device *pdev)
+static int restart_poweroff_probe(struct platform_device *pdev)
{
- if (pm_power_off == &restart_poweroff_do_poweroff)
- pm_power_off = NULL;
-
- return 0;
+ return devm_register_power_off_handler(&pdev->dev,
+ &restart_power_off_handler);
}
static const struct of_device_id of_restart_poweroff_match[] = {
@@ -52,7 +42,6 @@ static const struct of_device_id 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,