From patchwork Thu Jul 7 08:01: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: 71558 Delivered-To: patch@linaro.org Received: by 10.140.28.4 with SMTP id 4csp1280864qgy; Thu, 7 Jul 2016 01:28:16 -0700 (PDT) X-Received: by 10.66.120.138 with SMTP id lc10mr49825194pab.33.1467880096045; Thu, 07 Jul 2016 01:28:16 -0700 (PDT) Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id x5si3067129pac.165.2016.07.07.01.28.15; Thu, 07 Jul 2016 01:28:16 -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 S933670AbcGGI15 (ORCPT + 30 others); Thu, 7 Jul 2016 04:27:57 -0400 Received: from mail-wm0-f51.google.com ([74.125.82.51]:35244 "EHLO mail-wm0-f51.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S933431AbcGGIDb (ORCPT ); Thu, 7 Jul 2016 04:03:31 -0400 Received: by mail-wm0-f51.google.com with SMTP id z126so138049503wme.0 for ; Thu, 07 Jul 2016 01:03:30 -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=3l8xPvPMs/zn6dk1HDAkqB0lPKv7NqxCYAYN3xAOhFQ=; b=DaUc1SgyseTroECPjyz9XtbiF28YUyasyALEvt1fHXvsz9e4hG25SZBx+Mgv1lsuJ0 rJn7/VVqce/Ee9jH/vRnLUzOfXOzuDnN1bBgGIC99iCgTocbrSzvw42NB4P/ZdOYHdiP mCepvSKWTWjUTW5v2kMRdO2YieTrdpL2GpdjA= 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=3l8xPvPMs/zn6dk1HDAkqB0lPKv7NqxCYAYN3xAOhFQ=; b=NW0tWueLLHS/GojK1PyfXNmVd0aF/TXIWBjS+2ZIJpzLCj9KVSsxJ343j2yw3PsfmB PsegDAaLS/zHtN7aqJ7P0uY0fcs3Ea/xgN7wN5SC0oCmxOMLpJSJYhmn5k+quISSuk1s asO5EzkKt+mVydlSybZ/lQARxMScWSLChd+FzFfu8wc8hrwe1o2DrKYgQDYt+9OwbLFJ duImofi1GTQt2DWV/pozzFMtdxIBEwvl4+5yeWtpqjzD8SOpEvurwc+jFZ0rU5USuI73 /fkehSgSOOfUPXMaF0U29qhcNDqQV3DegdAHZU5i90FF+vVqjLo4SQMrnfm0yLQJFu+D 3rFQ== X-Gm-Message-State: ALyK8tLi1aH7o34Adgwc6urRLllt9d+t1pp1WgQsENEj8mgk20c9bKrZsO2Ht4AHYkc2hVhV X-Received: by 10.28.29.146 with SMTP id d140mr1480844wmd.27.1467878603263; Thu, 07 Jul 2016 01:03:23 -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.22 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 07 Jul 2016 01:03:22 -0700 (PDT) From: Daniel Lezcano To: tglx@linutronix.de, daniel.lezcano@linaro.org Cc: linux-kernel@vger.kernel.org Subject: [PATCH 34/93] clocksource/drivers/moxart: Convert init function to return error Date: Thu, 7 Jul 2016 10:01:07 +0200 Message-Id: <1467878526-1238-34-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/moxart_timer.c | 41 +++++++++++++++++++++++++------------- 1 file changed, 27 insertions(+), 14 deletions(-) -- 1.9.1 diff --git a/drivers/clocksource/moxart_timer.c b/drivers/clocksource/moxart_timer.c index 19857af..b9c30cd 100644 --- a/drivers/clocksource/moxart_timer.c +++ b/drivers/clocksource/moxart_timer.c @@ -119,34 +119,45 @@ static struct irqaction moxart_timer_irq = { .dev_id = &moxart_clockevent, }; -static void __init moxart_timer_init(struct device_node *node) +static int __init moxart_timer_init(struct device_node *node) { int ret, irq; unsigned long pclk; struct clk *clk; base = of_iomap(node, 0); - if (!base) - panic("%s: of_iomap failed\n", node->full_name); + if (!base) { + pr_err("%s: of_iomap failed\n", node->full_name); + return -ENXIO; + } irq = irq_of_parse_and_map(node, 0); - if (irq <= 0) - panic("%s: irq_of_parse_and_map failed\n", node->full_name); + if (irq <= 0) { + pr_err("%s: irq_of_parse_and_map failed\n", node->full_name); + return -EINVAL; + } ret = setup_irq(irq, &moxart_timer_irq); - if (ret) - panic("%s: setup_irq failed\n", node->full_name); + if (ret) { + pr_err("%s: setup_irq failed\n", node->full_name); + return ret; + } clk = of_clk_get(node, 0); - if (IS_ERR(clk)) - panic("%s: of_clk_get failed\n", node->full_name); + if (IS_ERR(clk)) { + pr_err("%s: of_clk_get failed\n", node->full_name); + return PTR_ERR(clk); + } pclk = clk_get_rate(clk); - if (clocksource_mmio_init(base + TIMER2_BASE + REG_COUNT, - "moxart_timer", pclk, 200, 32, - clocksource_mmio_readl_down)) - panic("%s: clocksource_mmio_init failed\n", node->full_name); + ret = clocksource_mmio_init(base + TIMER2_BASE + REG_COUNT, + "moxart_timer", pclk, 200, 32, + clocksource_mmio_readl_down); + if (ret) { + pr_err("%s: clocksource_mmio_init failed\n", node->full_name); + return ret; + } clock_count_per_tick = DIV_ROUND_CLOSEST(pclk, HZ); @@ -164,5 +175,7 @@ static void __init moxart_timer_init(struct device_node *node) */ clockevents_config_and_register(&moxart_clockevent, pclk, 0x4, 0xfffffffe); + + return 0; } -CLOCKSOURCE_OF_DECLARE(moxart, "moxa,moxart-timer", moxart_timer_init); +CLOCKSOURCE_OF_DECLARE_RET(moxart, "moxa,moxart-timer", moxart_timer_init);