Commit 522ed95c authored by Shawn Lin's avatar Shawn Lin Committed by Daniel Lezcano

clocksource/drivers/rockchip: Add err handle for rk_timer_init

Currently rockchip_timer doesn't do some basic cleanup work when
failing to init the timer. Let's add err handle routine to deal
with all the err cases.
Signed-off-by: default avatarShawn Lin <shawn.lin@rock-chips.com>
Signed-off-by: default avatarDaniel Lezcano <daniel.lezcano@linaro.org>
parent e392d603
...@@ -122,23 +122,23 @@ static void __init rk_timer_init(struct device_node *np) ...@@ -122,23 +122,23 @@ static void __init rk_timer_init(struct device_node *np)
pclk = of_clk_get_by_name(np, "pclk"); pclk = of_clk_get_by_name(np, "pclk");
if (IS_ERR(pclk)) { if (IS_ERR(pclk)) {
pr_err("Failed to get pclk for '%s'\n", TIMER_NAME); pr_err("Failed to get pclk for '%s'\n", TIMER_NAME);
return; goto out_unmap;
} }
if (clk_prepare_enable(pclk)) { if (clk_prepare_enable(pclk)) {
pr_err("Failed to enable pclk for '%s'\n", TIMER_NAME); pr_err("Failed to enable pclk for '%s'\n", TIMER_NAME);
return; goto out_unmap;
} }
timer_clk = of_clk_get_by_name(np, "timer"); timer_clk = of_clk_get_by_name(np, "timer");
if (IS_ERR(timer_clk)) { if (IS_ERR(timer_clk)) {
pr_err("Failed to get timer clock for '%s'\n", TIMER_NAME); pr_err("Failed to get timer clock for '%s'\n", TIMER_NAME);
return; goto out_timer_clk;
} }
if (clk_prepare_enable(timer_clk)) { if (clk_prepare_enable(timer_clk)) {
pr_err("Failed to enable timer clock\n"); pr_err("Failed to enable timer clock\n");
return; goto out_timer_clk;
} }
bc_timer.freq = clk_get_rate(timer_clk); bc_timer.freq = clk_get_rate(timer_clk);
...@@ -146,7 +146,7 @@ static void __init rk_timer_init(struct device_node *np) ...@@ -146,7 +146,7 @@ static void __init rk_timer_init(struct device_node *np)
irq = irq_of_parse_and_map(np, 0); irq = irq_of_parse_and_map(np, 0);
if (!irq) { if (!irq) {
pr_err("Failed to map interrupts for '%s'\n", TIMER_NAME); pr_err("Failed to map interrupts for '%s'\n", TIMER_NAME);
return; goto out_irq;
} }
ce->name = TIMER_NAME; ce->name = TIMER_NAME;
...@@ -164,10 +164,19 @@ static void __init rk_timer_init(struct device_node *np) ...@@ -164,10 +164,19 @@ static void __init rk_timer_init(struct device_node *np)
ret = request_irq(irq, rk_timer_interrupt, IRQF_TIMER, TIMER_NAME, ce); ret = request_irq(irq, rk_timer_interrupt, IRQF_TIMER, TIMER_NAME, ce);
if (ret) { if (ret) {
pr_err("Failed to initialize '%s': %d\n", TIMER_NAME, ret); pr_err("Failed to initialize '%s': %d\n", TIMER_NAME, ret);
return; goto out_irq;
} }
clockevents_config_and_register(ce, bc_timer.freq, 1, UINT_MAX); clockevents_config_and_register(ce, bc_timer.freq, 1, UINT_MAX);
return;
out_irq:
clk_disable_unprepare(timer_clk);
out_timer_clk:
clk_disable_unprepare(pclk);
out_unmap:
iounmap(bc_timer.base);
} }
CLOCKSOURCE_OF_DECLARE(rk_timer, "rockchip,rk3288-timer", rk_timer_init); CLOCKSOURCE_OF_DECLARE(rk_timer, "rockchip,rk3288-timer", rk_timer_init);
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment