From patchwork Tue Jun 28 10:31:17 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Lezcano X-Patchwork-Id: 71000 Delivered-To: patch@linaro.org Received: by 10.140.28.4 with SMTP id 4csp1509658qgy; Tue, 28 Jun 2016 03:34:28 -0700 (PDT) X-Received: by 10.98.74.157 with SMTP id c29mr480327pfj.99.1467110062318; Tue, 28 Jun 2016 03:34:22 -0700 (PDT) Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id xa6si33033397pab.117.2016.06.28.03.34.22; Tue, 28 Jun 2016 03:34:22 -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 S1752939AbcF1KeT (ORCPT + 30 others); Tue, 28 Jun 2016 06:34:19 -0400 Received: from mail-wm0-f49.google.com ([74.125.82.49]:35424 "EHLO mail-wm0-f49.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752877AbcF1KeO (ORCPT ); Tue, 28 Jun 2016 06:34:14 -0400 Received: by mail-wm0-f49.google.com with SMTP id v199so133621609wmv.0 for ; Tue, 28 Jun 2016 03:34:13 -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=81yeFHSYmEMEOomSdhkUeQibmaU3oSmEppNfds5/25w=; b=ivaJNqEI/oOk8++A8BFm/1fE3rx6KKzuknUaEQNl8R6PlL4G0aoParxFXUE5FX0D65 Vf/q7iVO/LouAO0MQN7/gxKIL5uccepzKAbCyTMoK2PVZvVzclKRnodVsJwC1GFDZp/p I+4kb/6EiVVS3rQNpihdVvWVdIj5rVr3buQ0o= 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=81yeFHSYmEMEOomSdhkUeQibmaU3oSmEppNfds5/25w=; b=aaq057Fcm4tTlzNjy7QDJUT+hAPhrO6WiFbjhv6lLpXtA0DP+iBGWIVKPlH9TOWdKd Pesf8wNWGRZPadtzwMRshJLV8c/AUxY5VwGlY868290FUKzvdCzZLD8cfnSHBfqgAeC9 0U1T31ga04A8ioCxJlLBEtc4GDKVplEvtz0j+ewuOA3EJuOIf86HL1pa9DsDtzylJqSj LxC8+FjvieXI4GYM/chikdRGNWziASA7R/Y6oIO8MJF5Th1xX+Q9eTyzVYzB6GODYZNR ASeSFo8018zJvfDX3Q6u7FDuDrdGg4ISFZtGmKMCKihDANzKaR1pLSg+Ap4tIIli9Nq0 j6XQ== X-Gm-Message-State: ALyK8tJjWA+Eu/Idb1rhx5HDGRqVPn9fefDPWYdPgPKQitMYtncJakWBSHfb54lcxmAFWZ8+ X-Received: by 10.194.88.106 with SMTP id bf10mr2612917wjb.37.1467110053267; Tue, 28 Jun 2016 03:34:13 -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 a84sm5377403wma.0.2016.06.28.03.34.11 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 28 Jun 2016 03:34:12 -0700 (PDT) From: Daniel Lezcano To: daniel.lezcano@linaro.org, tglx@linutronix.de Cc: linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org Subject: [PATCH 58/92] clocksource/drivers/sun5i: Convert init function to return error Date: Tue, 28 Jun 2016 12:31:17 +0200 Message-Id: <1467109911-11060-58-git-send-email-daniel.lezcano@linaro.org> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1467109911-11060-1-git-send-email-daniel.lezcano@linaro.org> References: <577251A4.7030508@linaro.org> <1467109911-11060-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/timer-sun5i.c | 37 +++++++++++++++++++++++-------------- 1 file changed, 23 insertions(+), 14 deletions(-) -- 1.9.1 diff --git a/drivers/clocksource/timer-sun5i.c b/drivers/clocksource/timer-sun5i.c index 24c83f9..f0a3ffb 100644 --- a/drivers/clocksource/timer-sun5i.c +++ b/drivers/clocksource/timer-sun5i.c @@ -311,33 +311,42 @@ err_free: return ret; } -static void __init sun5i_timer_init(struct device_node *node) +static int __init sun5i_timer_init(struct device_node *node) { struct reset_control *rstc; void __iomem *timer_base; struct clk *clk; - int irq; + int irq, ret; timer_base = of_io_request_and_map(node, 0, of_node_full_name(node)); - if (IS_ERR(timer_base)) - panic("Can't map registers"); + if (IS_ERR(timer_base)) { + pr_err("Can't map registers"); + return PTR_ERR(timer_base);; + } irq = irq_of_parse_and_map(node, 0); - if (irq <= 0) - panic("Can't parse IRQ"); + if (irq <= 0) { + pr_err("Can't parse IRQ"); + return -EINVAL; + } clk = of_clk_get(node, 0); - if (IS_ERR(clk)) - panic("Can't get timer clock"); + if (IS_ERR(clk)) { + pr_err("Can't get timer clock"); + return PTR_ERR(clk); + } rstc = of_reset_control_get(node, NULL); if (!IS_ERR(rstc)) reset_control_deassert(rstc); - sun5i_setup_clocksource(node, timer_base, clk, irq); - sun5i_setup_clockevent(node, timer_base, clk, irq); + ret = sun5i_setup_clocksource(node, timer_base, clk, irq); + if (ret) + return ret; + + return sun5i_setup_clockevent(node, timer_base, clk, irq); } -CLOCKSOURCE_OF_DECLARE(sun5i_a13, "allwinner,sun5i-a13-hstimer", - sun5i_timer_init); -CLOCKSOURCE_OF_DECLARE(sun7i_a20, "allwinner,sun7i-a20-hstimer", - sun5i_timer_init); +CLOCKSOURCE_OF_DECLARE_RET(sun5i_a13, "allwinner,sun5i-a13-hstimer", + sun5i_timer_init); +CLOCKSOURCE_OF_DECLARE_RET(sun7i_a20, "allwinner,sun7i-a20-hstimer", + sun5i_timer_init);