Skip to contentSkip to conversation

watchdog: sa11x0/pxa: fix error path of driver initialization

PATCH In review Vladimir Zapolskiy 4 participants 4 messages Dec 21, 2016 – Jan 2, 2017 Watchdog device drivers

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 watchdog: sa11x0/pxa: fix error path of driver initialization

The change corrects release of captured resources on error path, namely the clock is disabled and put if misc device registration fails and not enabled clock is not disabled now.

Fixes 6924089c488e ("watchdog: sa11x0/pxa: get rid of get_clock_tick_rate")
---
 drivers/watchdog/sa1100_wdt.c | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)
drivers/watchdog/sa1100_wdt.c +5 -3
index 8965e3f..d3be4f8 100644
@@ -188,12 +188,14 @@ static int __init sa1100dog_init(void)
 	pre_margin = oscr_freq * margin;
 
 	ret = misc_register(&sa1100dog_miscdev);
-	if (ret == 0)
+	if (ret == 0) {
 		pr_info("SA1100/PXA2xx Watchdog Timer: timer margin %d sec\n",
 			margin);
-	return ret;
-err:
+		return 0;
+	}
+
 	clk_disable_unprepare(clk);
+err:
 	clk_put(clk);
 	return ret;
 }
Signature · 1 line
2.10.2
Acked-by on v1 1/1
#1 lore raw
Quoted 3 lines · Vladimir Zapolskiy

The change corrects release of captured resources on error path, namely the clock is disabled and put if misc device registration fails and not enabled clock is not disabled now.

Cheers.

Signature · 1 line
Robert
maintainer Reviewed-by on v1 1/1
#2 lore raw
In reply to Vladimir Zapolskiy
Quoted 6 lines · Vladimir Zapolskiy

The change corrects release of captured resources on error path, namely the clock is disabled and put if misc device registration fails and not enabled clock is not disabled now.

Fixes 6924089c488e ("watchdog: sa11x0/pxa: get rid of get_clock_tick_rate")
Quoted 27 lines
---
 drivers/watchdog/sa1100_wdt.c | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)
drivers/watchdog/sa1100_wdt.c +5 -3
index 8965e3f..d3be4f8 100644
@@ -188,12 +188,14 @@ static int __init sa1100dog_init(void)
 	pre_margin = oscr_freq * margin;
 
 	ret = misc_register(&sa1100dog_miscdev);
-	if (ret == 0)
+	if (ret == 0) {
 		pr_info("SA1100/PXA2xx Watchdog Timer: timer margin %d sec\n",
 			margin);
-	return ret;
-err:
+		return 0;
+	}
+
 	clk_disable_unprepare(clk);
+err:
 	clk_put(clk);
 	return ret;
 }
Acked-by Russell King on v1 1/1
#3 lore raw
In reply to Vladimir Zapolskiy
Quoted 6 lines · Vladimir Zapolskiy

The change corrects release of captured resources on error path, namely the clock is disabled and put if misc device registration fails and not enabled clock is not disabled now.

Fixes 6924089c488e ("watchdog: sa11x0/pxa: get rid of get_clock_tick_rate")

Looks correct to me, thanks.

Quoted 29 lines
---
 drivers/watchdog/sa1100_wdt.c | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)
drivers/watchdog/sa1100_wdt.c +5 -3
index 8965e3f..d3be4f8 100644
@@ -188,12 +188,14 @@ static int __init sa1100dog_init(void)
 	pre_margin = oscr_freq * margin;
 
 	ret = misc_register(&sa1100dog_miscdev);
-	if (ret == 0)
+	if (ret == 0) {
 		pr_info("SA1100/PXA2xx Watchdog Timer: timer margin %d sec\n",
 			margin);
-	return ret;
-err:
+		return 0;
+	}
+
 	clk_disable_unprepare(clk);
+err:
 	clk_put(clk);
 	return ret;
 }
Signature · 1 line
2.10.2
Signature · 3 lines
RMK's Patch system: http://www.armlinux.org.uk/developer/patches/
FTTC broadband for 0.8mile line: currently at 9.6Mbps down 400kbps up
according to speedtest.net.