From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932641AbcFQMuv (ORCPT ); Fri, 17 Jun 2016 08:50:51 -0400 Received: from a.mx.sdesigns.eu ([78.31.43.6]:43401 "EHLO a.mx.sdesigns.eu" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755304AbcFQMuu (ORCPT ); Fri, 17 Jun 2016 08:50:50 -0400 X-Greylist: delayed 929 seconds by postgrey-1.27 at vger.kernel.org; Fri, 17 Jun 2016 08:50:50 EDT Subject: Re: [PATCH V3] clocksource/drivers/tango_xtal: Convert init function to return error To: Daniel Lezcano , Thomas Gleixner Cc: LKML , Mason , Sebastian Frias References: <5763C0BE.8090900@free.fr> <1466159197-23203-1-git-send-email-daniel.lezcano@linaro.org> From: Marc Gonzalez Message-ID: <5763EE87.9010207@sigmadesigns.com> Date: Fri, 17 Jun 2016 14:35:19 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:43.0) Gecko/20100101 Firefox/43.0 SeaMonkey/2.40 MIME-Version: 1.0 In-Reply-To: <1466159197-23203-1-git-send-email-daniel.lezcano@linaro.org> Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 17/06/2016 12:26, 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 ^^^ ^^ "leave the caller unaware of [...]" (?) > 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 ^^^^^^^^^^^ "just returns an error code from the init function" (?) > function. > > Signed-off-by: Daniel Lezcano > --- > drivers/clocksource/tango_xtal.c | 12 +++++++----- > 1 file changed, 7 insertions(+), 5 deletions(-) > > diff --git a/drivers/clocksource/tango_xtal.c b/drivers/clocksource/tango_xtal.c > index c407c47..7dc716c 100644 > --- a/drivers/clocksource/tango_xtal.c > +++ b/drivers/clocksource/tango_xtal.c > @@ -19,7 +19,7 @@ static u64 notrace read_sched_clock(void) > return read_xtal_counter(); > } > > -static void __init tango_clocksource_init(struct device_node *np) > +static int __init tango_clocksource_init(struct device_node *np) > { > struct clk *clk; > int xtal_freq, ret; > @@ -27,13 +27,13 @@ static void __init tango_clocksource_init(struct device_node *np) > xtal_in_cnt = of_iomap(np, 0); > if (xtal_in_cnt == NULL) { > pr_err("%s: invalid address\n", np->full_name); > - return; > + return -ENXIO; > } > > clk = of_clk_get(np, 0); > if (IS_ERR(clk)) { > pr_err("%s: invalid clock\n", np->full_name); > - return; > + return PTR_ERR(clk); > } > > xtal_freq = clk_get_rate(clk); > @@ -44,11 +44,13 @@ static void __init tango_clocksource_init(struct device_node *np) > 32, clocksource_mmio_readl_up); > if (ret) { > pr_err("%s: registration failed\n", np->full_name); > - return; > + return ret; > } > > sched_clock_register(read_sched_clock, 32, xtal_freq); > register_current_timer_delay(&delay_timer); > + > + return 0; > } > > -CLOCKSOURCE_OF_DECLARE(tango, "sigma,tick-counter", tango_clocksource_init); > +CLOCKSOURCE_OF_DECLARE_RET(tango, "sigma,tick-counter", tango_clocksource_init); The code looks good to me. Acked-by: Marc Gonzalez Could you merge, on top of these, the patch we discussed a few weeks ago for changing ret to err? (I will attach the patch to this message.) Regards.