0001
0002
0003
0004
0005
0006
0007
0008
0009
0010 #include <linux/kernel.h>
0011 #include <linux/init.h>
0012 #include <linux/platform_device.h>
0013 #include <linux/of_platform.h>
0014 #include <linux/module.h>
0015 #include <linux/reboot.h>
0016
0017 static void restart_poweroff_do_poweroff(void)
0018 {
0019 reboot_mode = REBOOT_HARD;
0020 machine_restart(NULL);
0021 }
0022
0023 static int restart_poweroff_probe(struct platform_device *pdev)
0024 {
0025
0026 if (pm_power_off != NULL) {
0027 dev_err(&pdev->dev,
0028 "pm_power_off function already registered");
0029 return -EBUSY;
0030 }
0031
0032 pm_power_off = &restart_poweroff_do_poweroff;
0033 return 0;
0034 }
0035
0036 static int restart_poweroff_remove(struct platform_device *pdev)
0037 {
0038 if (pm_power_off == &restart_poweroff_do_poweroff)
0039 pm_power_off = NULL;
0040
0041 return 0;
0042 }
0043
0044 static const struct of_device_id of_restart_poweroff_match[] = {
0045 { .compatible = "restart-poweroff", },
0046 {},
0047 };
0048 MODULE_DEVICE_TABLE(of, of_restart_poweroff_match);
0049
0050 static struct platform_driver restart_poweroff_driver = {
0051 .probe = restart_poweroff_probe,
0052 .remove = restart_poweroff_remove,
0053 .driver = {
0054 .name = "poweroff-restart",
0055 .of_match_table = of_restart_poweroff_match,
0056 },
0057 };
0058 module_platform_driver(restart_poweroff_driver);
0059
0060 MODULE_AUTHOR("Andrew Lunn <andrew@lunn.ch");
0061 MODULE_DESCRIPTION("restart poweroff driver");
0062 MODULE_LICENSE("GPL v2");
0063 MODULE_ALIAS("platform:poweroff-restart");