From patchwork Tue Jun 28 10:31: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: 71035 Delivered-To: patch@linaro.org Received: by 10.140.28.4 with SMTP id 4csp1512959qgy; Tue, 28 Jun 2016 03:43:02 -0700 (PDT) X-Received: by 10.66.101.136 with SMTP id fg8mr590379pab.144.1467110582609; Tue, 28 Jun 2016 03:43:02 -0700 (PDT) Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id wy7si12591751pab.3.2016.06.28.03.43.02; Tue, 28 Jun 2016 03:43:02 -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 S1753140AbcF1KnA (ORCPT + 30 others); Tue, 28 Jun 2016 06:43:00 -0400 Received: from mail-wm0-f47.google.com ([74.125.82.47]:35984 "EHLO mail-wm0-f47.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752400AbcF1Kd5 (ORCPT ); Tue, 28 Jun 2016 06:33:57 -0400 Received: by mail-wm0-f47.google.com with SMTP id f126so133920699wma.1 for ; Tue, 28 Jun 2016 03:33:56 -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=/cybx4wub3wqDU+Rnrn5cJMxnazLhs/1b0m5LZUP2a0=; b=dU4mGPd5TCu8Ek1GqVdna0vP+tIWyCrI0spBCikw8hfd4F814G/WcB9gq4HrIW2X7u F+2zHIR/IJaWMSgG6IS5KWvsVQsNHxe2p1WiP+und5nIt2hvL62z6HNXZ+KM5El8OZRl RPrC0tc/7nztqpaW6gcO7CR+ZvC1qxVDATbiE= 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=/cybx4wub3wqDU+Rnrn5cJMxnazLhs/1b0m5LZUP2a0=; b=COJrucC7G01sYzxu4lHL9Gp0qqRylLiSkVIag6UkKaBBt58rqf9HJi3XNFVQRG5Yj7 WSj5FqAGCYslXuY7iWXTqrM94bLC0HyM4VNY5PUD6jnqS0g8VcNa6PjhGPMkSQFOmNkg c6zrdk7U34+bo6R32GRFbxu6RJDwwn0aCPnua/EF9ZxHGsgxwsXSO2KZBBIW6TXm1DVh +3RehC8/Gi1kWA/TUSAlofbYQ0SBULB1f766oM66pfQ3m+WxDi3yEsV7Th03k828GQTQ iSUBlyeh4Nu17jUwN9HBpBNy6VfgGuZXI5G/PKfcIWO60se7cyYt/BDgemFRzl/0J+ox 7F3g== X-Gm-Message-State: ALyK8tJwdjXdPsmf1ZRhKnj3lEx3qWYyoyJFPqfYCetgfcHddqqhak25DEZ/rTumTaLA7DAn X-Received: by 10.28.56.68 with SMTP id f65mr15874660wma.58.1467110035841; Tue, 28 Jun 2016 03:33:55 -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.33.54 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 28 Jun 2016 03:33:55 -0700 (PDT) From: Daniel Lezcano To: daniel.lezcano@linaro.org, tglx@linutronix.de Cc: linux-kernel@vger.kernel.org Subject: [PATCH 48/92] clocksource/drivers/pistachio: Convert init function to return error Date: Tue, 28 Jun 2016 12:31:07 +0200 Message-Id: <1467109911-11060-48-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/time-pistachio.c | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) -- 1.9.1 diff --git a/drivers/clocksource/time-pistachio.c b/drivers/clocksource/time-pistachio.c index 376e59b..adaaec5 100644 --- a/drivers/clocksource/time-pistachio.c +++ b/drivers/clocksource/time-pistachio.c @@ -148,7 +148,7 @@ static struct pistachio_clocksource pcs_gpt = { }, }; -static void __init pistachio_clksrc_of_init(struct device_node *node) +static int __init pistachio_clksrc_of_init(struct device_node *node) { struct clk *sys_clk, *fast_clk; struct regmap *periph_regs; @@ -158,45 +158,45 @@ static void __init pistachio_clksrc_of_init(struct device_node *node) pcs_gpt.base = of_iomap(node, 0); if (!pcs_gpt.base) { pr_err("cannot iomap\n"); - return; + return -ENXIO; } periph_regs = syscon_regmap_lookup_by_phandle(node, "img,cr-periph"); if (IS_ERR(periph_regs)) { pr_err("cannot get peripheral regmap (%ld)\n", PTR_ERR(periph_regs)); - return; + return PTR_ERR(periph_regs); } /* Switch to using the fast counter clock */ ret = regmap_update_bits(periph_regs, PERIP_TIMER_CONTROL, 0xf, 0x0); if (ret) - return; + return ret; sys_clk = of_clk_get_by_name(node, "sys"); if (IS_ERR(sys_clk)) { pr_err("clock get failed (%ld)\n", PTR_ERR(sys_clk)); - return; + return PTR_ERR(sys_clk); } fast_clk = of_clk_get_by_name(node, "fast"); if (IS_ERR(fast_clk)) { pr_err("clock get failed (%lu)\n", PTR_ERR(fast_clk)); - return; + return PTR_ERR(fast_clk); } ret = clk_prepare_enable(sys_clk); if (ret < 0) { pr_err("failed to enable clock (%d)\n", ret); - return; + return ret; } ret = clk_prepare_enable(fast_clk); if (ret < 0) { pr_err("failed to enable clock (%d)\n", ret); clk_disable_unprepare(sys_clk); - return; + return ret; } rate = clk_get_rate(fast_clk); @@ -212,7 +212,7 @@ static void __init pistachio_clksrc_of_init(struct device_node *node) raw_spin_lock_init(&pcs_gpt.lock); sched_clock_register(pistachio_read_sched_clock, 32, rate); - clocksource_register_hz(&pcs_gpt.cs, rate); + return clocksource_register_hz(&pcs_gpt.cs, rate); } -CLOCKSOURCE_OF_DECLARE(pistachio_gptimer, "img,pistachio-gptimer", +CLOCKSOURCE_OF_DECLARE_RET(pistachio_gptimer, "img,pistachio-gptimer", pistachio_clksrc_of_init);