From patchwork Thu Jul 7 08:01:10 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Lezcano X-Patchwork-Id: 71509 Delivered-To: patch@linaro.org Received: by 10.140.28.4 with SMTP id 4csp1271492qgy; Thu, 7 Jul 2016 01:04:01 -0700 (PDT) X-Received: by 10.98.102.133 with SMTP id s5mr2987095pfj.75.1467878639965; Thu, 07 Jul 2016 01:03:59 -0700 (PDT) Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id wo10si2939743pab.206.2016.07.07.01.03.59; Thu, 07 Jul 2016 01:03:59 -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 S933479AbcGGIDg (ORCPT + 30 others); Thu, 7 Jul 2016 04:03:36 -0400 Received: from mail-wm0-f42.google.com ([74.125.82.42]:36782 "EHLO mail-wm0-f42.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S933428AbcGGID3 (ORCPT ); Thu, 7 Jul 2016 04:03:29 -0400 Received: by mail-wm0-f42.google.com with SMTP id f126so200129750wma.1 for ; Thu, 07 Jul 2016 01:03:29 -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=DCKOOefghxs/bWBj9sZ2ixNabRZgK2WukcBEHINh9hcdKUort18nxAHhfRQUGSywkt 9XNQJUfHaLvglOfv+zNO/NS6uVL05iqTk47f0e6vY+kzcDF/k3niZ+K1OarsbUC0w7vb 3DokXe6N5aycOJEPC6w8IVjVbOEHLbH72X8Uc= 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=nGC31LJk/bdDbUpMceiqW4wy6zfH6rVQL2FQLS5ay0gP3wINXlbxBcAzI4EzIOtHSL L3nyl0UrKOpFNZA2GNzo4OvTUc4rgU9M4cP+ReR06VUQ3uhoDOf8UJOUdvUxmgEp3yk6 5NfuO7703/+Foi2R3lNXZp6dU+wOIP03lYCyI+Tu4ecjJVmMUYsCO/Mu8Ea9AUXh3YSi kw7fUBW44cCHnOeDBCtqtjr8mXSYFVUY5GDnnx8QYMd1lXJRZXr2bl0fliSuFlpT4NZV yuohmBDJKpMCo2g+jSWgPnSIlIfLVBd/oWwRCTMXcwBM+awDbUwOaTAzze1U+plPcpSt jNyw== X-Gm-Message-State: ALyK8tKKxI6644tY0i5pWVlPmL3yj0OlZ8Z9inhtuxu1tkodOkoejdI1l6DWB1LJKVCSDEg3 X-Received: by 10.28.224.69 with SMTP id x66mr1460808wmg.89.1467878608462; Thu, 07 Jul 2016 01:03:28 -0700 (PDT) Received: from localhost.localdomain (lft31-1-88-121-166-205.fbx.proxad.net. [88.121.166.205]) by smtp.gmail.com with ESMTPSA id v70sm51327wmf.18.2016.07.07.01.03.26 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 07 Jul 2016 01:03:27 -0700 (PDT) From: Daniel Lezcano To: tglx@linutronix.de, daniel.lezcano@linaro.org Cc: linux-kernel@vger.kernel.org Subject: [PATCH 37/93] clocksource/drivers/nomadik-mtu: Convert init function to return error Date: Thu, 7 Jul 2016 10:01:10 +0200 Message-Id: <1467878526-1238-37-git-send-email-daniel.lezcano@linaro.org> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1467878526-1238-1-git-send-email-daniel.lezcano@linaro.org> References: <577E0BED.3020608@linaro.org> <1467878526-1238-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);