Skip to content

Commit e0e0ee0

Browse files
Uwe Kleine-KönigWim Van Sebroeck
authored andcommitted
watchdog: s3c2410_wdt: Simplify using dev_err_probe()
Make use of dev_err_probe() also for error paths that don't have to handle -EPROBE_DEFER. While the code handing -EPROBE_DEFER isn't used for these error paths, it still simpler as it cares for pretty printing the error code and usually needs one code line less as it combines message emitting and error returning. This also unifies the format of the error messages. Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de> Reviewed-by: Guenter Roeck <linux@roeck-us.net> Link: https://lore.kernel.org/r/20230307065603.2253054-3-u.kleine-koenig@pengutronix.de [groeck: Split long line to avoid checkpatch warning] Signed-off-by: Guenter Roeck <linux@roeck-us.net> Signed-off-by: Wim Van Sebroeck <wim@linux-watchdog.org>
1 parent 16d477a commit e0e0ee0

1 file changed

Lines changed: 11 additions & 19 deletions

File tree

drivers/watchdog/s3c2410_wdt.c

Lines changed: 11 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -601,10 +601,8 @@ s3c2410_get_wdt_drv_data(struct platform_device *pdev, struct s3c2410_wdt *wdt)
601601

602602
err = of_property_read_u32(dev->of_node,
603603
"samsung,cluster-index", &index);
604-
if (err) {
605-
dev_err(dev, "failed to get cluster index\n");
606-
return -EINVAL;
607-
}
604+
if (err)
605+
return dev_err_probe(dev, -EINVAL, "failed to get cluster index\n");
608606

609607
switch (index) {
610608
case 0:
@@ -615,8 +613,7 @@ s3c2410_get_wdt_drv_data(struct platform_device *pdev, struct s3c2410_wdt *wdt)
615613
&drv_data_exynosautov9_cl1;
616614
break;
617615
default:
618-
dev_err(dev, "wrong cluster index: %u\n", index);
619-
return -EINVAL;
616+
return dev_err_probe(dev, -EINVAL, "wrong cluster index: %u\n", index);
620617
}
621618
}
622619
#endif
@@ -653,10 +650,9 @@ static int s3c2410wdt_probe(struct platform_device *pdev)
653650
if (wdt->drv_data->quirks & QUIRKS_HAVE_PMUREG) {
654651
wdt->pmureg = syscon_regmap_lookup_by_phandle(dev->of_node,
655652
"samsung,syscon-phandle");
656-
if (IS_ERR(wdt->pmureg)) {
657-
dev_err(dev, "syscon regmap lookup failed.\n");
658-
return PTR_ERR(wdt->pmureg);
659-
}
653+
if (IS_ERR(wdt->pmureg))
654+
return dev_err_probe(dev, PTR_ERR(wdt->pmureg),
655+
"syscon regmap lookup failed.\n");
660656
}
661657

662658
wdt_irq = platform_get_irq(pdev, 0);
@@ -694,21 +690,17 @@ static int s3c2410wdt_probe(struct platform_device *pdev)
694690
if (ret) {
695691
ret = s3c2410wdt_set_heartbeat(&wdt->wdt_device,
696692
S3C2410_WATCHDOG_DEFAULT_TIME);
697-
if (ret == 0) {
693+
if (ret == 0)
698694
dev_warn(dev, "tmr_margin value out of range, default %d used\n",
699695
S3C2410_WATCHDOG_DEFAULT_TIME);
700-
} else {
701-
dev_err(dev, "failed to use default timeout\n");
702-
return ret;
703-
}
696+
else
697+
return dev_err_probe(dev, ret, "failed to use default timeout\n");
704698
}
705699

706700
ret = devm_request_irq(dev, wdt_irq, s3c2410wdt_irq, 0,
707701
pdev->name, pdev);
708-
if (ret != 0) {
709-
dev_err(dev, "failed to install irq (%d)\n", ret);
710-
return ret;
711-
}
702+
if (ret != 0)
703+
return dev_err_probe(dev, ret, "failed to install irq (%d)\n", ret);
712704

713705
watchdog_set_nowayout(&wdt->wdt_device, nowayout);
714706
watchdog_set_restart_priority(&wdt->wdt_device, 128);

0 commit comments

Comments
 (0)