Skip to content

Commit 8686532

Browse files
Anson-HuangWim Van Sebroeck
authored andcommitted
watchdog: imx2_wdt: Use 'dev' instead of dereferencing it repeatedly
Add helper variable dev = &pdev->dev to simply the code. Signed-off-by: Anson Huang <[email protected]> Reviewed-by: Guenter Roeck <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Guenter Roeck <[email protected]> Signed-off-by: Wim Van Sebroeck <[email protected]>
1 parent ebe66de commit 8686532

File tree

1 file changed

+12
-11
lines changed

1 file changed

+12
-11
lines changed

drivers/watchdog/imx2_wdt.c

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -246,30 +246,31 @@ static const struct regmap_config imx2_wdt_regmap_config = {
246246

247247
static int __init imx2_wdt_probe(struct platform_device *pdev)
248248
{
249+
struct device *dev = &pdev->dev;
249250
struct imx2_wdt_device *wdev;
250251
struct watchdog_device *wdog;
251252
void __iomem *base;
252253
int ret;
253254
u32 val;
254255

255-
wdev = devm_kzalloc(&pdev->dev, sizeof(*wdev), GFP_KERNEL);
256+
wdev = devm_kzalloc(dev, sizeof(*wdev), GFP_KERNEL);
256257
if (!wdev)
257258
return -ENOMEM;
258259

259260
base = devm_platform_ioremap_resource(pdev, 0);
260261
if (IS_ERR(base))
261262
return PTR_ERR(base);
262263

263-
wdev->regmap = devm_regmap_init_mmio_clk(&pdev->dev, NULL, base,
264+
wdev->regmap = devm_regmap_init_mmio_clk(dev, NULL, base,
264265
&imx2_wdt_regmap_config);
265266
if (IS_ERR(wdev->regmap)) {
266-
dev_err(&pdev->dev, "regmap init failed\n");
267+
dev_err(dev, "regmap init failed\n");
267268
return PTR_ERR(wdev->regmap);
268269
}
269270

270-
wdev->clk = devm_clk_get(&pdev->dev, NULL);
271+
wdev->clk = devm_clk_get(dev, NULL);
271272
if (IS_ERR(wdev->clk)) {
272-
dev_err(&pdev->dev, "can't get Watchdog clock\n");
273+
dev_err(dev, "can't get Watchdog clock\n");
273274
return PTR_ERR(wdev->clk);
274275
}
275276

@@ -279,12 +280,12 @@ static int __init imx2_wdt_probe(struct platform_device *pdev)
279280
wdog->min_timeout = 1;
280281
wdog->timeout = IMX2_WDT_DEFAULT_TIME;
281282
wdog->max_hw_heartbeat_ms = IMX2_WDT_MAX_TIME * 1000;
282-
wdog->parent = &pdev->dev;
283+
wdog->parent = dev;
283284

284285
ret = platform_get_irq(pdev, 0);
285286
if (ret > 0)
286-
if (!devm_request_irq(&pdev->dev, ret, imx2_wdt_isr, 0,
287-
dev_name(&pdev->dev), wdog))
287+
if (!devm_request_irq(dev, ret, imx2_wdt_isr, 0,
288+
dev_name(dev), wdog))
288289
wdog->info = &imx2_wdt_pretimeout_info;
289290

290291
ret = clk_prepare_enable(wdev->clk);
@@ -294,13 +295,13 @@ static int __init imx2_wdt_probe(struct platform_device *pdev)
294295
regmap_read(wdev->regmap, IMX2_WDT_WRSR, &val);
295296
wdog->bootstatus = val & IMX2_WDT_WRSR_TOUT ? WDIOF_CARDRESET : 0;
296297

297-
wdev->ext_reset = of_property_read_bool(pdev->dev.of_node,
298+
wdev->ext_reset = of_property_read_bool(dev->of_node,
298299
"fsl,ext-reset-output");
299300
platform_set_drvdata(pdev, wdog);
300301
watchdog_set_drvdata(wdog, wdev);
301302
watchdog_set_nowayout(wdog, nowayout);
302303
watchdog_set_restart_priority(wdog, 128);
303-
watchdog_init_timeout(wdog, timeout, &pdev->dev);
304+
watchdog_init_timeout(wdog, timeout, dev);
304305

305306
if (imx2_wdt_is_running(wdev)) {
306307
imx2_wdt_set_timeout(wdog, wdog->timeout);
@@ -318,7 +319,7 @@ static int __init imx2_wdt_probe(struct platform_device *pdev)
318319
if (ret)
319320
goto disable_clk;
320321

321-
dev_info(&pdev->dev, "timeout %d sec (nowayout=%d)\n",
322+
dev_info(dev, "timeout %d sec (nowayout=%d)\n",
322323
wdog->timeout, nowayout);
323324

324325
return 0;

0 commit comments

Comments
 (0)