From edaa35b5573c5fa5f01cd3f6fe3cb9a5e75f722f Mon Sep 17 00:00:00 2001 From: Guenter Roeck Date: Wed, 10 Apr 2019 09:27:48 -0700 Subject: [PATCH] watchdog: wdat_wdt: Use 'dev' instead of dereferencing it repeatedly 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 Signed-off-by: Wim Van Sebroeck --- drivers/watchdog/wdat_wdt.c | 27 ++++++++++++++------------- 1 file changed, 14 insertions(+), 13 deletions(-) diff --git a/drivers/watchdog/wdat_wdt.c b/drivers/watchdog/wdat_wdt.c index 387892fe63b4..430ee4e9b185 100644 --- a/drivers/watchdog/wdat_wdt.c +++ b/drivers/watchdog/wdat_wdt.c @@ -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