From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1758489AbcFAOge (ORCPT ); Wed, 1 Jun 2016 10:36:34 -0400 Received: from mail-bl2nam02on0079.outbound.protection.outlook.com ([104.47.38.79]:62691 "EHLO NAM02-BL2-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1753115AbcFAOgd (ORCPT ); Wed, 1 Jun 2016 10:36:33 -0400 Authentication-Results: spf=pass (sender IP is 149.199.60.100) smtp.mailfrom=xilinx.com; lists.infradead.org; dkim=none (message not signed) header.d=none;lists.infradead.org; dmarc=bestguesspass action=none header.from=xilinx.com; Date: Wed, 1 Jun 2016 07:36:22 -0700 From: =?utf-8?B?U8O2cmVu?= Brinkmann To: Daniel Lezcano CC: , , Michal Simek , "moderated list:ARM/ZYNQ ARCHITEC..." Subject: Re: [PATCH 7/9] clocksource/drivers/cadence_ttc: Convert init function to return error Message-ID: <20160601143622.GA3766@xsjsorenbubuntu> References: <1464770093-12667-1-git-send-email-daniel.lezcano@linaro.org> <1464770093-12667-8-git-send-email-daniel.lezcano@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <1464770093-12667-8-git-send-email-daniel.lezcano@linaro.org> User-Agent: Mutt/1.5.24 (2015-08-30) X-RCIS-Action: ALLOW X-TM-AS-Product-Ver: IMSS-7.1.0.1224-8.0.0.1202-22364.000 X-TM-AS-User-Approved-Sender: Yes;Yes X-EOPAttributedMessage: 0 X-Forefront-Antispam-Report: CIP:149.199.60.100;IPV:NLI;CTRY:US;EFV:NLI;SFV:NSPM;SFS:(10009020)(6009001)(2980300002)(438002)(24454002)(199003)(377424004)(189002)(9170700003)(50466002)(83506001)(4326007)(92566002)(9786002)(86362001)(6806005)(85202003)(8676002)(81166006)(5008740100001)(19580395003)(110136002)(87936001)(33716001)(4001350100001)(2906002)(57986006)(33656002)(85182001)(76506005)(23676002)(9686002)(189998001)(36386004)(50986999)(77096005)(47776003)(76176999)(2950100001)(19580405001)(63266004)(11100500001)(586003)(2870700001)(1076002)(106466001)(54356999)(8936002)(107986001);DIR:OUT;SFP:1101;SCL:1;SRVR:SN1NAM02HT220;H:xsj-pvapsmtpgw02;FPR:;SPF:Pass;MLV:sfv;A:1;MX:1;LANG:en; X-MS-Office365-Filtering-Correlation-Id: 30899d08-d2c0-421b-bfee-08d38a2a1f56 X-Microsoft-Antispam: UriScan:;BCL:0;PCL:0;RULEID:(8251501002);SRVR:SN1NAM02HT220; X-Microsoft-Antispam-PRVS: <40bca823446345c78b543e75c4d1da61@SN1NAM02HT220.eop-nam02.prod.protection.outlook.com> X-Exchange-Antispam-Report-Test: UriScan:; X-Exchange-Antispam-Report-CFA-Test: BCL:0;PCL:0;RULEID:(601004)(2401047)(13015025)(13017025)(5005006)(13023025)(8121501046)(13024025)(13018025)(3002001)(10201501046)(6055026);SRVR:SN1NAM02HT220;BCL:0;PCL:0;RULEID:;SRVR:SN1NAM02HT220; X-Forefront-PRVS: 096029FF66 X-OriginatorOrg: xilinx.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 01 Jun 2016 14:36:30.5753 (UTC) X-MS-Exchange-CrossTenant-Id: 657af505-d5df-48d0-8300-c31994686c5c X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=657af505-d5df-48d0-8300-c31994686c5c;Ip=[149.199.60.100];Helo=[xsj-pvapsmtpgw02] X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: SN1NAM02HT220 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Daniel, On Wed, 2016-06-01 at 10:34:50 +0200, 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/cadence_ttc_timer.c | 82 +++++++++++++++++++-------------- > 1 file changed, 48 insertions(+), 34 deletions(-) > [...] > ttcce->ttc.clk_rate_change_nb.notifier_call = > ttc_rate_change_clockevent_cb; > ttcce->ttc.clk_rate_change_nb.next = NULL; > - if (clk_notifier_register(ttcce->ttc.clk, > - &ttcce->ttc.clk_rate_change_nb)) > + > + err = clk_notifier_register(ttcce->ttc.clk, > + &ttcce->ttc.clk_rate_change_nb); > + if (err) { > pr_warn("Unable to register clock notifier.\n"); > + return err; So far we handle this as warning only and move on, as the notifier is only needed when frequency scaling is enabled. And even then, the effect is usually just that timing is off. > + } > + > ttcce->ttc.freq = clk_get_rate(ttcce->ttc.clk); > > ttcce->ttc.base_addr = base; > @@ -451,13 +462,15 @@ static void __init ttc_setup_clockevent(struct clk *clk, > > err = request_irq(irq, ttc_clock_event_interrupt, > IRQF_TIMER, ttcce->ce.name, ttcce); > - if (WARN_ON(err)) { > + if (err) { > kfree(ttcce); > - return; > + return err; > } > > clockevents_config_and_register(&ttcce->ce, > ttcce->ttc.freq / PRESCALE, 1, 0xfffe); > + > + return 0; > } > > /** > @@ -466,20 +479,14 @@ static void __init ttc_setup_clockevent(struct clk *clk, > * Initializes the timer hardware and register the clock source and clock event > * timers with Linux kernal timer framework > */ > -static void __init ttc_timer_init(struct device_node *timer) > +static int __init ttc_timer_init(struct device_node *timer) > { > unsigned int irq; > void __iomem *timer_baseaddr; > struct clk *clk_cs, *clk_ce; > - static int initialized; > - int clksel; > + int clksel, ret; > u32 timer_width = 16; > > - if (initialized) > - return; > - > - initialized = 1; > - This also changes behavior. We have multiple of these timer modules in our HW and we don't want them all to be used for time keeping. This construct made sure that we only use the first timer for which init is called leaving the others for non-OS purposes. Sören