From patchwork Wed Jun 1 08:34:47 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Lezcano X-Patchwork-Id: 68984 Delivered-To: patch@linaro.org Received: by 10.140.92.199 with SMTP id b65csp2402368qge; Wed, 1 Jun 2016 01:36:03 -0700 (PDT) X-Received: by 10.98.25.212 with SMTP id 203mr6125086pfz.94.1464770161369; Wed, 01 Jun 2016 01:36:01 -0700 (PDT) Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id f191si49677911pfc.101.2016.06.01.01.36.01; Wed, 01 Jun 2016 01:36:01 -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 S1757778AbcFAIfm (ORCPT + 30 others); Wed, 1 Jun 2016 04:35:42 -0400 Received: from mail-wm0-f41.google.com ([74.125.82.41]:36647 "EHLO mail-wm0-f41.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1757518AbcFAIfi (ORCPT ); Wed, 1 Jun 2016 04:35:38 -0400 Received: by mail-wm0-f41.google.com with SMTP id n184so19433912wmn.1 for ; Wed, 01 Jun 2016 01:35: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=DHx7k25J9gTUZGWBJtiBe/AXQfH4gokvau1ccoCEJ4w=; b=N6O0/2VMTD43LjtCVxnn8CtwXwg45RyFyjzQ6rVfJKv3iDjkukVV7I6g52i/2fI5Vb ELWMDu/+RetI/Ozp19eO8fJPI9wf5o3gbzjw7o0psQn/TEEpcqDiNEwM3lI6LZLR+i1t sBwEh/TJT141ysV3nSEv6l2EsNONgDs+A/9RQ= 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=DHx7k25J9gTUZGWBJtiBe/AXQfH4gokvau1ccoCEJ4w=; b=RZhO39fZZ3w83qOloOcYFx2Iqit8iN81JDXO1iyamD2JVKcR5GbJVS/1AZykv8s4+V CmS5nmrUj5FY0j0/G/MAYDan2DTEdluhUJZWaADxtXILk41rxPeBixagkvHr//EWAHf/ KAIxrE35OjEkoe6v4vf92+88B5FlBI1bi/SUNND1Whq0Ipm6llwcKiA4QSB6TQ5hq/BE 6HSn/cFjd8wD3hm7fkWSDrly0UFYHcuEoJIOzIUkhp96PZWMmHZfUm+sJjPu5dePZzhK Lls3hkwBwCmNknzXxDjj0yCK990blLUF0eoYkMazA0JTK3gA48h3koPsTo9Rnc6buE4x XdWg== X-Gm-Message-State: ALyK8tIr2R30K/M8c6YOmYn9qAug6Qytj/fuMGIoXSaGYna0CVOtKQRCtsLRNInQyoK3qUUa X-Received: by 10.28.210.72 with SMTP id j69mr19405136wmg.85.1464770136715; Wed, 01 Jun 2016 01:35: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 t3sm33542865wmf.20.2016.06.01.01.35.35 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 01 Jun 2016 01:35:36 -0700 (PDT) From: Daniel Lezcano To: daniel.lezcano@linaro.org, tglx@linutronix.de Cc: linux-kernel@vger.kernel.org, Matthias Brugger , linux-arm-kernel@lists.infradead.org (moderated list:ARM/Mediatek SoC...), linux-mediatek@lists.infradead.org (moderated list:ARM/Mediatek SoC...) Subject: [PATCH 4/9] clocksource/drivers/mkt_timer: Convert init function to return error Date: Wed, 1 Jun 2016 10:34:47 +0200 Message-Id: <1464770093-12667-5-git-send-email-daniel.lezcano@linaro.org> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1464770093-12667-1-git-send-email-daniel.lezcano@linaro.org> References: <1464770093-12667-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/mtk_timer.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) -- 1.9.1 diff --git a/drivers/clocksource/mtk_timer.c b/drivers/clocksource/mtk_timer.c index 7e583f8..432a2c0 100644 --- a/drivers/clocksource/mtk_timer.c +++ b/drivers/clocksource/mtk_timer.c @@ -181,7 +181,7 @@ static void mtk_timer_enable_irq(struct mtk_clock_event_device *evt, u8 timer) evt->gpt_base + GPT_IRQ_EN_REG); } -static void __init mtk_timer_init(struct device_node *node) +static int __init mtk_timer_init(struct device_node *node) { struct mtk_clock_event_device *evt; struct resource res; @@ -190,7 +190,7 @@ static void __init mtk_timer_init(struct device_node *node) evt = kzalloc(sizeof(*evt), GFP_KERNEL); if (!evt) - return; + return -ENOMEM; evt->dev.name = "mtk_tick"; evt->dev.rating = 300; @@ -248,7 +248,7 @@ static void __init mtk_timer_init(struct device_node *node) mtk_timer_enable_irq(evt, GPT_CLK_EVT); - return; + return 0; err_clk_disable: clk_disable_unprepare(clk); @@ -262,5 +262,7 @@ err_mem: release_mem_region(res.start, resource_size(&res)); err_kzalloc: kfree(evt); + + return -EINVAL; } -CLOCKSOURCE_OF_DECLARE(mtk_mt6577, "mediatek,mt6577-timer", mtk_timer_init); +CLOCKSOURCE_OF_DECLARE_RET(mtk_mt6577, "mediatek,mt6577-timer", mtk_timer_init);