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: 70390 Delivered-To: patch@linaro.org Received: by 10.140.28.4 with SMTP id 4csp715446qgy; Sat, 18 Jun 2016 05:54:29 -0700 (PDT) X-Received: by 10.107.5.12 with SMTP id 12mr10383523iof.160.1466254469225; Sat, 18 Jun 2016 05:54:29 -0700 (PDT) Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 2si19091613pfh.24.2016.06.18.05.54.28; Sat, 18 Jun 2016 05:54:29 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751361AbcFRMy1 (ORCPT + 30 others); Sat, 18 Jun 2016 08:54:27 -0400 Received: from mail-wm0-f49.google.com ([74.125.82.49]:38354 "EHLO mail-wm0-f49.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750879AbcFRMyZ (ORCPT ); Sat, 18 Jun 2016 08:54:25 -0400 Received: by mail-wm0-f49.google.com with SMTP id r201so3879742wme.1 for ; Sat, 18 Jun 2016 05:54:25 -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=lfAAmB28q+HpUvZcrf9A7Xik1GSUn/BxSpmiwF6AocEjzIcoNA2bqmKEav2tflJmVR m+i+rMv9HMII9AFqkGSkC4oYD15EUm4t6+r8pt+1MEWyeJma343361BYNYewypQpIOqH ctvdnsOLq+7fQPXtyHk84dNthIHvx4KcCx7HKfxt0DkeU9FQmmHkQUnMYs9YzWdHgvNL M1MUyPNFTsC4yTaehyedAps0HhEiE9l7x0vF1SP14KNn/3OU5aalHvzqEWe5xQgCh7Fk xzdrX5y4bp8hBL7AV9v8elRWTo2XHNSUYPcrU/vDT+0WZdmlgVmlBr3OJQr123FJ0j+Q LObA== X-Gm-Message-State: ALyK8tKXM/QyuZAmXS1D2BtfyiGLHeX1yUdUzrUK4Hb/oX4uVQDsFT9Q4DHrrp4RhIUUITK5 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 Cc: linux-kernel@vger.kernel.org, linux-rockchip@lists.infradead.org, linux-arm-kernel@lists.infradead.org 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> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 --- drivers/clocksource/rockchip_timer.c | 35 +++++++++++++++++++++-------------- 1 file changed, 21 insertions(+), 14 deletions(-) -- 1.9.1 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);