From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756252AbcFTRZn (ORCPT ); Mon, 20 Jun 2016 13:25:43 -0400 Received: from mail-pf0-f178.google.com ([209.85.192.178]:35636 "EHLO mail-pf0-f178.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753027AbcFTRW0 (ORCPT ); Mon, 20 Jun 2016 13:22:26 -0400 Subject: Re: [PATCH V2 14/63] clocksource/drivers/bcm_kona: Convert init function to return error To: Daniel Lezcano , tglx@linutronix.de References: <1466112442-31105-1-git-send-email-daniel.lezcano@linaro.org> <1466112442-31105-15-git-send-email-daniel.lezcano@linaro.org> Cc: linux-kernel@vger.kernel.org, Florian Fainelli , Ray Jui , Scott Branden , "open list:BROADCOM BCM281XX..." From: Ray Jui Message-ID: <707bd49d-5aea-485f-4efc-6d1d5e8d7506@broadcom.com> Date: Mon, 20 Jun 2016 10:22:08 -0700 User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:45.0) Gecko/20100101 Thunderbird/45.2 MIME-Version: 1.0 In-Reply-To: <1466112442-31105-15-git-send-email-daniel.lezcano@linaro.org> Content-Type: text/plain; charset=windows-1252; format=flowed Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Daniel, On 6/16/2016 2:26 PM, Daniel Lezcano wrote: > 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/bcm_kona_timer.c | 12 +++++++----- > 1 file changed, 7 insertions(+), 5 deletions(-) > > diff --git a/drivers/clocksource/bcm_kona_timer.c b/drivers/clocksource/bcm_kona_timer.c > index e717e87..98bc2a2 100644 > --- a/drivers/clocksource/bcm_kona_timer.c > +++ b/drivers/clocksource/bcm_kona_timer.c > @@ -163,14 +163,14 @@ static struct irqaction kona_timer_irq = { > .handler = kona_timer_interrupt, > }; > > -static void __init kona_timer_init(struct device_node *node) > +static int __init kona_timer_init(struct device_node *node) > { > u32 freq; > struct clk *external_clk; > > if (!of_device_is_available(node)) { > pr_info("Kona Timer v1 marked as disabled in device tree\n"); > - return; > + return 0; I thought we should return -ENODEV here. Moreover, if this device node is not enabled, kona_timer_init won't even be invoked. Can we simply get rid of this check here? > } > > external_clk = of_clk_get_by_name(node, NULL); > @@ -182,7 +182,7 @@ static void __init kona_timer_init(struct device_node *node) > arch_timer_rate = freq; > } else { > pr_err("Kona Timer v1 unable to determine clock-frequency"); > - return; > + return -EINVAL; > } > > /* Setup IRQ numbers */ > @@ -196,11 +196,13 @@ static void __init kona_timer_init(struct device_node *node) > kona_timer_clockevents_init(); > setup_irq(timers.tmr_irq, &kona_timer_irq); > kona_timer_set_next_event((arch_timer_rate / HZ), NULL); > + > + return 0; > } > > -CLOCKSOURCE_OF_DECLARE(brcm_kona, "brcm,kona-timer", kona_timer_init); > +CLOCKSOURCE_OF_DECLARE_RET(brcm_kona, "brcm,kona-timer", kona_timer_init); > /* > * bcm,kona-timer is deprecated by brcm,kona-timer > * being kept here for driver compatibility > */ > -CLOCKSOURCE_OF_DECLARE(bcm_kona, "bcm,kona-timer", kona_timer_init); > +CLOCKSOURCE_OF_DECLARE_RET(bcm_kona, "bcm,kona-timer", kona_timer_init); > Thanks, Ray