From patchwork Thu Jun 16 21:26:46 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Lezcano X-Patchwork-Id: 70261 Delivered-To: patch@linaro.org Received: by 10.140.28.4 with SMTP id 4csp468019qgy; Thu, 16 Jun 2016 14:39:10 -0700 (PDT) X-Received: by 10.98.68.203 with SMTP id m72mr7476014pfi.135.1466113150516; Thu, 16 Jun 2016 14:39:10 -0700 (PDT) Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id a8si8005321pfj.35.2016.06.16.14.39.10; Thu, 16 Jun 2016 14:39: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 S1755411AbcFPVjF (ORCPT + 30 others); Thu, 16 Jun 2016 17:39:05 -0400 Received: from mail-wm0-f44.google.com ([74.125.82.44]:38221 "EHLO mail-wm0-f44.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755253AbcFPV2j (ORCPT ); Thu, 16 Jun 2016 17:28:39 -0400 Received: by mail-wm0-f44.google.com with SMTP id m124so86960578wme.1 for ; Thu, 16 Jun 2016 14:28:38 -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=jkKv88oecEpu2ED2hSsrKrK+rTalEVEFFuLbrSSpR6YOPJs04Gv1gl1v290yaYwoer K3p8/k0TvvOhmXM7eGAOMzbIKiHOBiFpalmXi1j7NSFC1X7xmKQqUsWJpISWD0RtPMEM jx9LHyKkpOt/644IzYLOMwATmOjKdQYbS6x7o= 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=Y6ynBLrboDF0+2v3r9n6Y7x9yNPDOOT4NyyCbBepj8OiL0cHjVQQV4MDGW82NIM+ct 1xYFe9VaRcrsETr7yScnZ4H7xUD4/uWBX+xO7YXeMareifCBHVBzKz98sIv1aop4cXGr SEsVTxbW3LMolw52MnrvzZDFVscjAoNYb5vWEY8l1GC3GcDZEFVpy8+MCwmCWE7ltu9v mX7HYN9fmC9vc38D1vDkNBOe2FWVlrK99MEuHVavBPXQjj1hdgBcUi0Q+7cGr8Qbgzsx 4Hqdn467Ihaby/zdOBvQN+bKsqnQq6VFIax5DrZl7xGsr4nv+ywld7CdhVET7miVsKul pv3g== X-Gm-Message-State: ALyK8tLA4JzhdiVgH9CG4Vu4mqsSq/ZcRZcD7S3ZESAjaIy7w/hiJLVKKZSgqn7ju+iHk2iP X-Received: by 10.194.34.202 with SMTP id b10mr1539242wjj.47.1466112517722; Thu, 16 Jun 2016 14:28:37 -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.28.36 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 16 Jun 2016 14:28:37 -0700 (PDT) From: Daniel Lezcano To: daniel.lezcano@linaro.org, tglx@linutronix.de Cc: linux-kernel@vger.kernel.org Subject: [PATCH V2 27/63] clocksource/drivers/pxa_timer: Convert init function to return error Date: Thu, 16 Jun 2016 23:26:46 +0200 Message-Id: <1466112442-31105-28-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/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);