From patchwork Tue Jun 28 10:30:56 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Lezcano X-Patchwork-Id: 71041 Delivered-To: patch@linaro.org Received: by 10.140.28.4 with SMTP id 4csp1515021qgy; Tue, 28 Jun 2016 03:49:10 -0700 (PDT) X-Received: by 10.66.43.203 with SMTP id y11mr643599pal.96.1467110950843; Tue, 28 Jun 2016 03:49:10 -0700 (PDT) Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id d4si33132057pfg.5.2016.06.28.03.49.10; Tue, 28 Jun 2016 03:49:10 -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 S1752902AbcF1KtH (ORCPT + 30 others); Tue, 28 Jun 2016 06:49:07 -0400 Received: from mail-wm0-f54.google.com ([74.125.82.54]:37914 "EHLO mail-wm0-f54.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752805AbcF1Kdp (ORCPT ); Tue, 28 Jun 2016 06:33:45 -0400 Received: by mail-wm0-f54.google.com with SMTP id r201so20904989wme.1 for ; Tue, 28 Jun 2016 03:33:44 -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=QW+gHirK2rqAPFllyGnscemr7Q/YE+/k85X9/cFB3PM=; b=S3awJ1ibX2qr4RzzvzL79lGuQoBcvKNAgLZNMqEGTPtnD2alaoPVepEySlE52wRWIi B5atRMvlBH5PSFhXzAbJ3GxPYh362JbojucWfKSac7Kf3ejh7oQVUlkc9VsXC/jBNkFO aMUF8TN0sbudj8SvVo/wQZZfbPioEGiWKq7sU= 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=QW+gHirK2rqAPFllyGnscemr7Q/YE+/k85X9/cFB3PM=; b=PqUcBrXIncILL60lhFkGKz+JSvkdnMMcqwYJ0PW7hIJmjnILn7lwyBX+ywlN0/CIMo mrm42nKAIERJHJqwInF0EZ8qcapEdk02h3WvAkiyT9Yi8n4RwcZBOOgoYH7TexsvZu2W yqizReHEVZGO666j+p0VhtaQZ0umHLfI85WkvaSa1dN/b8mTtKph+U2L0ZWgbxZZmspM LUTtlASr39RMWeUPKd6yemDy1r7TNcTlwvu87EC1xeqF13xdBzL+LOYk1BewerfmilXQ c5M7tvTU7aPrUaVwqh8xUf8XDhrst2FPSo/Sp69UqjA12pbXzf2+cDgSvegaZyRmiIKa 4JlA== X-Gm-Message-State: ALyK8tLhgMCflL+oBOBjhtIrLMBxCOL7vlbp1ISebA/tEn2AqHmfIpWMYSJtASy2xSrab4n1 X-Received: by 10.194.236.195 with SMTP id uw3mr2613919wjc.149.1467110018612; Tue, 28 Jun 2016 03:33:38 -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.37 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 28 Jun 2016 03:33:38 -0700 (PDT) From: Daniel Lezcano To: daniel.lezcano@linaro.org, tglx@linutronix.de Cc: linux-kernel@vger.kernel.org Subject: [PATCH 37/92] clocksource/drivers/nomadik-mtu: Convert init function to return error Date: Tue, 28 Jun 2016 12:30:56 +0200 Message-Id: <1467109911-11060-37-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/nomadik-mtu.c | 45 +++++++++++++++++++++++++-------------- 1 file changed, 29 insertions(+), 16 deletions(-) -- 1.9.1 diff --git a/drivers/clocksource/nomadik-mtu.c b/drivers/clocksource/nomadik-mtu.c index bc8dd44..d2be5b3 100644 --- a/drivers/clocksource/nomadik-mtu.c +++ b/drivers/clocksource/nomadik-mtu.c @@ -193,10 +193,11 @@ static struct irqaction nmdk_timer_irq = { .dev_id = &nmdk_clkevt, }; -static void __init nmdk_timer_init(void __iomem *base, int irq, +static int __init nmdk_timer_init(void __iomem *base, int irq, struct clk *pclk, struct clk *clk) { unsigned long rate; + int ret; mtu_base = base; @@ -226,10 +227,12 @@ static void __init nmdk_timer_init(void __iomem *base, int irq, /* Timer 0 is the free running clocksource */ nmdk_clksrc_reset(); - if (clocksource_mmio_init(mtu_base + MTU_VAL(0), "mtu_0", - rate, 200, 32, clocksource_mmio_readl_down)) - pr_err("timer: failed to initialize clock source %s\n", - "mtu_0"); + ret = clocksource_mmio_init(mtu_base + MTU_VAL(0), "mtu_0", + rate, 200, 32, clocksource_mmio_readl_down); + if (ret) { + pr_err("timer: failed to initialize clock source %s\n", "mtu_0"); + return ret; + } #ifdef CONFIG_CLKSRC_NOMADIK_MTU_SCHED_CLOCK sched_clock_register(nomadik_read_sched_clock, 32, rate); @@ -244,9 +247,11 @@ static void __init nmdk_timer_init(void __iomem *base, int irq, mtu_delay_timer.read_current_timer = &nmdk_timer_read_current_timer; mtu_delay_timer.freq = rate; register_current_timer_delay(&mtu_delay_timer); + + return 0; } -static void __init nmdk_timer_of_init(struct device_node *node) +static int __init nmdk_timer_of_init(struct device_node *node) { struct clk *pclk; struct clk *clk; @@ -254,22 +259,30 @@ static void __init nmdk_timer_of_init(struct device_node *node) int irq; base = of_iomap(node, 0); - if (!base) - panic("Can't remap registers"); + if (!base) { + pr_err("Can't remap registers"); + return -ENXIO; + } pclk = of_clk_get_by_name(node, "apb_pclk"); - if (IS_ERR(pclk)) - panic("could not get apb_pclk"); + if (IS_ERR(pclk)) { + pr_err("could not get apb_pclk"); + return PTR_ERR(pclk); + } clk = of_clk_get_by_name(node, "timclk"); - if (IS_ERR(clk)) - panic("could not get timclk"); + if (IS_ERR(clk)) { + pr_err("could not get timclk"); + return PTR_ERR(clk); + } 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; + } - nmdk_timer_init(base, irq, pclk, clk); + return nmdk_timer_init(base, irq, pclk, clk); } -CLOCKSOURCE_OF_DECLARE(nomadik_mtu, "st,nomadik-mtu", +CLOCKSOURCE_OF_DECLARE_RET(nomadik_mtu, "st,nomadik-mtu", nmdk_timer_of_init);