[3/3] watchdog: wm8350: Simplify using devm_watchdog_register_device()

Message ID 20230306170901.2232323-4-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:09 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/wm8350_wdt.c | 9 +--------
 1 file changed, 1 insertion(+), 8 deletions(-)
  

Comments

Guenter Roeck March 6, 2023, 5:31 p.m. UTC | #1
On Mon, Mar 06, 2023 at 06:09:01PM +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/wm8350_wdt.c | 9 +--------
>  1 file changed, 1 insertion(+), 8 deletions(-)
> 
> diff --git a/drivers/watchdog/wm8350_wdt.c b/drivers/watchdog/wm8350_wdt.c
> index 33c62d51f00a..911ad64460a6 100644
> --- a/drivers/watchdog/wm8350_wdt.c
> +++ b/drivers/watchdog/wm8350_wdt.c
> @@ -153,18 +153,11 @@ static int wm8350_wdt_probe(struct platform_device *pdev)
>  	/* Default to 4s timeout */
>  	wm8350_wdt_set_timeout(&wm8350_wdt, 4);
>  
> -	return watchdog_register_device(&wm8350_wdt);
> -}
> -
> -static int wm8350_wdt_remove(struct platform_device *pdev)
> -{
> -	watchdog_unregister_device(&wm8350_wdt);
> -	return 0;
> +	return devm_watchdog_register_device(&wm8350_wdt);
>  }
>  
>  static struct platform_driver wm8350_wdt_driver = {
>  	.probe = wm8350_wdt_probe,
> -	.remove = wm8350_wdt_remove,
>  	.driver = {
>  		.name = "wm8350-wdt",
>  	},
> -- 
> 2.39.1
>
  
kernel test robot March 6, 2023, 7:39 p.m. UTC | #2
Hi Uwe,

I love your patch! Yet something to improve:

[auto build test ERROR on fe15c26ee26efa11741a7b632e9f23b01aca4cc6]

url:    https://github.com/intel-lab-lkp/linux/commits/Uwe-Kleine-K-nig/watchdog-bcm47xx-Simplify-using-devm_watchdog_register_device/20230307-011628
base:   fe15c26ee26efa11741a7b632e9f23b01aca4cc6
patch link:    https://lore.kernel.org/r/20230306170901.2232323-4-u.kleine-koenig%40pengutronix.de
patch subject: [PATCH 3/3] watchdog: wm8350: Simplify using devm_watchdog_register_device()
config: ia64-allyesconfig (https://download.01.org/0day-ci/archive/20230307/202303070325.74bkgnG6-lkp@intel.com/config)
compiler: ia64-linux-gcc (GCC) 12.1.0
reproduce (this is a W=1 build):
        wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
        chmod +x ~/bin/make.cross
        # https://github.com/intel-lab-lkp/linux/commit/94594fa75b3515d5dbff3ec2d1db1cf5627900b1
        git remote add linux-review https://github.com/intel-lab-lkp/linux
        git fetch --no-tags linux-review Uwe-Kleine-K-nig/watchdog-bcm47xx-Simplify-using-devm_watchdog_register_device/20230307-011628
        git checkout 94594fa75b3515d5dbff3ec2d1db1cf5627900b1
        # save the config file
        mkdir build_dir && cp config build_dir/.config
        COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-12.1.0 make.cross W=1 O=build_dir ARCH=ia64 olddefconfig
        COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-12.1.0 make.cross W=1 O=build_dir ARCH=ia64 SHELL=/bin/bash drivers/

If you fix the issue, kindly add following tag where applicable
| Reported-by: kernel test robot <lkp@intel.com>
| Link: https://lore.kernel.org/oe-kbuild-all/202303070325.74bkgnG6-lkp@intel.com/

All errors (new ones prefixed by >>):

   drivers/watchdog/wm8350_wdt.c: In function 'wm8350_wdt_probe':
>> drivers/watchdog/wm8350_wdt.c:156:46: error: passing argument 1 of 'devm_watchdog_register_device' from incompatible pointer type [-Werror=incompatible-pointer-types]
     156 |         return devm_watchdog_register_device(&wm8350_wdt);
         |                                              ^~~~~~~~~~~
         |                                              |
         |                                              struct watchdog_device *
   In file included from drivers/watchdog/wm8350_wdt.c:15:
   include/linux/watchdog.h:226:50: note: expected 'struct device *' but argument is of type 'struct watchdog_device *'
     226 | int devm_watchdog_register_device(struct device *dev, struct watchdog_device *);
         |                                   ~~~~~~~~~~~~~~~^~~
>> drivers/watchdog/wm8350_wdt.c:156:16: error: too few arguments to function 'devm_watchdog_register_device'
     156 |         return devm_watchdog_register_device(&wm8350_wdt);
         |                ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   include/linux/watchdog.h:226:5: note: declared here
     226 | int devm_watchdog_register_device(struct device *dev, struct watchdog_device *);
         |     ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   drivers/watchdog/wm8350_wdt.c:157:1: error: control reaches end of non-void function [-Werror=return-type]
     157 | }
         | ^
   cc1: some warnings being treated as errors


vim +/devm_watchdog_register_device +156 drivers/watchdog/wm8350_wdt.c

   139	
   140	static int wm8350_wdt_probe(struct platform_device *pdev)
   141	{
   142		struct wm8350 *wm8350 = platform_get_drvdata(pdev);
   143	
   144		if (!wm8350) {
   145			pr_err("No driver data supplied\n");
   146			return -ENODEV;
   147		}
   148	
   149		watchdog_set_nowayout(&wm8350_wdt, nowayout);
   150		watchdog_set_drvdata(&wm8350_wdt, wm8350);
   151		wm8350_wdt.parent = &pdev->dev;
   152	
   153		/* Default to 4s timeout */
   154		wm8350_wdt_set_timeout(&wm8350_wdt, 4);
   155	
 > 156		return devm_watchdog_register_device(&wm8350_wdt);
   157	}
   158
  

Patch

diff --git a/drivers/watchdog/wm8350_wdt.c b/drivers/watchdog/wm8350_wdt.c
index 33c62d51f00a..911ad64460a6 100644
--- a/drivers/watchdog/wm8350_wdt.c
+++ b/drivers/watchdog/wm8350_wdt.c
@@ -153,18 +153,11 @@  static int wm8350_wdt_probe(struct platform_device *pdev)
 	/* Default to 4s timeout */
 	wm8350_wdt_set_timeout(&wm8350_wdt, 4);
 
-	return watchdog_register_device(&wm8350_wdt);
-}
-
-static int wm8350_wdt_remove(struct platform_device *pdev)
-{
-	watchdog_unregister_device(&wm8350_wdt);
-	return 0;
+	return devm_watchdog_register_device(&wm8350_wdt);
 }
 
 static struct platform_driver wm8350_wdt_driver = {
 	.probe = wm8350_wdt_probe,
-	.remove = wm8350_wdt_remove,
 	.driver = {
 		.name = "wm8350-wdt",
 	},