Skip to content

Commit f7bcb02

Browse files
Sam ProtsenkoWim Van Sebroeck
authored andcommitted
watchdog: s3c2410: Fix getting the optional clock
"watchdog_src" clock is optional and may not be present for some SoCs supported by this driver. Nevertheless, in case the clock is provided but some error happens during its getting, that error should be handled properly. Use devm_clk_get_optional() API for that. Also report possible errors using dev_err_probe() to handle properly -EPROBE_DEFER error (if clock provider is not ready by the time WDT probe function is executed). Fixes: e249d01 ("watchdog: s3c2410: Support separate source clock") Reported-by: kernel test robot <[email protected]> Reported-by: Dan Carpenter <[email protected]> Suggested-by: Guenter Roeck <[email protected]> Signed-off-by: Sam Protsenko <[email protected]> Reviewed-by: Guenter Roeck <[email protected]> Reviewed-by: Krzysztof Kozlowski <[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 a51f589 commit f7bcb02

File tree

1 file changed

+12
-10
lines changed

1 file changed

+12
-10
lines changed

drivers/watchdog/s3c2410_wdt.c

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -711,16 +711,18 @@ static int s3c2410wdt_probe(struct platform_device *pdev)
711711
* "watchdog_src" clock is optional; if it's not present -- just skip it
712712
* and use "watchdog" clock as both bus and source clock.
713713
*/
714-
wdt->src_clk = devm_clk_get(dev, "watchdog_src");
715-
if (!IS_ERR(wdt->src_clk)) {
716-
ret = clk_prepare_enable(wdt->src_clk);
717-
if (ret < 0) {
718-
dev_err(dev, "failed to enable source clock\n");
719-
ret = PTR_ERR(wdt->src_clk);
720-
goto err_bus_clk;
721-
}
722-
} else {
723-
wdt->src_clk = NULL;
714+
wdt->src_clk = devm_clk_get_optional(dev, "watchdog_src");
715+
if (IS_ERR(wdt->src_clk)) {
716+
dev_err_probe(dev, PTR_ERR(wdt->src_clk),
717+
"failed to get source clock\n");
718+
ret = PTR_ERR(wdt->src_clk);
719+
goto err_bus_clk;
720+
}
721+
722+
ret = clk_prepare_enable(wdt->src_clk);
723+
if (ret) {
724+
dev_err(dev, "failed to enable source clock\n");
725+
goto err_bus_clk;
724726
}
725727

726728
wdt->wdt_device.min_timeout = 1;

0 commit comments

Comments
 (0)