watchdog: wdat_wdt: Use 'dev' instead of dereferencing it repeatedly
authorGuenter Roeck <linux@roeck-us.net>
Wed, 10 Apr 2019 16:27:48 +0000 (09:27 -0700)
committerWim Van Sebroeck <wim@linux-watchdog.org>
Sun, 5 May 2019 19:02:33 +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

Signed-off-by: Guenter Roeck <linux@roeck-us.net>
Signed-off-by: Wim Van Sebroeck <wim@linux-watchdog.org>
drivers/watchdog/wdat_wdt.c

index 387892fe63b4a8ceca01916017a7b217c6a6a5c1..430ee4e9b1853fc2eaec8612b5a0a9e85197d928 100644 (file)
@@ -308,6 +308,7 @@ static const struct watchdog_ops wdat_wdt_ops = {
 
 static int wdat_wdt_probe(struct platform_device *pdev)
 {
+       struct device *dev = &pdev->dev;
        const struct acpi_wdat_entry *entries;
        const struct acpi_table_wdat *tbl;
        struct wdat_wdt *wdat;
@@ -321,11 +322,11 @@ static int wdat_wdt_probe(struct platform_device *pdev)
        if (ACPI_FAILURE(status))
                return -ENODEV;
 
-       wdat = devm_kzalloc(&pdev->dev, sizeof(*wdat), GFP_KERNEL);
+       wdat = devm_kzalloc(dev, sizeof(*wdat), GFP_KERNEL);
        if (!wdat)
                return -ENOMEM;
 
-       regs = devm_kcalloc(&pdev->dev, pdev->num_resources, sizeof(*regs),
+       regs = devm_kcalloc(dev, pdev->num_resources, sizeof(*regs),
                            GFP_KERNEL);
        if (!regs)
                return -ENOMEM;
@@ -350,15 +351,15 @@ static int wdat_wdt_probe(struct platform_device *pdev)
 
                res = &pdev->resource[i];
                if (resource_type(res) == IORESOURCE_MEM) {
-                       reg = devm_ioremap_resource(&pdev->dev, res);
+                       reg = devm_ioremap_resource(dev, res);
                        if (IS_ERR(reg))
                                return PTR_ERR(reg);
                } else if (resource_type(res) == IORESOURCE_IO) {
-                       reg = devm_ioport_map(&pdev->dev, res->start, 1);
+                       reg = devm_ioport_map(dev, res->start, 1);
                        if (!reg)
                                return -ENOMEM;
                } else {
-                       dev_err(&pdev->dev, "Unsupported resource\n");
+                       dev_err(dev, "Unsupported resource\n");
                        return -EINVAL;
                }
 
@@ -376,12 +377,11 @@ static int wdat_wdt_probe(struct platform_device *pdev)
 
                action = entries[i].action;
                if (action >= MAX_WDAT_ACTIONS) {
-                       dev_dbg(&pdev->dev, "Skipping unknown action: %u\n",
-                               action);
+                       dev_dbg(dev, "Skipping unknown action: %u\n", action);
                        continue;
                }
 
-               instr = devm_kzalloc(&pdev->dev, sizeof(*instr), GFP_KERNEL);
+               instr = devm_kzalloc(dev, sizeof(*instr), GFP_KERNEL);
                if (!instr)
                        return -ENOMEM;
 
@@ -398,7 +398,7 @@ static int wdat_wdt_probe(struct platform_device *pdev)
                } else if (gas->space_id == ACPI_ADR_SPACE_SYSTEM_IO) {
                        r.flags = IORESOURCE_IO;
                } else {
-                       dev_dbg(&pdev->dev, "Unsupported address space: %d\n",
+                       dev_dbg(dev, "Unsupported address space: %d\n",
                                gas->space_id);
                        continue;
                }
@@ -413,14 +413,15 @@ static int wdat_wdt_probe(struct platform_device *pdev)
                }
 
                if (!instr->reg) {
-                       dev_err(&pdev->dev, "I/O resource not found\n");
+                       dev_err(dev, "I/O resource not found\n");
                        return -EINVAL;
                }
 
                instructions = wdat->instructions[action];
                if (!instructions) {
-                       instructions = devm_kzalloc(&pdev->dev,
-                                       sizeof(*instructions), GFP_KERNEL);
+                       instructions = devm_kzalloc(dev,
+                                                   sizeof(*instructions),
+                                                   GFP_KERNEL);
                        if (!instructions)
                                return -ENOMEM;
 
@@ -441,7 +442,7 @@ static int wdat_wdt_probe(struct platform_device *pdev)
        platform_set_drvdata(pdev, wdat);
 
        watchdog_set_nowayout(&wdat->wdd, nowayout);
-       return devm_watchdog_register_device(&pdev->dev, &wdat->wdd);
+       return devm_watchdog_register_device(dev, &wdat->wdd);
 }
 
 #ifdef CONFIG_PM_SLEEP