From patchwork Thu Jun 16 21:26:37 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Lezcano X-Patchwork-Id: 70214 Delivered-To: patch@linaro.org Received: by 10.140.28.4 with SMTP id 4csp464633qgy; Thu, 16 Jun 2016 14:29:13 -0700 (PDT) X-Received: by 10.98.77.65 with SMTP id a62mr7560142pfb.128.1466112553842; Thu, 16 Jun 2016 14:29:13 -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.13; Thu, 16 Jun 2016 14:29:13 -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 S932179AbcFPV2f (ORCPT + 30 others); Thu, 16 Jun 2016 17:28:35 -0400 Received: from mail-wm0-f51.google.com ([74.125.82.51]:38129 "EHLO mail-wm0-f51.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755202AbcFPV21 (ORCPT ); Thu, 16 Jun 2016 17:28:27 -0400 Received: by mail-wm0-f51.google.com with SMTP id m124so86955215wme.1 for ; Thu, 16 Jun 2016 14:28:26 -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=z06mtoC6CIZAiWYrrSLKltSeDBdvZjZ1M9Y7nBD6lO8=; b=cEyxeVIeugxmO+AEHHBIj2jAFVLt9CbmK1toaNWzvm2YOSQcaVf1aHBTjvvb/uB6GG 2H9EecpsPrTesH3j8VBKZNAygMlvPrKWTcliyzVbFFCdOmIV4mr2lgcn6UhGp3FqcHLw tRAhF4nrAPO4dU9E+RUC5K/R275IK4aGobRo0= 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=z06mtoC6CIZAiWYrrSLKltSeDBdvZjZ1M9Y7nBD6lO8=; b=b44vyQ8mCtbCCDezZpbOxuKxdd+VR/DmhRyQf+GvCUSmNDZT7/Yy0vXYd8S2CcwHYv wvnDSD52dd3eXl9sPVRhEmZJU7ph9ihzapeWU9UTaI3l7KPvQe7hY3CnRzjytuti7bMy qnnhjo+JQmOBlcfhUuNhmT6jnFpigBQiOk9hnM9LS/AfO2CMuX8aygZLJFJkPOfiuSe/ 9jNDUEburB2d8o7MjHPqduMEcaKzG6/mQT3FKJvGlI4dXJDzm6JKnAZY3M00spBB6vKK dOtLku+dLjK49+ZZWARZm46jt9Vb7fcp2yLYpHDfMjy7ddknIqlY06mMpjc86voYPtfQ mArg== X-Gm-Message-State: ALyK8tLEFlmWv4l8x3eLGinxDmFpcW0m+JD4Cmo54V05LyqUNgZIJa0RyigJPsEpVul0/ABL X-Received: by 10.194.151.73 with SMTP id uo9mr1325800wjb.177.1466112506028; Thu, 16 Jun 2016 14:28:26 -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.24 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 16 Jun 2016 14:28:25 -0700 (PDT) From: Daniel Lezcano To: daniel.lezcano@linaro.org, tglx@linutronix.de Cc: linux-kernel@vger.kernel.org, Srinivas Kandagatla , Maxime Coquelin , Patrice Chotard , linux-arm-kernel@lists.infradead.org (moderated list:ARM/STI ARCHITECTURE), kernel@stlinux.com (open list:ARM/STI ARCHITECTURE) Subject: [PATCH V2 18/63] clocksource/drivers/arm_global_timer: Convert init function to return error Date: Thu, 16 Jun 2016 23:26:37 +0200 Message-Id: <1466112442-31105-19-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/arm_global_timer.c | 28 ++++++++++++++++++---------- 1 file changed, 18 insertions(+), 10 deletions(-) -- 1.9.1 Acked-by: Maxime Coquelin diff --git a/drivers/clocksource/arm_global_timer.c b/drivers/clocksource/arm_global_timer.c index 9df0d16..40104fc 100644 --- a/drivers/clocksource/arm_global_timer.c +++ b/drivers/clocksource/arm_global_timer.c @@ -238,7 +238,7 @@ static void __init gt_delay_timer_init(void) register_current_timer_delay(>_delay_timer); } -static void __init gt_clocksource_init(void) +static int __init gt_clocksource_init(void) { writel(0, gt_base + GT_CONTROL); writel(0, gt_base + GT_COUNTER0); @@ -249,7 +249,7 @@ static void __init gt_clocksource_init(void) #ifdef CONFIG_CLKSRC_ARM_GLOBAL_TIMER_SCHED_CLOCK sched_clock_register(gt_sched_clock_read, 64, gt_clk_rate); #endif - clocksource_register_hz(>_clocksource, gt_clk_rate); + return clocksource_register_hz(>_clocksource, gt_clk_rate); } static int gt_cpu_notify(struct notifier_block *self, unsigned long action, @@ -270,7 +270,7 @@ static struct notifier_block gt_cpu_nb = { .notifier_call = gt_cpu_notify, }; -static void __init global_timer_of_register(struct device_node *np) +static int __init global_timer_of_register(struct device_node *np) { struct clk *gt_clk; int err = 0; @@ -283,19 +283,19 @@ static void __init global_timer_of_register(struct device_node *np) if (read_cpuid_part() == ARM_CPU_PART_CORTEX_A9 && (read_cpuid_id() & 0xf0000f) < 0x200000) { pr_warn("global-timer: non support for this cpu version.\n"); - return; + return -ENOSYS; } gt_ppi = irq_of_parse_and_map(np, 0); if (!gt_ppi) { pr_warn("global-timer: unable to parse irq\n"); - return; + return -EINVAL; } gt_base = of_iomap(np, 0); if (!gt_base) { pr_warn("global-timer: invalid base address\n"); - return; + return -ENXIO; } gt_clk = of_clk_get(np, 0); @@ -332,11 +332,17 @@ static void __init global_timer_of_register(struct device_node *np) } /* Immediately configure the timer on the boot CPU */ - gt_clocksource_init(); - gt_clockevents_init(this_cpu_ptr(gt_evt)); + err = gt_clocksource_init(); + if (err) + goto out_irq; + + err = gt_clockevents_init(this_cpu_ptr(gt_evt)); + if (err) + goto out_irq; + gt_delay_timer_init(); - return; + return 0; out_irq: free_percpu_irq(gt_ppi, gt_evt); @@ -347,8 +353,10 @@ out_clk: out_unmap: iounmap(gt_base); WARN(err, "ARM Global timer register failed (%d)\n", err); + + return err; } /* Only tested on r2p2 and r3p0 */ -CLOCKSOURCE_OF_DECLARE(arm_gt, "arm,cortex-a9-global-timer", +CLOCKSOURCE_OF_DECLARE_RET(arm_gt, "arm,cortex-a9-global-timer", global_timer_of_register);