[1/3] watchdog: bcm47xx: Simplify using devm_watchdog_register_device()

Message ID 20230306170901.2232323-2-u.kleine-koenig@pengutronix.de
State New
Headers
Series watchdog: Simplify using devm_watchdog_register_device() |

Commit Message

Uwe Kleine-König March 6, 2023, 5:08 p.m. UTC
  This allows to drop the .remove() function as it only exists to
unregister the watchdog device which is now done in a callback
registered by devm_watchdog_register_device().

Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
---
 drivers/watchdog/bcm47xx_wdt.c | 12 +-----------
 1 file changed, 1 insertion(+), 11 deletions(-)
  

Comments

Guenter Roeck March 6, 2023, 5:30 p.m. UTC | #1
On Mon, Mar 06, 2023 at 06:08:59PM +0100, Uwe Kleine-König wrote:
> This allows to drop the .remove() function as it only exists to
> unregister the watchdog device which is now done in a callback
> registered by devm_watchdog_register_device().
> 
> Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>

Reviewed-by: Guenter Roeck <linux@roeck-us.net>

> ---
>  drivers/watchdog/bcm47xx_wdt.c | 12 +-----------
>  1 file changed, 1 insertion(+), 11 deletions(-)
> 
> diff --git a/drivers/watchdog/bcm47xx_wdt.c b/drivers/watchdog/bcm47xx_wdt.c
> index 05425c1dfd4c..8698ef94dddf 100644
> --- a/drivers/watchdog/bcm47xx_wdt.c
> +++ b/drivers/watchdog/bcm47xx_wdt.c
> @@ -202,7 +202,7 @@ static int bcm47xx_wdt_probe(struct platform_device *pdev)
>  	watchdog_set_restart_priority(&wdt->wdd, 64);
>  	watchdog_stop_on_reboot(&wdt->wdd);
>  
> -	ret = watchdog_register_device(&wdt->wdd);
> +	ret = devm_watchdog_register_device(&wdt->wdd);
>  	if (ret)
>  		goto err_timer;
>  
> @@ -218,21 +218,11 @@ static int bcm47xx_wdt_probe(struct platform_device *pdev)
>  	return ret;
>  }
>  
> -static int bcm47xx_wdt_remove(struct platform_device *pdev)
> -{
> -	struct bcm47xx_wdt *wdt = dev_get_platdata(&pdev->dev);
> -
> -	watchdog_unregister_device(&wdt->wdd);
> -
> -	return 0;
> -}
> -
>  static struct platform_driver bcm47xx_wdt_driver = {
>  	.driver		= {
>  		.name	= "bcm47xx-wdt",
>  	},
>  	.probe		= bcm47xx_wdt_probe,
> -	.remove		= bcm47xx_wdt_remove,
>  };
>  
>  module_platform_driver(bcm47xx_wdt_driver);
> -- 
> 2.39.1
>
  
Guenter Roeck March 6, 2023, 8:17 p.m. UTC | #2
On 3/6/23 09:08, Uwe Kleine-König wrote:
> This allows to drop the .remove() function as it only exists to
> unregister the watchdog device which is now done in a callback
> registered by devm_watchdog_register_device().
> 
> Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
> ---
>   drivers/watchdog/bcm47xx_wdt.c | 12 +-----------
>   1 file changed, 1 insertion(+), 11 deletions(-)
> 
> diff --git a/drivers/watchdog/bcm47xx_wdt.c b/drivers/watchdog/bcm47xx_wdt.c
> index 05425c1dfd4c..8698ef94dddf 100644
> --- a/drivers/watchdog/bcm47xx_wdt.c
> +++ b/drivers/watchdog/bcm47xx_wdt.c
> @@ -202,7 +202,7 @@ static int bcm47xx_wdt_probe(struct platform_device *pdev)
>   	watchdog_set_restart_priority(&wdt->wdd, 64);
>   	watchdog_stop_on_reboot(&wdt->wdd);
>   
> -	ret = watchdog_register_device(&wdt->wdd);
> +	ret = devm_watchdog_register_device(&wdt->wdd);

Oops, all those need &pdev->dev as first argument. Please resend with that fixed.

Thanks,
Guenter

>   	if (ret)
>   		goto err_timer;
>   
> @@ -218,21 +218,11 @@ static int bcm47xx_wdt_probe(struct platform_device *pdev)
>   	return ret;
>   }
>   
> -static int bcm47xx_wdt_remove(struct platform_device *pdev)
> -{
> -	struct bcm47xx_wdt *wdt = dev_get_platdata(&pdev->dev);
> -
> -	watchdog_unregister_device(&wdt->wdd);
> -
> -	return 0;
> -}
> -
>   static struct platform_driver bcm47xx_wdt_driver = {
>   	.driver		= {
>   		.name	= "bcm47xx-wdt",
>   	},
>   	.probe		= bcm47xx_wdt_probe,
> -	.remove		= bcm47xx_wdt_remove,
>   };
>   
>   module_platform_driver(bcm47xx_wdt_driver);
  

Patch

diff --git a/drivers/watchdog/bcm47xx_wdt.c b/drivers/watchdog/bcm47xx_wdt.c
index 05425c1dfd4c..8698ef94dddf 100644
--- a/drivers/watchdog/bcm47xx_wdt.c
+++ b/drivers/watchdog/bcm47xx_wdt.c
@@ -202,7 +202,7 @@  static int bcm47xx_wdt_probe(struct platform_device *pdev)
 	watchdog_set_restart_priority(&wdt->wdd, 64);
 	watchdog_stop_on_reboot(&wdt->wdd);
 
-	ret = watchdog_register_device(&wdt->wdd);
+	ret = devm_watchdog_register_device(&wdt->wdd);
 	if (ret)
 		goto err_timer;
 
@@ -218,21 +218,11 @@  static int bcm47xx_wdt_probe(struct platform_device *pdev)
 	return ret;
 }
 
-static int bcm47xx_wdt_remove(struct platform_device *pdev)
-{
-	struct bcm47xx_wdt *wdt = dev_get_platdata(&pdev->dev);
-
-	watchdog_unregister_device(&wdt->wdd);
-
-	return 0;
-}
-
 static struct platform_driver bcm47xx_wdt_driver = {
 	.driver		= {
 		.name	= "bcm47xx-wdt",
 	},
 	.probe		= bcm47xx_wdt_probe,
-	.remove		= bcm47xx_wdt_remove,
 };
 
 module_platform_driver(bcm47xx_wdt_driver);