mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Daniel Lezcano <daniel.lezcano@linaro.org>
To: tglx@linutronix.de
Cc: Shawn Lin <shawn.lin@rock-chips.com>,
	Heiko Stuebner <heiko@sntech.de>,
	linux-kernel@vger.kernel.org (open list:CLOCKSOURCE, CLOC...),
	linux-arm-kernel@lists.infradead.org (moderated
	list:ARM/Rockchip SoC...),
	linux-rockchip@lists.infradead.org (open list:ARM/Rockchip
	SoC...)
Subject: [PATCH 2/9] clocksource/drivers/rockchip: Add err handle for rk_timer_init
Date: Thu, 25 Feb 2016 14:37:10 +0100	[thread overview]
Message-ID: <1456407438-6131-2-git-send-email-daniel.lezcano@linaro.org> (raw)
In-Reply-To: <1456407438-6131-1-git-send-email-daniel.lezcano@linaro.org>

From: Shawn Lin <shawn.lin@rock-chips.com>

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: Shawn Lin <shawn.lin@rock-chips.com>
Signed-off-by: Daniel Lezcano <daniel.lezcano@linaro.org>
---
 drivers/clocksource/rockchip_timer.c | 21 +++++++++++++++------
 1 file changed, 15 insertions(+), 6 deletions(-)

diff --git a/drivers/clocksource/rockchip_timer.c b/drivers/clocksource/rockchip_timer.c
index 8c77a52..b991b28 100644
--- a/drivers/clocksource/rockchip_timer.c
+++ b/drivers/clocksource/rockchip_timer.c
@@ -122,23 +122,23 @@ static void __init rk_timer_init(struct device_node *np)
 	pclk = of_clk_get_by_name(np, "pclk");
 	if (IS_ERR(pclk)) {
 		pr_err("Failed to get pclk for '%s'\n", TIMER_NAME);
-		return;
+		goto out_unmap;
 	}
 
 	if (clk_prepare_enable(pclk)) {
 		pr_err("Failed to enable pclk for '%s'\n", TIMER_NAME);
-		return;
+		goto out_unmap;
 	}
 
 	timer_clk = of_clk_get_by_name(np, "timer");
 	if (IS_ERR(timer_clk)) {
 		pr_err("Failed to get timer clock for '%s'\n", TIMER_NAME);
-		return;
+		goto out_timer_clk;
 	}
 
 	if (clk_prepare_enable(timer_clk)) {
 		pr_err("Failed to enable timer clock\n");
-		return;
+		goto out_timer_clk;
 	}
 
 	bc_timer.freq = clk_get_rate(timer_clk);
@@ -146,7 +146,7 @@ static void __init rk_timer_init(struct device_node *np)
 	irq = irq_of_parse_and_map(np, 0);
 	if (!irq) {
 		pr_err("Failed to map interrupts for '%s'\n", TIMER_NAME);
-		return;
+		goto out_irq;
 	}
 
 	ce->name = TIMER_NAME;
@@ -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);
 	if (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);
+
+	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);
-- 
1.9.1

  reply	other threads:[~2016-02-25 13:37 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-02-25 13:26 [PULL] : clockevents for 4.6 Daniel Lezcano
2016-02-25 13:37 ` [PATCH 1/9] clocksource/drivers/arm_arch_timer: Enable and verify MMIO access Daniel Lezcano
2016-02-25 13:37   ` Daniel Lezcano [this message]
2016-02-25 13:37   ` [PATCH 3/9] clocksource/drivers/lpc32xx: Don't use the prescaler counter for clockevents Daniel Lezcano
2016-02-25 13:37   ` [PATCH 4/9] clocksource/drivers/lpc32xx: Support periodic mode Daniel Lezcano
2016-02-25 13:37   ` [PATCH 5/9] clocksource/drivers/lpc32xx: Support timer-based ARM delay Daniel Lezcano
2016-02-25 13:37   ` [PATCH 6/9] clocksource/drivers/arm_global_timer: Register delay timer Daniel Lezcano
2016-02-25 13:37   ` [PATCH 7/9] clockevents/drivers/arm_arch_timer: Implement ->set_state_oneshot_stopped() Daniel Lezcano
2016-02-25 13:37   ` [PATCH 8/9] clockevents/drivers/arm_global_timer: " Daniel Lezcano
2016-02-26  9:43     ` Jisheng Zhang
2016-02-25 13:37   ` [PATCH 9/9] clockevents/drivers/exynos_mct: " Daniel Lezcano

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1456407438-6131-2-git-send-email-daniel.lezcano@linaro.org \
    --to=daniel.lezcano@linaro.org \
    --cc=heiko@sntech.de \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-rockchip@lists.infradead.org \
    --cc=shawn.lin@rock-chips.com \
    --cc=tglx@linutronix.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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®