From patchwork Tue Jun 28 10:30:48 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Lezcano X-Patchwork-Id: 71050 Delivered-To: patch@linaro.org Received: by 10.140.28.4 with SMTP id 4csp1516055qgy; Tue, 28 Jun 2016 03:52:02 -0700 (PDT) X-Received: by 10.66.83.35 with SMTP id n3mr663209pay.124.1467111122395; Tue, 28 Jun 2016 03:52:02 -0700 (PDT) Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id x5si33144440pac.165.2016.06.28.03.52.02; Tue, 28 Jun 2016 03:52:02 -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 S932287AbcF1Kv6 (ORCPT + 30 others); Tue, 28 Jun 2016 06:51:58 -0400 Received: from mail-wm0-f45.google.com ([74.125.82.45]:36654 "EHLO mail-wm0-f45.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752742AbcF1Kdd (ORCPT ); Tue, 28 Jun 2016 06:33:33 -0400 Received: by mail-wm0-f45.google.com with SMTP id f126so133904873wma.1 for ; Tue, 28 Jun 2016 03:33: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=vGkFL9mInYpU29oeqJlV9y+Ksx6pEAj9qSWN1L52+gw=; b=EBFTAwadfwTuFO2lwoJNOdZn6Oxgz6zAbSSI1I/HGHtgslZoEzyScCTBUsN4OQXvzD U2nJXylvWpD4UglWG9tfjg21THJRWosOU2xLx3XqGlXV8ezKP2VdtwjqEZFsScLfGX+e 7fnC0xlFZYEpINyY1FBYE2RnoEfaSXn6P2nxc= 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=vGkFL9mInYpU29oeqJlV9y+Ksx6pEAj9qSWN1L52+gw=; b=CT0S7oTWQDpOPAWsAVQKbDaD/CUO5YFNR07tjt6MhlpeVt/tkJhQbjQw1wJRTXprd1 60jJKaDOkCh2WGxnQaV4cu/p9LR6BvFWkSmJ9AbTO8qlqKpK9uLROOey7sQfrpk38ifQ 2pTxfflSqCaJelXS1oDvi321kUWMVgmwzngoSAWPwEPfH28NvONwAsjPeJWcFncpiX1e gByFxQsDnDpySDBjqKj7+9lyNWthzKrQoR+mTsvHgjLZR+YwS/TiXL0XcAgDPOr9QUBg E006G9UBFcEuUcDEP24e5FGMAsdb9PfzdmhxTPcLp66O1t03V6CtZunQpDEsPloiVuQu 4mVA== X-Gm-Message-State: ALyK8tLlmv6G108DH/BhCfbY/DO5R+3pShf1GdGG3Du8bqX72te4O0iIW4CqkDWzBU24v77E X-Received: by 10.194.201.73 with SMTP id jy9mr2581573wjc.150.1467110009019; Tue, 28 Jun 2016 03:33:29 -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.28 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 28 Jun 2016 03:33:28 -0700 (PDT) From: Daniel Lezcano To: daniel.lezcano@linaro.org, tglx@linutronix.de Cc: linux-kernel@vger.kernel.org, uclinux-h8-devel@lists.sourceforge.jp Subject: [PATCH 29/92] clocksource/drivers/h8300_timer16: Convert init function to return error Date: Tue, 28 Jun 2016 12:30:48 +0200 Message-Id: <1467109911-11060-29-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/h8300_timer16.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) -- 1.9.1 diff --git a/drivers/clocksource/h8300_timer16.c b/drivers/clocksource/h8300_timer16.c index 75c4407..9d99fc8 100644 --- a/drivers/clocksource/h8300_timer16.c +++ b/drivers/clocksource/h8300_timer16.c @@ -126,7 +126,7 @@ static struct timer16_priv timer16_priv = { #define REG_CH 0 #define REG_COMM 1 -static void __init h8300_16timer_init(struct device_node *node) +static int __init h8300_16timer_init(struct device_node *node) { void __iomem *base[2]; int ret, irq; @@ -136,9 +136,10 @@ static void __init h8300_16timer_init(struct device_node *node) clk = of_clk_get(node, 0); if (IS_ERR(clk)) { pr_err("failed to get clock for clocksource\n"); - return; + return PTR_ERR(clk); } + ret = -ENXIO; base[REG_CH] = of_iomap(node, 0); if (!base[REG_CH]) { pr_err("failed to map registers for clocksource\n"); @@ -151,6 +152,7 @@ static void __init h8300_16timer_init(struct device_node *node) goto unmap_ch; } + ret = -EINVAL; irq = irq_of_parse_and_map(node, 0); if (!irq) { pr_err("failed to get irq for clockevent\n"); @@ -174,7 +176,7 @@ static void __init h8300_16timer_init(struct device_node *node) clocksource_register_hz(&timer16_priv.cs, clk_get_rate(clk) / 8); - return; + return 0; unmap_comm: iounmap(base[REG_COMM]); @@ -182,6 +184,8 @@ unmap_ch: iounmap(base[REG_CH]); free_clk: clk_put(clk); + return ret; } -CLOCKSOURCE_OF_DECLARE(h8300_16bit, "renesas,16bit-timer", h8300_16timer_init); +CLOCKSOURCE_OF_DECLARE_RET(h8300_16bit, "renesas,16bit-timer", + h8300_16timer_init);