From patchwork Thu Jun 16 21:26:45 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Lezcano X-Patchwork-Id: 70216 Delivered-To: patch@linaro.org Received: by 10.140.28.4 with SMTP id 4csp464644qgy; Thu, 16 Jun 2016 14:29:17 -0700 (PDT) X-Received: by 10.98.149.10 with SMTP id p10mr7519778pfd.88.1466112554520; Thu, 16 Jun 2016 14:29:14 -0700 (PDT) Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id l17si7967338pfa.42.2016.06.16.14.29.14; Thu, 16 Jun 2016 14:29:14 -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 S1755275AbcFPV2m (ORCPT + 30 others); Thu, 16 Jun 2016 17:28:42 -0400 Received: from mail-wm0-f52.google.com ([74.125.82.52]:38211 "EHLO mail-wm0-f52.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755240AbcFPV2h (ORCPT ); Thu, 16 Jun 2016 17:28:37 -0400 Received: by mail-wm0-f52.google.com with SMTP id m124so86959981wme.1 for ; Thu, 16 Jun 2016 14:28:37 -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=BjfcoRqCnnf4g+oy1Dy930ImNq28h7vnTmO6IagbXf8=; b=E6lZi0LwTfVz4kmR2lV7hxW4W5d8kHg+dio9MiE56WxluKpy5LDaIWYz8ELIJHVlbt c79s08sUn+jJKIlqcfeI25nUbXtvF/hcDuh9cnlbWhRjmEDRSUCf6Mb6adc4uNS/FCHQ CFtMCVvVyHx44sdMbUPFY1lFg1obw63ry0cAA= 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=BjfcoRqCnnf4g+oy1Dy930ImNq28h7vnTmO6IagbXf8=; b=UDyDet/ukGgWBaLaujDTUGeIBqKpxloYdCNzPMY7WB4YUZA4TetKO2KsNZOhuL7Ujq gq8odjueafeUwIQ8bWPnRnQu7s+fAktRG/zPLohpKUtuxrWPC9T213+Vc4EGSKUzxvTd L+Aljd70NR6tAnvbakiIELKUoapIVq85kKx2sXAc6uuhg0ca1qOZ6re4wpbv+LwhBo0P 5lx6/v0yjFgjdO4in2DxavUp3JkxQZmqMe5I8b1gpkAkCvA8+htb632ppYo5s9Vtg/O/ ObSgPR82a+tN5N9FrQzYsF3TOEIsa19kAoWrMT0fIsXNPfPIlWskSIJ+kTJQWZ+VC3j3 iniQ== X-Gm-Message-State: ALyK8tLBqQplxGq9zxnuKk6elvNBHVUFYciEeBT2ylVpYtjk9cKr27qZiA2Z+ciKlHC5tlya X-Received: by 10.194.54.102 with SMTP id i6mr1361288wjp.91.1466112516483; Thu, 16 Jun 2016 14:28:36 -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.28.35 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 16 Jun 2016 14:28:35 -0700 (PDT) From: Daniel Lezcano To: daniel.lezcano@linaro.org, tglx@linutronix.de Cc: linux-kernel@vger.kernel.org Subject: [PATCH V2 26/63] clocksource/drivers/nomadik-mtu: Convert init function to return error Date: Thu, 16 Jun 2016 23:26:45 +0200 Message-Id: <1466112442-31105-27-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> 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/mxs_timer.c | 24 +++++++++++++++++------- 1 file changed, 17 insertions(+), 7 deletions(-) -- 1.9.1 diff --git a/drivers/clocksource/mxs_timer.c b/drivers/clocksource/mxs_timer.c index 16cf53b..17b9d19 100644 --- a/drivers/clocksource/mxs_timer.c +++ b/drivers/clocksource/mxs_timer.c @@ -229,7 +229,7 @@ static int __init mxs_clocksource_init(struct clk *timer_clk) static int __init mxs_timer_init(struct device_node *np) { struct clk *timer_clk; - int irq; + int irq, ret; mxs_timrot_base = of_iomap(np, 0); WARN_ON(!mxs_timrot_base); @@ -237,10 +237,12 @@ static int __init mxs_timer_init(struct device_node *np) timer_clk = of_clk_get(np, 0); if (IS_ERR(timer_clk)) { pr_err("%s: failed to get clk\n", __func__); - return; + return PTR_ERR(timer_clk); } - clk_prepare_enable(timer_clk); + ret = clk_prepare_enable(timer_clk); + if (ret) + return ret; /* * Initialize timers to a known state @@ -278,11 +280,19 @@ static int __init mxs_timer_init(struct device_node *np) mxs_timrot_base + HW_TIMROT_FIXED_COUNTn(1)); /* init and register the timer to the framework */ - mxs_clocksource_init(timer_clk); - mxs_clockevent_init(timer_clk); + ret = mxs_clocksource_init(timer_clk); + if (ret) + return ret; + + ret = mxs_clockevent_init(timer_clk); + if (ret) + return ret; /* Make irqs happen */ irq = irq_of_parse_and_map(np, 0); - setup_irq(irq, &mxs_timer_irq); + if (irq <= 0) + return -EINVAL; + + return setup_irq(irq, &mxs_timer_irq); } -CLOCKSOURCE_OF_DECLARE(mxs, "fsl,timrot", mxs_timer_init); +CLOCKSOURCE_OF_DECLARE_RET(mxs, "fsl,timrot", mxs_timer_init);