Skip to contentSkip to conversation

watchdog: renesas-wdt: Check the return value from clk_prepare_enable()

PATCH In review Fabio Estevam 3 participants 8 messages Jul 22, 2017 – Jul 23, 2017

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/2 watchdog: renesas-wdt: Check the return value from clk_prepare_enable()

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/renesas_wdt.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)
drivers/watchdog/renesas_wdt.c +5 -1
index cf61c92..ca3dc4c 100644
@@ -62,9 +62,13 @@ static int rwdt_init_timeout(struct watchdog_device *wdev)
 
 static int rwdt_start(struct watchdog_device *wdev)
 {
+	int ret;
+
 	struct rwdt_priv *priv = watchdog_get_drvdata(wdev);
 
-	clk_prepare_enable(priv->clk);
+	ret = clk_prepare_enable(priv->clk);
+	if (ret)
+		return ret;
 
 	rwdt_write(priv, priv->cks, RWTCSRA);
 	rwdt_init_timeout(wdev);
Signature · 1 line
2.7.4
#1 lore raw

PATCH 2/2 watchdog: bcm7038: Check the return value from clk_prepare_enable()

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/bcm7038_wdt.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/watchdog/bcm7038_wdt.c +3 -1
index c1b8e534..f88f546 100644
@@ -136,7 +136,9 @@ static int bcm7038_wdt_probe(struct platform_device *pdev)
 	wdt->clk = devm_clk_get(dev, NULL);
 	/* If unable to get clock, use default frequency */
 	if (!IS_ERR(wdt->clk)) {
-		clk_prepare_enable(wdt->clk);
+		err = clk_prepare_enable(wdt->clk);
+		if (err)
+			return err;
 		wdt->rate = clk_get_rate(wdt->clk);
 		/* Prevent divide-by-zero exception */
 		if (!wdt->rate)
Signature · 1 line
2.7.4
maintainer Reviewed-by on v1 2/2
#2 lore raw

Re: [PATCH 2/2] watchdog: bcm7038: Check the return value from clk_prepare_enable()

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.

Quoted 9 lines
---
 drivers/watchdog/bcm7038_wdt.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/watchdog/bcm7038_wdt.c +0 -0
index c1b8e534..f88f546 100644

drivers/watchdog/bcm7038_wdt.c static int bcm7038_wdt_probe(struct platform_device *pdev) · line 139

Quoted 5 lines
drivers/watchdog/bcm7038_wdt.c +1 -1
@@ -136,7 +136,9 @@ static int bcm7038_wdt_probe(struct platform_device *pdev)
 	wdt->clk = devm_clk_get(dev, NULL);
 	/* If unable to get clock, use default frequency */
 	if (!IS_ERR(wdt->clk)) {
-		clk_prepare_enable(wdt->clk);
+		err = clk_prepare_enable(wdt->clk);

One of those situations where devm_clk_prepare_enable() would be really useful.

Wonder if it would make sense introduce subsystem specific functions, such as devm_watchdog_clk_prepare_enable(). That would at least be better than devm_add_action() in each driver.

Guenter

Quoted 8 lines
drivers/watchdog/bcm7038_wdt.c +2 -0
+		if (err)
+			return err;
 		wdt->rate = clk_get_rate(wdt->clk);
 		/* Prevent divide-by-zero exception */
 		if (!wdt->rate)
Signature · 1 line
2.7.4
#3 lore raw
In reply to Fabio Estevam
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.

True. Yet, I have a patch in preparation which fully switches to RuntimePM which will make manual clk handling superfluous.

I'd prefer to drop this patch because I'd need to revert it anyhow.

maintainer
#4 lore raw
Quoted 11 lines · Wolfram Sang
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.

True. Yet, I have a patch in preparation which fully switches to RuntimePM which will make manual clk handling superfluous.

It won't need clk_prepare_enable() anymore ?

Guenter

#5 lore raw
Quoted 2 lines

It won't need clk_prepare_enable() anymore ?

Nope, RuntimePM does all the clock handling.

maintainer
#6 lore raw
Quoted 5 lines · Wolfram Sang
Quoted 2 lines

It won't need clk_prepare_enable() anymore ?

Nope, RuntimePM does all the clock handling.

What if runtime PM is disabled ?

Thanks,
Guenter

#7 lore raw
Quoted 7 lines · Guenter Roeck
Quoted 5 lines · Wolfram Sang
Quoted 2 lines

It won't need clk_prepare_enable() anymore ?

Nope, RuntimePM does all the clock handling.

What if runtime PM is disabled ?

PM is selected by RENESAS_ARCH.