From patchwork Tue Jun 28 10:30:49 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Lezcano X-Patchwork-Id: 71037 Delivered-To: patch@linaro.org Received: by 10.140.28.4 with SMTP id 4csp1513226qgy; Tue, 28 Jun 2016 03:43:50 -0700 (PDT) X-Received: by 10.98.149.10 with SMTP id p10mr616678pfd.88.1467110630219; Tue, 28 Jun 2016 03:43:50 -0700 (PDT) Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 5si33113015pft.184.2016.06.28.03.43.49; Tue, 28 Jun 2016 03:43:50 -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 S932137AbcF1Kdy (ORCPT + 30 others); Tue, 28 Jun 2016 06:33:54 -0400 Received: from mail-wm0-f51.google.com ([74.125.82.51]:33234 "EHLO mail-wm0-f51.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752743AbcF1Kdd (ORCPT ); Tue, 28 Jun 2016 06:33:33 -0400 Received: by mail-wm0-f51.google.com with SMTP id r190so26342779wmr.0 for ; Tue, 28 Jun 2016 03:33: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=9xx9ud0jmuaV7LxadLQ0AYjN5rqoVBzHb2jRCUhav0E=; b=SjyWApcsfE9eCREfL5EqmIcR9j2njzXBO30hZMM/16i1YOH+GgKcHft+wPAtS2ZWBz jTZf3wQFGcLPvwz5nqXqbMvgokRAV6jvbRLzXY84dEp22JLtx6S+OjM/yWQUi9HdW8II uvAuijRIBj7uKo7azCmN4pnCHlExUREpPO94g= 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=9xx9ud0jmuaV7LxadLQ0AYjN5rqoVBzHb2jRCUhav0E=; b=eRKY+XGO2FwMLGpxZyzpyOezWfpamxUdmKEY9Ow/Qr0nzivs0Y0FyLJwvyVOK4wmQg +xEAvg08soTZ87kxgaW+QHCDt8Igu2PQMRGP2zLYrkXIsy9x+rktz31PV5rWhAP/fbNh nuAckvEVYqJrFfJmrYMcDhP+0+i0FOTZ/HB+Fzhyv1d5l6k9cPUIPPbdEWYqS1g0xJWj zDAah2LwrCSj6I4qEaz2wcSFfcLgShQPKzwhKOcfPp7khPFvZH/N99mO3JMgELi0IBsP RMeHlTM5cQBCmsY/JvoqKtJ71rHSh02ffjWyRV2Q6wNK5sNHTYbryTqvVzCuE6d3REbk Kdtw== X-Gm-Message-State: ALyK8tLpUu0vdKitXh1dL03UYxyPB3dcXg+5V7F07yeoyh0EhhxXAzbGFfGmp0Jy5gIyRxDz X-Received: by 10.194.31.137 with SMTP id a9mr2646181wji.113.1467110010186; Tue, 28 Jun 2016 03:33:30 -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.29 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 28 Jun 2016 03:33:29 -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 30/92] clocksource/drivers/h8300_timer8: Convert init function to return error Date: Tue, 28 Jun 2016 12:30:49 +0200 Message-Id: <1467109911-11060-30-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_timer8.c | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) -- 1.9.1 diff --git a/drivers/clocksource/h8300_timer8.c b/drivers/clocksource/h8300_timer8.c index c151941..0292a19 100644 --- a/drivers/clocksource/h8300_timer8.c +++ b/drivers/clocksource/h8300_timer8.c @@ -164,24 +164,26 @@ static struct timer8_priv timer8_priv = { }, }; -static void __init h8300_8timer_init(struct device_node *node) +static int __init h8300_8timer_init(struct device_node *node) { void __iomem *base; - int irq; + int irq, ret; struct clk *clk; clk = of_clk_get(node, 0); if (IS_ERR(clk)) { pr_err("failed to get clock for clockevent\n"); - return; + return PTR_ERR(clk); } + ret = ENXIO; base = of_iomap(node, 0); if (!base) { pr_err("failed to map registers for clockevent\n"); goto free_clk; } + ret = -EINVAL; irq = irq_of_parse_and_map(node, 0); if (!irq) { pr_err("failed to get irq for clockevent\n"); @@ -205,11 +207,12 @@ static void __init h8300_8timer_init(struct device_node *node) clockevents_config_and_register(&timer8_priv.ced, timer8_priv.rate, 1, 0x0000ffff); - return; + return 0; unmap_reg: iounmap(base); free_clk: clk_put(clk); + return ret; } -CLOCKSOURCE_OF_DECLARE(h8300_8bit, "renesas,8bit-timer", h8300_8timer_init); +CLOCKSOURCE_OF_DECLARE_RET(h8300_8bit, "renesas,8bit-timer", h8300_8timer_init);