From patchwork Thu Jun 16 21:27: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: 70224 Delivered-To: patch@linaro.org Received: by 10.140.28.4 with SMTP id 4csp464869qgy; Thu, 16 Jun 2016 14:29:54 -0700 (PDT) X-Received: by 10.66.81.70 with SMTP id y6mr7548283pax.121.1466112591292; Thu, 16 Jun 2016 14:29:51 -0700 (PDT) Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id n188si7982154pfn.2.2016.06.16.14.29.51; Thu, 16 Jun 2016 14:29:51 -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 S1755360AbcFPV3W (ORCPT + 30 others); Thu, 16 Jun 2016 17:29:22 -0400 Received: from mail-wm0-f52.google.com ([74.125.82.52]:36086 "EHLO mail-wm0-f52.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754727AbcFPV3N (ORCPT ); Thu, 16 Jun 2016 17:29:13 -0400 Received: by mail-wm0-f52.google.com with SMTP id f126so66418441wma.1 for ; Thu, 16 Jun 2016 14:29: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=PVWBeePhZtNFITcFhEFETF89X5V/ovID5L4ISa1Zaa0BGStOsMQ9LEqv/2UoTieW3E V6+e2Kp2KG6mkL4eBJ7R8Z4fDWJ59fNY68z/izq6EpJXcTqnEa5zzesNPlJZV40KG+Gg PN0EU6nAG5RakQhyrYmTgfHd0f3kz8XfGJ9Qo= 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=Ak9E3E7PUrWemLBEM3dRZ1PV4k0p980jcMbbYEb+XrBAuW+qwvTF5dH/5a7eqyHpn5 kCZO7lHMSThacMcnqCuKhxpMT2TDU+WdofVg9epfOdJyq3QC1uOUK1y9+gndggCBPksV cJUofIrE9iMaJJAyfBAAai9wUK1Yp8WX0gMKW6PvLe2nZdwLXS1WsFeGEWc0N03FeSo6 d20XFOv/d/su2as+Yp9l03T6KOQ3oxG46E/hNjOGZQ4LnZ8RKlp9xa+PDPTMaULbz6DM wqVGDlpq6zvkPE7tx+Sj7Ni9aqKLp2yzBG8ZdHG1iTqkAEHNWWDrAWNHkRmw57YrYB8N Pw4g== X-Gm-Message-State: ALyK8tIvrnMdw94llaYeNF4KB9A7emg7a6mwhvRiGMeNRtohZceXkMNgRKmDjR4K+YnM8m+/ X-Received: by 10.194.107.10 with SMTP id gy10mr1423659wjb.14.1466112547239; Thu, 16 Jun 2016 14:29:07 -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.29.05 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 16 Jun 2016 14:29:06 -0700 (PDT) From: Daniel Lezcano To: daniel.lezcano@linaro.org, tglx@linutronix.de Cc: linux-kernel@vger.kernel.org, Maxime Ripard , Chen-Yu Tsai , linux-arm-kernel@lists.infradead.org (moderated list:ARM/Allwinner sun...) Subject: [PATCH V2 48/63] clocksource/drivers/timer-sun5i: Convert init function to return error Date: Thu, 16 Jun 2016 23:27:07 +0200 Message-Id: <1466112442-31105-49-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/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);