All of lore.kernel.org
 help / color / mirror / Atom feed
From: Arvind Yadav <arvind.yadav.cs@gmail.com>
To: linus.walleij@linaro.org, daniel.lezcano@linaro.org, tglx@linutronix.de
Cc: linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org
Subject: [PATCH] clocksource: timer-u300: Unmap region and unprepare clk obtained by of_iomap/clk_prepare_enable.
Date: Wed, 28 Jun 2017 13:08:16 +0530	[thread overview]
Message-ID: <4f413218d177cde9760f222329fde91b56797843.1498635400.git.arvind.yadav.cs@gmail.com> (raw)

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-u300.c | 21 +++++++++++++++------
 1 file changed, 15 insertions(+), 6 deletions(-)

diff --git a/drivers/clocksource/timer-u300.c b/drivers/clocksource/timer-u300.c
index 704e40c..e3b29ae 100644
--- a/drivers/clocksource/timer-u300.c
+++ b/drivers/clocksource/timer-u300.c
@@ -376,19 +376,22 @@ static int __init u300_timer_init_of(struct device_node *np)
 	irq = irq_of_parse_and_map(np, 2);
 	if (!irq) {
 		pr_err("no IRQ for system timer\n");
-		return -EINVAL;
+		ret = -EINVAL;
+		goto err_iounmap;
 	}
 
 	pr_info("U300 GP1 timer @ base: %p, IRQ: %u\n", u300_timer_base, irq);
 
 	/* Clock the interrupt controller */
 	clk = of_clk_get(np, 0);
-	if (IS_ERR(clk))
-		return PTR_ERR(clk);
+	if (IS_ERR(clk)) {
+		ret = PTR_ERR(clk);
+		goto err_iounmap;
+	}
 
 	ret = clk_prepare_enable(clk);
 	if (ret)
-		return ret;
+		goto err_iounmap;
 
 	rate = clk_get_rate(clk);
 
@@ -422,7 +425,7 @@ static int __init u300_timer_init_of(struct device_node *np)
 	/* Set up the IRQ handler */
 	ret = setup_irq(irq, &u300_timer_irq);
 	if (ret)
-		return ret;
+		goto err_unprepare;
 
 	/* Reset the General Purpose timer 2 */
 	writel(U300_TIMER_APP_RGPT2_TIMER_RESET,
@@ -444,7 +447,7 @@ static int __init u300_timer_init_of(struct device_node *np)
 				    "GPT2", rate, 300, 32, clocksource_mmio_readl_up);
 	if (ret) {
 		pr_err("timer: failed to initialize U300 clock source\n");
-		return ret;
+		goto err_unprepare;
 	}
 
 	/* Configure and register the clockevent */
@@ -456,6 +459,12 @@ static int __init u300_timer_init_of(struct device_node *np)
 	 * used by hrtimers!
 	 */
 	return 0;
+
+err_unprepare:
+	clk_disable_unprepare(clk);
+err_iounmap:
+	iounmap(u300_timer_base);
+	return ret;
 }
 
 CLOCKSOURCE_OF_DECLARE(u300_timer, "stericsson,u300-apptimer",
-- 
1.9.1

WARNING: multiple messages have this Message-ID (diff)
From: arvind.yadav.cs@gmail.com (Arvind Yadav)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH] clocksource: timer-u300: Unmap region and unprepare clk obtained by of_iomap/clk_prepare_enable.
Date: Wed, 28 Jun 2017 13:08:16 +0530	[thread overview]
Message-ID: <4f413218d177cde9760f222329fde91b56797843.1498635400.git.arvind.yadav.cs@gmail.com> (raw)

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-u300.c | 21 +++++++++++++++------
 1 file changed, 15 insertions(+), 6 deletions(-)

diff --git a/drivers/clocksource/timer-u300.c b/drivers/clocksource/timer-u300.c
index 704e40c..e3b29ae 100644
--- a/drivers/clocksource/timer-u300.c
+++ b/drivers/clocksource/timer-u300.c
@@ -376,19 +376,22 @@ static int __init u300_timer_init_of(struct device_node *np)
 	irq = irq_of_parse_and_map(np, 2);
 	if (!irq) {
 		pr_err("no IRQ for system timer\n");
-		return -EINVAL;
+		ret = -EINVAL;
+		goto err_iounmap;
 	}
 
 	pr_info("U300 GP1 timer @ base: %p, IRQ: %u\n", u300_timer_base, irq);
 
 	/* Clock the interrupt controller */
 	clk = of_clk_get(np, 0);
-	if (IS_ERR(clk))
-		return PTR_ERR(clk);
+	if (IS_ERR(clk)) {
+		ret = PTR_ERR(clk);
+		goto err_iounmap;
+	}
 
 	ret = clk_prepare_enable(clk);
 	if (ret)
-		return ret;
+		goto err_iounmap;
 
 	rate = clk_get_rate(clk);
 
@@ -422,7 +425,7 @@ static int __init u300_timer_init_of(struct device_node *np)
 	/* Set up the IRQ handler */
 	ret = setup_irq(irq, &u300_timer_irq);
 	if (ret)
-		return ret;
+		goto err_unprepare;
 
 	/* Reset the General Purpose timer 2 */
 	writel(U300_TIMER_APP_RGPT2_TIMER_RESET,
@@ -444,7 +447,7 @@ static int __init u300_timer_init_of(struct device_node *np)
 				    "GPT2", rate, 300, 32, clocksource_mmio_readl_up);
 	if (ret) {
 		pr_err("timer: failed to initialize U300 clock source\n");
-		return ret;
+		goto err_unprepare;
 	}
 
 	/* Configure and register the clockevent */
@@ -456,6 +459,12 @@ static int __init u300_timer_init_of(struct device_node *np)
 	 * used by hrtimers!
 	 */
 	return 0;
+
+err_unprepare:
+	clk_disable_unprepare(clk);
+err_iounmap:
+	iounmap(u300_timer_base);
+	return ret;
 }
 
 CLOCKSOURCE_OF_DECLARE(u300_timer, "stericsson,u300-apptimer",
-- 
1.9.1

             reply	other threads:[~2017-06-28  7:39 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-06-28  7:38 Arvind Yadav [this message]
2017-06-28  7:38 ` [PATCH] clocksource: timer-u300: Unmap region and unprepare clk obtained by of_iomap/clk_prepare_enable Arvind Yadav
2017-06-28 15:07 ` Linus Walleij
2017-06-28 15:07   ` Linus Walleij
2017-06-28 15:59 ` Daniel Lezcano
2017-06-28 15:59   ` 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=4f413218d177cde9760f222329fde91b56797843.1498635400.git.arvind.yadav.cs@gmail.com \
    --to=arvind.yadav.cs@gmail.com \
    --cc=daniel.lezcano@linaro.org \
    --cc=linus.walleij@linaro.org \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.