watchdog: mena21_wdt: Use 'dev' instead of dereferencing it repeatedly
authorGuenter Roeck <linux@roeck-us.net>
Tue, 9 Apr 2019 17:23:40 +0000 (10:23 -0700)
committerWim Van Sebroeck <wim@linux-watchdog.org>
Sun, 5 May 2019 19:02:23 +0000 (21:02 +0200)
Introduce local variable 'struct device *dev' and use it instead of
dereferencing it repeatedly.

The conversion was done automatically with coccinelle using the
following semantic patches. The semantic patches and the scripts
used to generate this commit log are available at
https://github.com/groeck/coccinelle-patches

Cc: Johannes Thumshirn <morbidrsa@gmail.com>
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
Reviewed-by: Johannes Thumshirn <jth@kernel.org>
Signed-off-by: Wim Van Sebroeck <wim@linux-watchdog.org>
drivers/watchdog/mena21_wdt.c

index 6db69883ece69540839ec6da3ec5a88939019df8..e9ca4e0e25dc02babc50bb2818346cb9bc9d096a 100644 (file)
@@ -127,19 +127,20 @@ static struct watchdog_device a21_wdt = {
 
 static int a21_wdt_probe(struct platform_device *pdev)
 {
+       struct device *dev = &pdev->dev;
        struct a21_wdt_drv *drv;
        unsigned int reset = 0;
        int num_gpios;
        int ret;
        int i;
 
-       drv = devm_kzalloc(&pdev->dev, sizeof(struct a21_wdt_drv), GFP_KERNEL);
+       drv = devm_kzalloc(dev, sizeof(struct a21_wdt_drv), GFP_KERNEL);
        if (!drv)
                return -ENOMEM;
 
-       num_gpios = gpiod_count(&pdev->dev, NULL);
+       num_gpios = gpiod_count(dev, NULL);
        if (num_gpios != NUM_GPIOS) {
-               dev_err(&pdev->dev, "gpios DT property wrong, got %d want %d",
+               dev_err(dev, "gpios DT property wrong, got %d want %d",
                        num_gpios, NUM_GPIOS);
                return -ENODEV;
        }
@@ -152,12 +153,9 @@ static int a21_wdt_probe(struct platform_device *pdev)
                        gflags = GPIOD_ASIS;
                else
                        gflags = GPIOD_IN;
-               drv->gpios[i] = devm_gpiod_get_index(&pdev->dev, NULL, i,
-                                                    gflags);
-               if (IS_ERR(drv->gpios[i])) {
-                       ret = PTR_ERR(drv->gpios[i]);
-                       return ret;
-               }
+               drv->gpios[i] = devm_gpiod_get_index(dev, NULL, i, gflags);
+               if (IS_ERR(drv->gpios[i]))
+                       return PTR_ERR(drv->gpios[i]);
 
                gpiod_set_consumer_name(drv->gpios[i], "MEN A21 Watchdog");
 
@@ -173,10 +171,10 @@ static int a21_wdt_probe(struct platform_device *pdev)
                }
        }
 
-       watchdog_init_timeout(&a21_wdt, 30, &pdev->dev);
+       watchdog_init_timeout(&a21_wdt, 30, dev);
        watchdog_set_nowayout(&a21_wdt, nowayout);
        watchdog_set_drvdata(&a21_wdt, drv);
-       a21_wdt.parent = &pdev->dev;
+       a21_wdt.parent = dev;
 
        reset = a21_wdt_get_bootstatus(drv);
        if (reset == 2)
@@ -189,15 +187,15 @@ static int a21_wdt_probe(struct platform_device *pdev)
                a21_wdt.bootstatus |= WDIOF_EXTERN2;
 
        drv->wdt = a21_wdt;
-       dev_set_drvdata(&pdev->dev, drv);
+       dev_set_drvdata(dev, drv);
 
-       ret = devm_watchdog_register_device(&pdev->dev, &a21_wdt);
+       ret = devm_watchdog_register_device(dev, &a21_wdt);
        if (ret) {
-               dev_err(&pdev->dev, "Cannot register watchdog device\n");
+               dev_err(dev, "Cannot register watchdog device\n");
                return ret;
        }
 
-       dev_info(&pdev->dev, "MEN A21 watchdog timer driver enabled\n");
+       dev_info(dev, "MEN A21 watchdog timer driver enabled\n");
 
        return 0;
 }