From patchwork Thu Jun 16 21:27: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: 9181701 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 6AB3960776 for ; Thu, 16 Jun 2016 21:35:11 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 5BC632837E for ; Thu, 16 Jun 2016 21:35:11 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 4EB5728384; Thu, 16 Jun 2016 21:35:11 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-4.1 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_MED, T_DKIM_INVALID autolearn=unavailable version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.9]) (using TLSv1.2 with cipher AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id F19842837E for ; Thu, 16 Jun 2016 21:35:10 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1bDev0-0001tw-5s; Thu, 16 Jun 2016 21:33:42 +0000 Received: from mail-wm0-x234.google.com ([2a00:1450:400c:c09::234]) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1bDerP-00043F-4g for linux-arm-kernel@lists.infradead.org; Thu, 16 Jun 2016 21:30:11 +0000 Received: by mail-wm0-x234.google.com with SMTP id f126so66430224wma.1 for ; Thu, 16 Jun 2016 14:29:39 -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=FpGgJkmIFyOjZ6cRVgvGQpVqRSCH79OxIdzn9CM8O7Y=; b=HTx8ROhE/kw6MSlxGRE14bxfds9FsUgljmUeE0xLv9n6qRdhtqe/GPAEgVBtRJENfF /C/iW7UWU5s/EyyL+wMFRqiZ6eljGL7Enj+1ShdXvzE/VdZjm3WHKj+9pxQ8miPmW+ve H0QqMoechwYhIKcOh+4zBM0Kb3QwRUjHGjLT0= 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=FpGgJkmIFyOjZ6cRVgvGQpVqRSCH79OxIdzn9CM8O7Y=; b=Usn6NoTYICuhWbsGXUI/J2/WR27dQPok8PUH61hYcQNZKnABaklHFyt7mgrGCaqd/1 dTzERoX0grE3agcsgJSPMACeFpAopaFfQMK0FEXWvxMnA/lQuW9Krw2AZppLni4t85Bm jc36E4dXwGZqHISA8u/ykbudJ5tiKaa8q6HD0dyIDv4x3sVTiDwcB93hpI9dN//6PZ/V DlUll3iCwH3i/v4VOc6cC2k5K/uAS7HIziIZSc1nNblStqL8xWuOlBqPWp3uLHBkYj9T +TlhVkq2DMk8JrJ4TJjCWyoJ4dVPSn6rMDWNrwBE1DI/zSh4G/v/5ZoF9yFQOicS/EgM Y79g== X-Gm-Message-State: ALyK8tIT25/r0AiNMMXY3hLWo191xfuLzs5xVHcpXqoS+uMRusofdE4lMPb00nrdSkdPi3Jx X-Received: by 10.28.191.193 with SMTP id o62mr8112280wmi.64.1466112577752; Thu, 16 Jun 2016 14:29:37 -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 x128sm16705606wmf.6.2016.06.16.14.29.36 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 16 Jun 2016 14:29:36 -0700 (PDT) From: Daniel Lezcano To: daniel.lezcano@linaro.org, tglx@linutronix.de Subject: [PATCH V2 62/63] clocksource/drivers/oxnas-rps: Convert init function to return error Date: Thu, 16 Jun 2016 23:27:21 +0200 Message-Id: <1466112442-31105-63-git-send-email-daniel.lezcano@linaro.org> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1466112442-31105-1-git-send-email-daniel.lezcano@linaro.org> References: <1466112442-31105-1-git-send-email-daniel.lezcano@linaro.org> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20160616_142959_900982_A1A25FDE X-CRM114-Status: GOOD ( 15.81 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: linux-kernel@vger.kernel.org, "moderated list:ARM/OXNAS platfor..." , Neil Armstrong MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP 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 Acked-by: Neil Armstrong --- drivers/clocksource/timer-oxnas-rps.c | 33 ++++++++++++++++++++------------- 1 file changed, 20 insertions(+), 13 deletions(-) diff --git a/drivers/clocksource/timer-oxnas-rps.c b/drivers/clocksource/timer-oxnas-rps.c index c002e99..0d99f40 100644 --- a/drivers/clocksource/timer-oxnas-rps.c +++ b/drivers/clocksource/timer-oxnas-rps.c @@ -220,32 +220,37 @@ static int __init oxnas_rps_clocksource_init(struct oxnas_rps_timer *rps) return 0; } -static void __init oxnas_rps_timer_init(struct device_node *np) +static int __init oxnas_rps_timer_init(struct device_node *np) { struct oxnas_rps_timer *rps; void __iomem *base; int ret; rps = kzalloc(sizeof(*rps), GFP_KERNEL); - if (!rps) { - pr_err("Failed to allocate rps structure\n"); - return; - } + if (!rps) + return -ENOMEM; rps->clk = of_clk_get(np, 0); - if (WARN_ON(IS_ERR(rps->clk))) + if (IS_ERR(rps->clk)) { + ret = PTR_ERR(rps->clk); goto err_alloc; + } - if (WARN_ON(clk_prepare_enable(rps->clk))) + ret = clk_prepare_enable(rps->clk); + if (ret) goto err_clk; base = of_iomap(np, 0); - if (WARN_ON(!base)) + if (!base) { + ret = -ENXIO; goto err_clk_prepare; + } rps->irq = irq_of_parse_and_map(np, 0); - if (WARN_ON(rps->irq < 0)) + if (rps->irq < 0) { + ret = -EINVAL; goto err_iomap; + } rps->clkevt_base = base + TIMER1_REG_OFFSET; rps->clksrc_base = base + TIMER2_REG_OFFSET; @@ -261,7 +266,7 @@ static void __init oxnas_rps_timer_init(struct device_node *np) ret = request_irq(rps->irq, oxnas_rps_timer_irq, IRQF_TIMER | IRQF_IRQPOLL, "rps-timer", rps); - if (WARN_ON(ret)) + if (ret) goto err_iomap; ret = oxnas_rps_clocksource_init(rps); @@ -272,7 +277,7 @@ static void __init oxnas_rps_timer_init(struct device_node *np) if (ret) goto err_irqreq; - return; + return 0; err_irqreq: free_irq(rps->irq, rps); @@ -284,7 +289,9 @@ err_clk: clk_put(rps->clk); err_alloc: kfree(rps); + + return ret; } -CLOCKSOURCE_OF_DECLARE(ox810se_rps, - "oxsemi,ox810se-rps-timer", oxnas_rps_timer_init); +CLOCKSOURCE_OF_DECLARE_RET(ox810se_rps, + "oxsemi,ox810se-rps-timer", oxnas_rps_timer_init);