Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751540AbdF1HvK (ORCPT ); Wed, 28 Jun 2017 03:51:10 -0400 Received: from mail-pf0-f195.google.com ([209.85.192.195]:36445 "EHLO mail-pf0-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751488AbdF1HvF (ORCPT ); Wed, 28 Jun 2017 03:51:05 -0400 From: Arvind Yadav To: baohua@kernel.org, daniel.lezcano@linaro.org, tglx@linutronix.de Cc: linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Subject: [PATCH] clocksource: timer-prima2: Unmap region and unprepare clk obtained by of_iomap/clk_prepare_enable Date: Wed, 28 Jun 2017 13:20:15 +0530 Message-Id: <69a66a7f59cdee90d01e30d3f8274576c1a51e27.1498636084.git.arvind.yadav.cs@gmail.com> X-Mailer: git-send-email 1.9.1 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1768 Lines: 60 In case of error at init time, rollback iomapping and unprepare clk. Signed-off-by: Arvind Yadav --- 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