From patchwork Sat Jun 18 12:54:07 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Lezcano X-Patchwork-Id: 9185565 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id AFA146075F for ; Sat, 18 Jun 2016 12:54:51 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 9FEEE25E13 for ; Sat, 18 Jun 2016 12:54:51 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 94A85262AE; Sat, 18 Jun 2016 12:54:51 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-4.1 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_MED, T_DKIM_INVALID autolearn=unavailable version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.9]) (using TLSv1.2 with cipher AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 1B30025E13 for ; Sat, 18 Jun 2016 12:54:51 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1bEFly-0003xG-O4; Sat, 18 Jun 2016 12:54:50 +0000 Received: from mail-wm0-x22f.google.com ([2a00:1450:400c:c09::22f]) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1bEFlp-0003u7-0H for linux-rockchip@lists.infradead.org; Sat, 18 Jun 2016 12:54:43 +0000 Received: by mail-wm0-x22f.google.com with SMTP id k184so2694152wme.1 for ; Sat, 18 Jun 2016 05:54:20 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=aG2dYffet9Gj2Nj2NRCcCzQ5aSZo6ZC+R7QXk9b8Nvs=; b=IelcLjw5wkIwSuBpkUYDbSv3mbg1XMyAGo2NWt0RjyQtSE5xno7f37jQb35rB4vUPW 87W/oOcJhp/p1PozH0+l9Dxr1ZBhVYHwqm44WkqVLya/nHRnMUZHj3eio55EreN0miFv 0SfsMCc2fwVNNu7zocWTpFnZRwnFTh+jpGCKk= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=aG2dYffet9Gj2Nj2NRCcCzQ5aSZo6ZC+R7QXk9b8Nvs=; b=FkPwlkDffF/JOMNtpv1iePYlab3tXVB5puxOt2a13j3HCv1vvcqfEuWpM2ua8zWplU b/iW/Xr56gwRDLbI5+MpweAcIifs7MCmmLKTF62ch+LPoUXIpscounDBMYRdnpxORDot I4z0tL0ULoGsP5PUW/6IfOgkTuXwXvhPbO8908WqbBYadVWQ2N/vqUAZa67ddRNjF1Mr tuVs6FetFMoV8HuHgyuMVX/AB6ORQYfCmlRiq2wIThbMYPyEB5/rRm/jzZvILrr4mRRc KWVsMsWFvVvOF0St/v6ZiYe/2Tgn3Ktd2gge0UpJJxf6yWoHB25YqswGRbKzEpBCQKO5 NkSg== X-Gm-Message-State: ALyK8tKy/NTENt33rp75nmR30cpfZWxng8afIMQ+AtHrcZHl1b6bNYYK3sD1dENQnAXOKNEM X-Received: by 10.28.165.206 with SMTP id o197mr3195695wme.102.1466254459079; Sat, 18 Jun 2016 05:54:19 -0700 (PDT) Received: from localhost.localdomain (sju31-1-78-210-255-2.fbx.proxad.net. [78.210.255.2]) by smtp.gmail.com with ESMTPSA id u4sm53605670wjz.4.2016.06.18.05.54.17 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Sat, 18 Jun 2016 05:54:17 -0700 (PDT) From: Daniel Lezcano To: daniel.lezcano@linaro.org, tglx@linutronix.de, heiko@sntech.de Subject: [PATCH V3] clocksource/drivers/rockchip_timer: Convert init function to return error Date: Sat, 18 Jun 2016 14:54:07 +0200 Message-Id: <1466254447-2420-1-git-send-email-daniel.lezcano@linaro.org> X-Mailer: git-send-email 1.9.1 In-Reply-To: <2572341.0UcvQ6PvRt@diego> References: <2572341.0UcvQ6PvRt@diego> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20160618_055441_213756_51B6F2CC X-CRM114-Status: GOOD ( 13.22 ) X-BeenThere: linux-rockchip@lists.infradead.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: Upstream kernel work for Rockchip platforms List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: linux-rockchip@lists.infradead.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org MIME-Version: 1.0 Sender: "Linux-rockchip" Errors-To: linux-rockchip-bounces+patchwork-linux-rockchip=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP The init functions do not return any error. They behave as the following: - panic, thus leading to a kernel crash while another timer may work and make the system boot up correctly or - print an error and let the caller unaware if the state of the system Change that by converting the init functions to return an error conforming to the CLOCKSOURCE_OF_RET prototype. Proper error handling (rollback, errno value) will be changed later case by case, thus this change just return back an error or success in the init function. Signed-off-by: Daniel Lezcano Reviewed-by: Heiko Stuebner Tested-by: Heiko Stuebner --- drivers/clocksource/rockchip_timer.c | 35 +++++++++++++++++++++-------------- 1 file changed, 21 insertions(+), 14 deletions(-) diff --git a/drivers/clocksource/rockchip_timer.c b/drivers/clocksource/rockchip_timer.c index a3f22b0..85aee69 100644 --- a/drivers/clocksource/rockchip_timer.c +++ b/drivers/clocksource/rockchip_timer.c @@ -113,38 +113,42 @@ static irqreturn_t rk_timer_interrupt(int irq, void *dev_id) return IRQ_HANDLED; } -static void __init rk_timer_init(struct device_node *np, u32 ctrl_reg) +static int __init rk_timer_init(struct device_node *np, u32 ctrl_reg) { struct clock_event_device *ce = &bc_timer.ce; struct clk *timer_clk; struct clk *pclk; - int ret, irq; + int ret = -EINVAL, irq; bc_timer.base = of_iomap(np, 0); if (!bc_timer.base) { pr_err("Failed to get base address for '%s'\n", TIMER_NAME); - return; + return -ENXIO; } bc_timer.ctrl = bc_timer.base + ctrl_reg; pclk = of_clk_get_by_name(np, "pclk"); if (IS_ERR(pclk)) { + ret = PTR_ERR(pclk); pr_err("Failed to get pclk for '%s'\n", TIMER_NAME); goto out_unmap; } - if (clk_prepare_enable(pclk)) { + ret = clk_prepare_enable(pclk); + if (ret) { pr_err("Failed to enable pclk for '%s'\n", TIMER_NAME); goto out_unmap; } timer_clk = of_clk_get_by_name(np, "timer"); if (IS_ERR(timer_clk)) { + ret = PTR_ERR(timer_clk); pr_err("Failed to get timer clock for '%s'\n", TIMER_NAME); goto out_timer_clk; } - if (clk_prepare_enable(timer_clk)) { + ret = clk_prepare_enable(timer_clk); + if (ret) { pr_err("Failed to enable timer clock\n"); goto out_timer_clk; } @@ -153,6 +157,7 @@ static void __init rk_timer_init(struct device_node *np, u32 ctrl_reg) irq = irq_of_parse_and_map(np, 0); if (!irq) { + ret = -EINVAL; pr_err("Failed to map interrupts for '%s'\n", TIMER_NAME); goto out_irq; } @@ -178,7 +183,7 @@ static void __init rk_timer_init(struct device_node *np, u32 ctrl_reg) clockevents_config_and_register(ce, bc_timer.freq, 1, UINT_MAX); - return; + return 0; out_irq: clk_disable_unprepare(timer_clk); @@ -186,19 +191,21 @@ out_timer_clk: clk_disable_unprepare(pclk); out_unmap: iounmap(bc_timer.base); + + return ret; } -static void __init rk3288_timer_init(struct device_node *np) +static int __init rk3288_timer_init(struct device_node *np) { - rk_timer_init(np, TIMER_CONTROL_REG3288); + return rk_timer_init(np, TIMER_CONTROL_REG3288); } -static void __init rk3399_timer_init(struct device_node *np) +static int __init rk3399_timer_init(struct device_node *np) { - rk_timer_init(np, TIMER_CONTROL_REG3399); + return rk_timer_init(np, TIMER_CONTROL_REG3399); } -CLOCKSOURCE_OF_DECLARE(rk3288_timer, "rockchip,rk3288-timer", - rk3288_timer_init); -CLOCKSOURCE_OF_DECLARE(rk3399_timer, "rockchip,rk3399-timer", - rk3399_timer_init); +CLOCKSOURCE_OF_DECLARE_RET(rk3288_timer, "rockchip,rk3288-timer", + rk3288_timer_init); +CLOCKSOURCE_OF_DECLARE_RET(rk3399_timer, "rockchip,rk3399-timer", + rk3399_timer_init);