* [PATCH] clocksource: timer-prima2: Unmap region and unprepare clk obtained by of_iomap/clk_prepare_enable
@ 2017-06-28 7:50 Arvind Yadav
0 siblings, 0 replies; only message in thread
From: Arvind Yadav @ 2017-06-28 7:50 UTC (permalink / raw)
To: baohua, daniel.lezcano, tglx; +Cc: linux-arm-kernel, linux-kernel
In case of error at init time, rollback iomapping and unprepare clk.
Signed-off-by: Arvind Yadav <arvind.yadav.cs@gmail.com>
---
drivers/clocksource/timer-prima2.c | 16 ++++++++++++----
1 file changed, 12 insertions(+), 4 deletions(-)
diff --git a/drivers/clocksource/timer-prima2.c b/drivers/clocksource/timer-prima2.c
index b4122ed..46d40b3 100644
--- a/drivers/clocksource/timer-prima2.c
+++ b/drivers/clocksource/timer-prima2.c
@@ -210,13 +210,15 @@ static int __init sirfsoc_prima2_timer_init(struct device_node *np)
if (rate < PRIMA2_CLOCK_FREQ || rate % PRIMA2_CLOCK_FREQ) {
pr_err("Invalid clock rate\n");
- return -EINVAL;
+ ret = -EINVAL;
+ goto err_unprepare;
}
sirfsoc_timer_base = of_iomap(np, 0);
if (!sirfsoc_timer_base) {
pr_err("unable to map timer cpu registers\n");
- return -ENXIO;
+ ret = -ENXIO;
+ goto err_unprepare;
}
sirfsoc_timer_irq.irq = irq_of_parse_and_map(np, 0);
@@ -230,7 +232,7 @@ static int __init sirfsoc_prima2_timer_init(struct device_node *np)
ret = clocksource_register_hz(&sirfsoc_clocksource, PRIMA2_CLOCK_FREQ);
if (ret) {
pr_err("Failed to register clocksource\n");
- return ret;
+ goto err_iounmap;
}
sched_clock_register(sirfsoc_read_sched_clock, 64, PRIMA2_CLOCK_FREQ);
@@ -238,12 +240,18 @@ static int __init sirfsoc_prima2_timer_init(struct device_node *np)
ret = setup_irq(sirfsoc_timer_irq.irq, &sirfsoc_timer_irq);
if (ret) {
pr_err("Failed to setup irq\n");
- return ret;
+ goto err_iounmap;
}
sirfsoc_clockevent_init();
return 0;
+
+err_iounmap:
+ iounmap(sirfsoc_timer_base);
+err_unprepare:
+ clk_disable_unprepare(clk);
+ return ret;
}
CLOCKSOURCE_OF_DECLARE(sirfsoc_prima2_timer,
"sirf,prima2-tick", sirfsoc_prima2_timer_init);
--
1.9.1
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2017-06-28 7:51 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-06-28 7:50 [PATCH] clocksource: timer-prima2: Unmap region and unprepare clk obtained by of_iomap/clk_prepare_enable Arvind Yadav
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®