watchdog: imx2_wdt: Check for clk_prepare_enable() error
Subsystems (2)
Fabio Estevam
reviewerPATCH 1/2 watchdog: imx2_wdt: Check for clk_prepare_enable() error
From: Fabio Estevam <[email protected]>
clk_prepare_enable() may fail, so we should better check its return value and propagate it in the case of error.
--- drivers/watchdog/imx2_wdt.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-)
drivers/watchdog/imx2_wdt.c +7 -2
@@ -260,7 +260,9 @@ static int __init imx2_wdt_probe(struct platform_device *pdev) wdog->max_timeout =IMX2_WDT_MAX_TIME ; wdog->parent = &pdev->dev; -clk_prepare_enable (wdev->clk); + ret =clk_prepare_enable (wdev->clk); +if (ret) +return ret;regmap_read (wdev->regmap,IMX2_WDT_WRSR , &val); wdog->bootstatus = val &IMX2_WDT_WRSR_TOUT ?WDIOF_CARDRESET :0 ;
@@ -365,8 +367,11 @@ static int imx2_wdt_resume(struct device *dev) {struct watchdog_device *wdog =dev_get_drvdata (dev);struct imx2_wdt_device *wdev =watchdog_get_drvdata (wdog); +int ret; -clk_prepare_enable (wdev->clk); + ret =clk_prepare_enable (wdev->clk); +if (ret) +return ret;if (watchdog_active (wdog) && !imx2_wdt_is_running (wdev)) {/*
Signature · 4 lines
1.9.1 -- To unsubscribe from this list: send the line "unsubscribe linux-watchdog" in
Fabio Estevam
reviewerPATCH 2/2 watchdog: imx2_wdt: Disable previously acquired clock on error path
From: Fabio Estevam <[email protected]>
If watchdog_register_device() fails we should disable the previously acquired wdev->clk clock on error path.
--- drivers/watchdog/imx2_wdt.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-)
drivers/watchdog/imx2_wdt.c +5 -1
@@ -291,7 +291,7 @@ static int __init imx2_wdt_probe(struct platform_device *pdev) ret =watchdog_register_device (wdog);if (ret) {dev_err (&pdev->dev,"cannot register watchdog device\n" ); -return ret; + goto disable_clk; } wdev->restart_handler.notifier_call = imx2_restart_handler;
@@ -304,6 +304,10 @@ static int __init imx2_wdt_probe(struct platform_device *pdev) wdog->timeout, nowayout);return 0 ; + +disable_clk: +clk_disable_unprepare (wdev->clk); +return ret; } static int __exit imx2_wdt_remove(struct platform_device *pdev)
Signature · 4 lines
1.9.1 -- To unsubscribe from this list: send the line "unsubscribe linux-watchdog" in
Re: [2/2] watchdog: imx2_wdt: Disable previously acquired clock on error path
Quoted 6 lines · Fabio Estevam
From: Fabio Estevam <[email protected]>
If
watchdog_register_device()fails we should disable the previously acquiredwdev->clkclock on error path.Signed-off-by Fabio Estevam <[email protected]>
--
To unsubscribe from this list: send the line "unsubscribe linux-watchdog" in
Quoted 6 lines · Fabio Estevam
From: Fabio Estevam <[email protected]>
clk_prepare_enable()may fail, so we should better check its return value and propagate it in the case of error.Signed-off-by Fabio Estevam <[email protected]>
--
To unsubscribe from this list: send the line "unsubscribe linux-watchdog" in