From patchwork Thu Jun 16 21:26:22 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Lezcano X-Patchwork-Id: 70209 Delivered-To: patch@linaro.org Received: by 10.140.28.4 with SMTP id 4csp464377qgy; Thu, 16 Jun 2016 14:28:33 -0700 (PDT) X-Received: by 10.66.75.72 with SMTP id a8mr7246961paw.99.1466112513098; Thu, 16 Jun 2016 14:28:33 -0700 (PDT) Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id u4si20618946pal.94.2016.06.16.14.28.32; Thu, 16 Jun 2016 14:28:33 -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 S1755106AbcFPV2J (ORCPT + 30 others); Thu, 16 Jun 2016 17:28:09 -0400 Received: from mail-wm0-f48.google.com ([74.125.82.48]:34910 "EHLO mail-wm0-f48.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754466AbcFPV2F (ORCPT ); Thu, 16 Jun 2016 17:28:05 -0400 Received: by mail-wm0-f48.google.com with SMTP id v199so207641089wmv.0 for ; Thu, 16 Jun 2016 14:28:04 -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=DmbGzxDP/oVE26kezhTisBaywvmhWjn6VdxOWXD9u8A=; b=fY6tV0Zx91xdbWxxkyBXebeopgpRcBEPqdCxIJxxcKLF2HIEOwTmrG0Zubr5twzTkI GGxKrRsMRhspIuTuyH1WJmHE/fXh7jCnbnzXZKSJyJ44dF1MrbVHhhl7lRZanteLzQKi w++NNFdlZkIocE4MmQq7tMKrvOizct1pSTOTE= 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=DmbGzxDP/oVE26kezhTisBaywvmhWjn6VdxOWXD9u8A=; b=mC6Of5a0wYYV4VMHgrEmX9gcwAe/aq+zeDxmtlSPK+tbRqUyD/tpxsFX+6cINs0VtC 6U1lJ6EikJGfPPCb4TU4PDLq8djN9IeEB2tSi+giMsEPw11RlCJraXJBmzrkJ6uJtNAA DyGFsuFOevkV9XRkXKKNzXuKYuH3+TafT/h5eeO0epZyzthkpG5MmAT5Y29uw8pqLVfa fGG5BymfG1g8BvAW8fCQLBlBMwDz3cIRN6q+CgcBWewy4ocuNOSUZy0FOkPKQibgxBtk d1j3nxtaqt4yW9H6Vp1LwfQB4u3S3nQAl0HRGjTe58dqQMfdnugkwc72V1dS5Bn5PX+z 8+tw== X-Gm-Message-State: ALyK8tIWlQiyHsg1Zm02SO050hvLtyu2250l3083uZNitxFXNqDcNdA+gcUjEVpU7nymTtU/ X-Received: by 10.194.107.10 with SMTP id gy10mr1421355wjb.14.1466112484030; Thu, 16 Jun 2016 14:28:04 -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 x128sm16705606wmf.6.2016.06.16.14.28.02 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 16 Jun 2016 14:28:03 -0700 (PDT) From: Daniel Lezcano To: daniel.lezcano@linaro.org, tglx@linutronix.de Cc: linux-kernel@vger.kernel.org, Heiko Stuebner , linux-arm-kernel@lists.infradead.org (moderated list:ARM/Rockchip SoC...), linux-rockchip@lists.infradead.org (open list:ARM/Rockchip SoC...) Subject: [PATCH V2 03/63] clocksource/drivers/rockchip_timer: Convert init function to return error Date: Thu, 16 Jun 2016 23:26:22 +0200 Message-Id: <1466112442-31105-4-git-send-email-daniel.lezcano@linaro.org> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1466112442-31105-1-git-send-email-daniel.lezcano@linaro.org> References: <1466112442-31105-1-git-send-email-daniel.lezcano@linaro.org> 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 | 26 ++++++++++++++------------ 1 file changed, 14 insertions(+), 12 deletions(-) -- 1.9.1 diff --git a/drivers/clocksource/rockchip_timer.c b/drivers/clocksource/rockchip_timer.c index a3f22b0..d10bdee 100644 --- a/drivers/clocksource/rockchip_timer.c +++ b/drivers/clocksource/rockchip_timer.c @@ -113,17 +113,17 @@ 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; @@ -178,7 +178,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 +186,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);