Skip to contentSkip to conversation

watchdog: imx2_wdt: Check for clk_prepare_enable() error

PATCH In review Fabio Estevam 2 participants 4 messages Jun 22, 2015

Subsystems (2)
lore
Share & tools
lore

Fabio Estevam

author reviewer
#0 lore raw

PATCH 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
index 2acdd17..add1fa0 100644
@@ -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
author reviewer
#1 lore raw

PATCH 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
index add1fa0..0bb1a1d 100644
@@ -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
maintainer Reviewed-by on v1 2/2
#2 lore raw

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 acquired wdev->clk clock on error path.

--
To unsubscribe from this list: send the line "unsubscribe linux-watchdog" in