1717
1818struct gpio_restart {
1919 struct gpio_desc * reset_gpio ;
20- struct notifier_block restart_handler ;
2120 u32 active_delay_ms ;
2221 u32 inactive_delay_ms ;
2322 u32 wait_delay_ms ;
2423};
2524
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 )
2826{
29- struct gpio_restart * gpio_restart =
30- container_of (this , struct gpio_restart , restart_handler );
27+ struct gpio_restart * gpio_restart = data -> cb_data ;
3128
3229 /* drive it active, also inactive->active edge */
3330 gpiod_direction_output (gpio_restart -> reset_gpio , 1 );
@@ -52,6 +49,7 @@ static int gpio_restart_probe(struct platform_device *pdev)
5249{
5350 struct gpio_restart * gpio_restart ;
5451 bool open_source = false;
52+ int priority = 129 ;
5553 u32 property ;
5654 int ret ;
5755
@@ -71,8 +69,6 @@ static int gpio_restart_probe(struct platform_device *pdev)
7169 return ret ;
7270 }
7371
74- gpio_restart -> restart_handler .notifier_call = gpio_restart_notify ;
75- gpio_restart -> restart_handler .priority = 129 ;
7672 gpio_restart -> active_delay_ms = 100 ;
7773 gpio_restart -> inactive_delay_ms = 100 ;
7874 gpio_restart -> wait_delay_ms = 3000 ;
@@ -83,7 +79,7 @@ static int gpio_restart_probe(struct platform_device *pdev)
8379 dev_err (& pdev -> dev , "Invalid priority property: %u\n" ,
8480 property );
8581 else
86- gpio_restart -> restart_handler . priority = property ;
82+ priority = property ;
8783 }
8884
8985 of_property_read_u32 (pdev -> dev .of_node , "active-delay" ,
@@ -93,9 +89,11 @@ static int gpio_restart_probe(struct platform_device *pdev)
9389 of_property_read_u32 (pdev -> dev .of_node , "wait-delay" ,
9490 & gpio_restart -> wait_delay_ms );
9591
96- platform_set_drvdata (pdev , gpio_restart );
97-
98- ret = register_restart_handler (& gpio_restart -> restart_handler );
92+ ret = devm_register_sys_off_handler (& pdev -> dev ,
93+ SYS_OFF_MODE_RESTART ,
94+ priority ,
95+ gpio_restart_notify ,
96+ gpio_restart );
9997 if (ret ) {
10098 dev_err (& pdev -> dev , "%s: cannot register restart handler, %d\n" ,
10199 __func__ , ret );
@@ -105,27 +103,13 @@ static int gpio_restart_probe(struct platform_device *pdev)
105103 return 0 ;
106104}
107105
108- static void gpio_restart_remove (struct platform_device * pdev )
109- {
110- struct gpio_restart * gpio_restart = platform_get_drvdata (pdev );
111- int ret ;
112-
113- ret = unregister_restart_handler (& gpio_restart -> restart_handler );
114- if (ret ) {
115- dev_err (& pdev -> dev ,
116- "%s: cannot unregister restart handler, %d\n" ,
117- __func__ , ret );
118- }
119- }
120-
121106static const struct of_device_id of_gpio_restart_match [] = {
122107 { .compatible = "gpio-restart" , },
123108 {},
124109};
125110
126111static struct platform_driver gpio_restart_driver = {
127112 .probe = gpio_restart_probe ,
128- .remove_new = gpio_restart_remove ,
129113 .driver = {
130114 .name = "restart-gpio" ,
131115 .of_match_table = of_gpio_restart_match ,
0 commit comments