From patchwork Tue Jun 28 10:31:30 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Lezcano X-Patchwork-Id: 71005 Delivered-To: patch@linaro.org Received: by 10.140.28.4 with SMTP id 4csp1509879qgy; Tue, 28 Jun 2016 03:35:05 -0700 (PDT) X-Received: by 10.98.50.1 with SMTP id y1mr545784pfy.120.1467110105404; Tue, 28 Jun 2016 03:35:05 -0700 (PDT) Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id p6si24933579pai.24.2016.06.28.03.35.05; Tue, 28 Jun 2016 03:35:05 -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 S1753116AbcF1KfB (ORCPT + 30 others); Tue, 28 Jun 2016 06:35:01 -0400 Received: from mail-wm0-f54.google.com ([74.125.82.54]:36513 "EHLO mail-wm0-f54.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752550AbcF1Keg (ORCPT ); Tue, 28 Jun 2016 06:34:36 -0400 Received: by mail-wm0-f54.google.com with SMTP id f126so133944172wma.1 for ; Tue, 28 Jun 2016 03:34:36 -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=4JFbBNZlt4QcsZb1EtcCUL96H3F9QNT5dBIIssrTXD8=; b=aUSLISBb0iARt55cYIYPxBkwqgxawf3hJmMwhHjLSi+BQPit0q+qLKMYR5MQLlBqjI n9fXZNjm/zyqExbvbliGN1C1C7QIwPmTOaibg//p6+n6ir0DY+siPGUJzLNrvpgSV8Qu xks7F4CCtek/ApMxMMuKEltlUInZKKAHGHvyk= 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=4JFbBNZlt4QcsZb1EtcCUL96H3F9QNT5dBIIssrTXD8=; b=bRFkDiFWXJ1uM+BisEKKsDrVGLaWCKtplb7AgveCpsv3xFeVkZ/a3EVfqfiCSGeJBs mw/W9N3qWRHUnw1knW9bIZkR1xoeluQpstyksxYI9MeHF1YjIiXS/Q4cNNtoq4quI0/A 5qXbRXdyoCqpCyDRIUufHFPPCfWg4NRa3kIfqmJkJ08lLvs+RqrkG24jonHeF/rHs6fa qXPZSzhNrp52XBKEhGD3t3+1VuImiVTAGoZOYf3Z34WW1xRACjsf8UfK+Dly/m9DyGgo UXOb7WAaeow8Gb29auCuX+QYezOhdMnHxcB/n621ADAt7Ru/6O1UpLfkSirYqtWBTQBk pgQw== X-Gm-Message-State: ALyK8tK6K9GozJtjZEC+YdMisMOG0FKZ4yVgp32RZ4+61b4vpwzL0YJMVs4RgGeUanhDggL1 X-Received: by 10.194.55.234 with SMTP id v10mr2580445wjp.64.1467110075240; Tue, 28 Jun 2016 03:34:35 -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.34 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 28 Jun 2016 03:34:34 -0700 (PDT) From: Daniel Lezcano To: daniel.lezcano@linaro.org, tglx@linutronix.de Cc: linux-kernel@vger.kernel.org, Neil Armstrong , linux-arm-kernel@lists.infradead.org Subject: [PATCH 71/92] clocksource/drivers/oxnas-rps: Convert init function to return error Date: Tue, 28 Jun 2016 12:31:30 +0200 Message-Id: <1467109911-11060-71-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 Acked-by: Neil Armstrong --- drivers/clocksource/timer-oxnas-rps.c | 33 ++++++++++++++++++++------------- 1 file changed, 20 insertions(+), 13 deletions(-) -- 1.9.1 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);