Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1432750

[PATCH 69/92] clocksource/drivers/nps: Convert init function to return error

Path csiph.com!news.mixmin.net!feeds.phibee-telecom.net!news.panservice.it!bofh.it!news.nic.it!robomod
From Daniel Lezcano <daniel.lezcano@linaro.org>
Newsgroups linux.kernel
Subject [PATCH 69/92] clocksource/drivers/nps: Convert init function to return error
Date Tue, 28 Jun 2016 12:40:01 +0200
Message-ID <rOYAV-5IE-7@gated-at.bofh.it> (permalink)
References <rOYAV-5IE-3@gated-at.bofh.it> <rOYAV-5IE-5@gated-at.bofh.it>
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=pXeDflHQGdqnqPISHUMBFmCrHD+I8PCh7rC7AxPOnEo=; b=QFFQiecF0hoCDO7CYqKJBVa+Qdn0NXtHXVvkT/BSuknJZdnjPedNtmj0NWoxjCKbDa yQ0UhQ48EWi104ZSlVPb98tZlWyOAlTlzzWXwemKRkB1XnJG5XVi2LdvHAukm1yjj1xE 6X6Bp7RUazWKplbeaDvQ55d6XeOM4QidvwM8o=
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=pXeDflHQGdqnqPISHUMBFmCrHD+I8PCh7rC7AxPOnEo=; b=dSD9XJ8QNGvNmZ/LCbTAHS6tIK2JnhfRc+54ZOR5ejS8RO6BA40674CSXgvVNAIhkI ectG23NMwJrPTB6pCS94K2eZwtiSAa/HiJfIIHdPRl4OyoYpXZSI2LZyyZuFtx3ytd3M hKXJsTkufr3ryo3olg4ZZM2EySajiHe3fGLMNjkmKbLDzr60kLEvpx8ziLyxXmuqfC1J GMjS5FdziIrkwwKYfvFh1lXCv1mjbJ6MmH24/5FigNpu3whebQ/xURlOQzIVm1lgoe4S ByOhxdYHXbw4Rbmzv8rCrjFmniCpkG742a1Ss+7VG/QG/Lpp+DVJTBz92B1acgKCPEQS CxZQ==
X-Gm-Message-State ALyK8tJZRLkEbroi00pzFtdL64rJLHy4NcFYHxqmT88IXr30NqvNPkkqHaBZhrtTyc0PhCa2
X-Received by 10.194.104.196 with SMTP id gg4mr2653292wjb.112.1467110072690; Tue, 28 Jun 2016 03:34:32 -0700 (PDT)
X-Mailer git-send-email 1.9.1
Sender robomod@news.nic.it
List-ID <linux-kernel.vger.kernel.org>
X-Mailing-List linux-kernel@vger.kernel.org
Approved robomod@news.nic.it
Lines 76
Organization linux.* mail to news gateway
X-Original-Cc linux-kernel@vger.kernel.org, Arnd Bergmann <arnd@arndb.de>
X-Original-Date Tue, 28 Jun 2016 12:31:28 +0200
X-Original-Message-ID <1467109911-11060-69-git-send-email-daniel.lezcano@linaro.org>
X-Original-References <577251A4.7030508@linaro.org> <1467109911-11060-1-git-send-email-daniel.lezcano@linaro.org>
X-Original-Sender linux-kernel-owner@vger.kernel.org
Xref csiph.com linux.kernel:1432750

Show key headers only | View raw


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 <daniel.lezcano@linaro.org>
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
---
 drivers/clocksource/timer-nps.c | 18 ++++++++++--------
 1 file changed, 10 insertions(+), 8 deletions(-)

diff --git a/drivers/clocksource/timer-nps.c b/drivers/clocksource/timer-nps.c
index d461089..b5c7b2b 100644
--- a/drivers/clocksource/timer-nps.c
+++ b/drivers/clocksource/timer-nps.c
@@ -55,8 +55,8 @@ static cycle_t nps_clksrc_read(struct clocksource *clksrc)
 	return (cycle_t)ioread32be(nps_msu_reg_low_addr[cluster]);
 }
 
-static void __init nps_setup_clocksource(struct device_node *node,
-					 struct clk *clk)
+static int __init nps_setup_clocksource(struct device_node *node,
+					struct clk *clk)
 {
 	int ret, cluster;
 
@@ -68,7 +68,7 @@ static void __init nps_setup_clocksource(struct device_node *node,
 	ret = clk_prepare_enable(clk);
 	if (ret) {
 		pr_err("Couldn't enable parent clock\n");
-		return;
+		return ret;
 	}
 
 	nps_timer_rate = clk_get_rate(clk);
@@ -79,20 +79,22 @@ static void __init nps_setup_clocksource(struct device_node *node,
 		pr_err("Couldn't register clock source.\n");
 		clk_disable_unprepare(clk);
 	}
+
+	return ret;
 }
 
-static void __init nps_timer_init(struct device_node *node)
+static int __init nps_timer_init(struct device_node *node)
 {
 	struct clk *clk;
 
 	clk = of_clk_get(node, 0);
 	if (IS_ERR(clk)) {
 		pr_err("Can't get timer clock.\n");
-		return;
+		return PTR_ERR(clk);
 	}
 
-	nps_setup_clocksource(node, clk);
+	return nps_setup_clocksource(node, clk);
 }
 
-CLOCKSOURCE_OF_DECLARE(ezchip_nps400_clksrc, "ezchip,nps400-timer",
-		       nps_timer_init);
+CLOCKSOURCE_OF_DECLARE_RET(ezchip_nps400_clksrc, "ezchip,nps400-timer",
+			   nps_timer_init);
-- 
1.9.1

Back to linux.kernel | Previous | Next | Find similar | Unroll thread


Thread

[PATCH 69/92] clocksource/drivers/nps: Convert init function to return error Daniel Lezcano <daniel.lezcano@linaro.org> - 2016-06-28 12:40 +0200

csiph-web