From patchwork Tue Jun 28 10:31:21 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Lezcano X-Patchwork-Id: 71002 Delivered-To: patch@linaro.org Received: by 10.140.28.4 with SMTP id 4csp1509769qgy; Tue, 28 Jun 2016 03:34:47 -0700 (PDT) X-Received: by 10.98.107.129 with SMTP id g123mr563123pfc.62.1467110086476; Tue, 28 Jun 2016 03:34:46 -0700 (PDT) Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id l24si33040779pfj.19.2016.06.28.03.34.46; Tue, 28 Jun 2016 03:34:46 -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 S1753005AbcF1Kef (ORCPT + 30 others); Tue, 28 Jun 2016 06:34:35 -0400 Received: from mail-wm0-f46.google.com ([74.125.82.46]:34217 "EHLO mail-wm0-f46.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752963AbcF1Ke0 (ORCPT ); Tue, 28 Jun 2016 06:34:26 -0400 Received: by mail-wm0-f46.google.com with SMTP id 187so26448034wmz.1 for ; Tue, 28 Jun 2016 03:34:26 -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=9qa5gru+2A7l9gkuat9yCHZR6gBoZikByuk8O5UzY0o=; b=FxOZBkp/4s5p5paQU253BMnHGcJn3Crss31KX/sTdyg9Ep9/UQkQAp+lk7ihGHe4Zl Q53rpg1/eFSfhhjUoG6KJZBsKqK1wwM9guPjBo0sEIZ84U3Ur220GmiVhyUhTloWBV/M UXLdmaHLKgNiek2ENKb3W+KlZf3hGc16YaiV0= 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=9qa5gru+2A7l9gkuat9yCHZR6gBoZikByuk8O5UzY0o=; b=ISjVHe6EYCJVYXlhZenlN20xB1G+gdKLRDp60FsRlWEfqTFOv5zgeOa95p5ve7OXzy b3onFCAxvJFrkrMRuHINtQpsHHX8FP7TzOw2xc4lBYLv9iOEZ5PXb2EQuJSfwIqZojHl sNICHjnjd7o2EHOJHOv5qdSY+synnoUP0t5iN0mqggJGra5sdSHHeTS9HKtPwUYlCmm0 Z4j7u17pqLMV7ICOVeJaywL+OuA2ramxzoyAXAjhEhFz1A06/zY953eXNCEzgY1umTy3 3LSwMQe8hpg7DKyYUOe+OaGmyS/8glsHDoathLPZcLiDw24tM+BHROb5J9q0zqGU0NM9 /9Zw== X-Gm-Message-State: ALyK8tLo0P23zDOYZ/vrQUd3YZsS3yuZitXctr3+1dVHjKUHKTzKeOOagSpPfAlAoGI/TJRO X-Received: by 10.28.136.21 with SMTP id k21mr2880211wmd.24.1467110060485; Tue, 28 Jun 2016 03:34:20 -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.34.18 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 28 Jun 2016 03:34:19 -0700 (PDT) From: Daniel Lezcano To: daniel.lezcano@linaro.org, tglx@linutronix.de Cc: linux-kernel@vger.kernel.org Subject: [PATCH 62/92] clocksource/drivers/vf_pit_timer: Convert init function to return error Date: Tue, 28 Jun 2016 12:31:21 +0200 Message-Id: <1467109911-11060-62-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/vf_pit_timer.c | 27 ++++++++++++++++++--------- 1 file changed, 18 insertions(+), 9 deletions(-) -- 1.9.1 diff --git a/drivers/clocksource/vf_pit_timer.c b/drivers/clocksource/vf_pit_timer.c index a0e6c68..ca4dff4 100644 --- a/drivers/clocksource/vf_pit_timer.c +++ b/drivers/clocksource/vf_pit_timer.c @@ -156,15 +156,18 @@ static int __init pit_clockevent_init(unsigned long rate, int irq) return 0; } -static void __init pit_timer_init(struct device_node *np) +static int __init pit_timer_init(struct device_node *np) { struct clk *pit_clk; void __iomem *timer_base; unsigned long clk_rate; - int irq; + int irq, ret; timer_base = of_iomap(np, 0); - BUG_ON(!timer_base); + if (!timer_base) { + pr_err("Failed to iomap"); + return -ENXIO; + } /* * PIT0 and PIT1 can be chained to build a 64-bit timer, @@ -175,12 +178,16 @@ static void __init pit_timer_init(struct device_node *np) clkevt_base = timer_base + PITn_OFFSET(3); irq = irq_of_parse_and_map(np, 0); - BUG_ON(irq <= 0); + if (irq <= 0) + return -EINVAL; pit_clk = of_clk_get(np, 0); - BUG_ON(IS_ERR(pit_clk)); + if (IS_ERR(pit_clk)) + return PTR_ERR(pit_clk); - BUG_ON(clk_prepare_enable(pit_clk)); + ret = clk_prepare_enable(pit_clk); + if (ret) + return ret; clk_rate = clk_get_rate(pit_clk); cycle_per_jiffy = clk_rate / (HZ); @@ -188,8 +195,10 @@ static void __init pit_timer_init(struct device_node *np) /* enable the pit module */ __raw_writel(~PITMCR_MDIS, timer_base + PITMCR); - BUG_ON(pit_clocksource_init(clk_rate)); + ret = pit_clocksource_init(clk_rate); + if (ret) + return ret; - pit_clockevent_init(clk_rate, irq); + return pit_clockevent_init(clk_rate, irq); } -CLOCKSOURCE_OF_DECLARE(vf610, "fsl,vf610-pit", pit_timer_init); +CLOCKSOURCE_OF_DECLARE_RET(vf610, "fsl,vf610-pit", pit_timer_init);