Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

power: reset: gpio-restart: Use devm_register_sys_off_handler()

Use device life-cycle managed register function to simplify probe error
path and eliminate need for explicit remove function.

Signed-off-by: Andrew Davis <afd@ti.com>
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>

authored by

Andrew Davis and committed by
Sebastian Reichel
c04c4ebd b55d073e

+9 -25
+9 -25
drivers/power/reset/gpio-restart.c
··· 17 17 18 18 struct gpio_restart { 19 19 struct gpio_desc *reset_gpio; 20 - struct notifier_block restart_handler; 21 20 u32 active_delay_ms; 22 21 u32 inactive_delay_ms; 23 22 u32 wait_delay_ms; 24 23 }; 25 24 26 - static int gpio_restart_notify(struct notifier_block *this, 27 - unsigned long mode, void *cmd) 25 + static int gpio_restart_notify(struct sys_off_data *data) 28 26 { 29 - struct gpio_restart *gpio_restart = 30 - container_of(this, struct gpio_restart, restart_handler); 27 + struct gpio_restart *gpio_restart = data->cb_data; 31 28 32 29 /* drive it active, also inactive->active edge */ 33 30 gpiod_direction_output(gpio_restart->reset_gpio, 1); ··· 49 52 { 50 53 struct gpio_restart *gpio_restart; 51 54 bool open_source = false; 55 + int priority = 129; 52 56 u32 property; 53 57 int ret; 54 58 ··· 69 71 return ret; 70 72 } 71 73 72 - gpio_restart->restart_handler.notifier_call = gpio_restart_notify; 73 - gpio_restart->restart_handler.priority = 129; 74 74 gpio_restart->active_delay_ms = 100; 75 75 gpio_restart->inactive_delay_ms = 100; 76 76 gpio_restart->wait_delay_ms = 3000; ··· 79 83 dev_err(&pdev->dev, "Invalid priority property: %u\n", 80 84 property); 81 85 else 82 - gpio_restart->restart_handler.priority = property; 86 + priority = property; 83 87 } 84 88 85 89 of_property_read_u32(pdev->dev.of_node, "active-delay", ··· 89 93 of_property_read_u32(pdev->dev.of_node, "wait-delay", 90 94 &gpio_restart->wait_delay_ms); 91 95 92 - platform_set_drvdata(pdev, gpio_restart); 93 - 94 - ret = register_restart_handler(&gpio_restart->restart_handler); 96 + ret = devm_register_sys_off_handler(&pdev->dev, 97 + SYS_OFF_MODE_RESTART, 98 + priority, 99 + gpio_restart_notify, 100 + gpio_restart); 95 101 if (ret) { 96 102 dev_err(&pdev->dev, "%s: cannot register restart handler, %d\n", 97 103 __func__, ret); ··· 103 105 return 0; 104 106 } 105 107 106 - static void gpio_restart_remove(struct platform_device *pdev) 107 - { 108 - struct gpio_restart *gpio_restart = platform_get_drvdata(pdev); 109 - int ret; 110 - 111 - ret = unregister_restart_handler(&gpio_restart->restart_handler); 112 - if (ret) { 113 - dev_err(&pdev->dev, 114 - "%s: cannot unregister restart handler, %d\n", 115 - __func__, ret); 116 - } 117 - } 118 - 119 108 static const struct of_device_id of_gpio_restart_match[] = { 120 109 { .compatible = "gpio-restart", }, 121 110 {}, ··· 110 125 111 126 static struct platform_driver gpio_restart_driver = { 112 127 .probe = gpio_restart_probe, 113 - .remove_new = gpio_restart_remove, 114 128 .driver = { 115 129 .name = "restart-gpio", 116 130 .of_match_table = of_gpio_restart_match,