From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755380AbcFQIyj (ORCPT ); Fri, 17 Jun 2016 04:54:39 -0400 Received: from nbd.name ([46.4.11.11]:43050 "EHLO nbd.name" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754013AbcFQIyh (ORCPT ); Fri, 17 Jun 2016 04:54:37 -0400 Subject: Re: [PATCH V2 57/63] clocksource/drivers/ralink: 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-58-git-send-email-daniel.lezcano@linaro.org> Cc: linux-kernel@vger.kernel.org, Ralf Baechle , "open list:RALINK MIPS ARCHI..." From: John Crispin Message-ID: <23a1568b-59c2-d0e6-ae26-27df16240398@phrozen.org> Date: Fri, 17 Jun 2016 10:54:34 +0200 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.10; rv:45.0) Gecko/20100101 Thunderbird/45.1.1 MIME-Version: 1.0 In-Reply-To: <1466112442-31105-58-git-send-email-daniel.lezcano@linaro.org> Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 16/06/2016 23:27, 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 Acked-by: John Crispin > --- > arch/mips/ralink/cevt-rt3352.c | 19 +++++++++++++------ > 1 file changed, 13 insertions(+), 6 deletions(-) > > diff --git a/arch/mips/ralink/cevt-rt3352.c b/arch/mips/ralink/cevt-rt3352.c > index 3ad0b07..f2d3c79 100644 > --- a/arch/mips/ralink/cevt-rt3352.c > +++ b/arch/mips/ralink/cevt-rt3352.c > @@ -117,11 +117,13 @@ static int systick_set_oneshot(struct clock_event_device *evt) > return 0; > } > > -static void __init ralink_systick_init(struct device_node *np) > +static int __init ralink_systick_init(struct device_node *np) > { > + int ret; > + > systick.membase = of_iomap(np, 0); > if (!systick.membase) > - return; > + return -ENXIO; > > systick_irqaction.name = np->name; > systick.dev.name = np->name; > @@ -131,16 +133,21 @@ static void __init ralink_systick_init(struct device_node *np) > systick.dev.irq = irq_of_parse_and_map(np, 0); > if (!systick.dev.irq) { > pr_err("%s: request_irq failed", np->name); > - return; > + return -EINVAL; > } > > - clocksource_mmio_init(systick.membase + SYSTICK_COUNT, np->name, > - SYSTICK_FREQ, 301, 16, clocksource_mmio_readl_up); > + ret = clocksource_mmio_init(systick.membase + SYSTICK_COUNT, np->name, > + SYSTICK_FREQ, 301, 16, > + clocksource_mmio_readl_up); > + if (ret) > + return ret; > > clockevents_register_device(&systick.dev); > > pr_info("%s: running - mult: %d, shift: %d\n", > np->name, systick.dev.mult, systick.dev.shift); > + > + return 0; > } > > -CLOCKSOURCE_OF_DECLARE(systick, "ralink,cevt-systick", ralink_systick_init); > +CLOCKSOURCE_OF_DECLARE_RET(systick, "ralink,cevt-systick", ralink_systick_init); >