From patchwork Tue Jun 28 10:31:08 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Lezcano X-Patchwork-Id: 71028 Delivered-To: patch@linaro.org Received: by 10.140.28.4 with SMTP id 4csp1511917qgy; Tue, 28 Jun 2016 03:40:18 -0700 (PDT) X-Received: by 10.66.237.104 with SMTP id vb8mr607641pac.24.1467110418387; Tue, 28 Jun 2016 03:40:18 -0700 (PDT) Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id w74si33075050pfa.169.2016.06.28.03.40.18; Tue, 28 Jun 2016 03:40:18 -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 S932221AbcF1KkN (ORCPT + 30 others); Tue, 28 Jun 2016 06:40:13 -0400 Received: from mail-wm0-f43.google.com ([74.125.82.43]:35214 "EHLO mail-wm0-f43.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752869AbcF1KeD (ORCPT ); Tue, 28 Jun 2016 06:34:03 -0400 Received: by mail-wm0-f43.google.com with SMTP id v199so133612174wmv.0 for ; Tue, 28 Jun 2016 03:33:58 -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=bmdu5mQAy4mF7yKX2sXbSELiVlwBptb+4HpuNXRRPb0=; b=j5mzVuhxc4OGm4PsZNlekGovuhfIl+fU0uijy1aKgu+FXRrD9U4mMbDwFFyi3HIUOD xe3OzakF7wpCO3AB+YJNaevbiagdCmotyTTj8BfTkUtpJ3388tLQNt2xJRFJ6eaxN+dW E82QFBUd1ZxorDhY9IcT3mX60zo8QSeb4XwuY= 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=bmdu5mQAy4mF7yKX2sXbSELiVlwBptb+4HpuNXRRPb0=; b=KYXAXF4JIafe761t3oGejaC6mAxE2z5kV81Q3806Zkp2ayo6we33UJOy/Lq3b4QSYM AdMPcOeYMbhuKR7Ge1v6hdzdoqjQIUOyxyOFvYJzPpBxiEyzAnus4IGeUBktaO0N+oVX ymz1/GVdnxil9uTT3EREeQQ6i8vS4pZbLIRA9+YHTHPgxWwqNtYZ0KYAmyJrykd281FW 3nXTT1eXSDb7uD/xOhn1xbweyrraujEGeAfxGGSof9OHgvTXrKWVLpwkYT750sXziwJb gqjj1Varrgz0xeKhCo1FfcQ3XmNx6w89HUfNJxl3JiQOgWrg3qfVOGEjYx2ZQeWpzvEi QSaQ== X-Gm-Message-State: ALyK8tK+5e7BpElAkJNYJ2lH19TsoxPiv+0Za23whVWEyuk+bUcezpUeXNGGU4QgREtgfVHk X-Received: by 10.194.123.73 with SMTP id ly9mr2621259wjb.21.1467110037238; Tue, 28 Jun 2016 03:33:57 -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.33.56 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 28 Jun 2016 03:33:56 -0700 (PDT) From: Daniel Lezcano To: daniel.lezcano@linaro.org, tglx@linutronix.de Cc: linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org Subject: [PATCH 49/92] clocksource/drivers/atlas7: Convert init function to return error Date: Tue, 28 Jun 2016 12:31:08 +0200 Message-Id: <1467109911-11060-49-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 --- drivers/clocksource/timer-atlas7.c | 32 +++++++++++++++++++------------- 1 file changed, 19 insertions(+), 13 deletions(-) -- 1.9.1 diff --git a/drivers/clocksource/timer-atlas7.c b/drivers/clocksource/timer-atlas7.c index 27fa136..7b1a007 100644 --- a/drivers/clocksource/timer-atlas7.c +++ b/drivers/clocksource/timer-atlas7.c @@ -238,7 +238,7 @@ static struct notifier_block sirfsoc_cpu_nb = { .notifier_call = sirfsoc_cpu_notify, }; -static void __init sirfsoc_clockevent_init(void) +static int __init sirfsoc_clockevent_init(void) { sirfsoc_clockevent = alloc_percpu(struct clock_event_device); BUG_ON(!sirfsoc_clockevent); @@ -246,11 +246,11 @@ static void __init sirfsoc_clockevent_init(void) BUG_ON(register_cpu_notifier(&sirfsoc_cpu_nb)); /* Immediately configure the timer on the boot CPU */ - sirfsoc_local_timer_setup(this_cpu_ptr(sirfsoc_clockevent)); + return sirfsoc_local_timer_setup(this_cpu_ptr(sirfsoc_clockevent)); } /* initialize the kernel jiffy timer source */ -static void __init sirfsoc_atlas7_timer_init(struct device_node *np) +static int __init sirfsoc_atlas7_timer_init(struct device_node *np) { struct clk *clk; @@ -279,23 +279,29 @@ static void __init sirfsoc_atlas7_timer_init(struct device_node *np) BUG_ON(clocksource_register_hz(&sirfsoc_clocksource, atlas7_timer_rate)); - sirfsoc_clockevent_init(); + return sirfsoc_clockevent_init(); } -static void __init sirfsoc_of_timer_init(struct device_node *np) +static int __init sirfsoc_of_timer_init(struct device_node *np) { sirfsoc_timer_base = of_iomap(np, 0); - if (!sirfsoc_timer_base) - panic("unable to map timer cpu registers\n"); + if (!sirfsoc_timer_base) { + pr_err("unable to map timer cpu registers\n"); + return -ENXIO; + } sirfsoc_timer_irq.irq = irq_of_parse_and_map(np, 0); - if (!sirfsoc_timer_irq.irq) - panic("No irq passed for timer0 via DT\n"); + if (!sirfsoc_timer_irq.irq) { + pr_err("No irq passed for timer0 via DT\n"); + return -EINVAL; + } sirfsoc_timer1_irq.irq = irq_of_parse_and_map(np, 1); - if (!sirfsoc_timer1_irq.irq) - panic("No irq passed for timer1 via DT\n"); + if (!sirfsoc_timer1_irq.irq) { + pr_err("No irq passed for timer1 via DT\n"); + return -EINVAL; + } - sirfsoc_atlas7_timer_init(np); + return sirfsoc_atlas7_timer_init(np); } -CLOCKSOURCE_OF_DECLARE(sirfsoc_atlas7_timer, "sirf,atlas7-tick", sirfsoc_of_timer_init); +CLOCKSOURCE_OF_DECLARE_RET(sirfsoc_atlas7_timer, "sirf,atlas7-tick", sirfsoc_of_timer_init);