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 <linux@roeck-us.net>
Signed-off-by: Wim Van Sebroeck <wim@linux-watchdog.org>
This commit is contained in:
Guenter Roeck 2019-04-10 09:27:48 -07:00 committed by Wim Van Sebroeck
parent b1f4718218
commit edaa35b557
1 changed files with 14 additions and 13 deletions

View File

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