Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752575AbbDAPTG (ORCPT ); Wed, 1 Apr 2015 11:19:06 -0400 Received: from smtprelay0186.hostedemail.com ([216.40.44.186]:41119 "EHLO smtprelay.hostedemail.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1752400AbbDAPTA (ORCPT ); Wed, 1 Apr 2015 11:19:00 -0400 X-Session-Marker: 6A6F6540706572636865732E636F6D X-Spam-Summary: 2,0,0,,d41d8cd98f00b204,joe@perches.com,:::::::::::::::::,RULES_HIT:41:355:379:541:599:800:960:973:988:989:1260:1277:1311:1313:1314:1345:1359:1373:1437:1515:1516:1518:1534:1542:1593:1594:1605:1711:1730:1747:1777:1792:2393:2551:2553:2559:2562:2740:2828:3138:3139:3140:3141:3142:3622:3865:3866:3867:3868:3870:3871:3872:3873:3874:4250:4321:4470:5007:6261:6298:7576:7875:7903:8660:10004:10400:10848:11026:11232:11473:11658:11914:12043:12050:12296:12438:12517:12519:12555:12740:13095:13148:13230:14096:14097:21080,0,RBL:none,CacheIP:none,Bayesian:0.5,0.5,0.5,Netcheck:none,DomainCache:0,MSF:not bulk,SPF:fn,MSBL:0,DNSBL:none,Custom_rules:0:0:0 X-HE-Tag: bone80_4e3d87da40f3b X-Filterd-Recvd-Size: 4214 Message-ID: <1427901535.31790.10.camel@perches.com> Subject: Re: [PATCH] mtd: fsl_ifc_nand: use msecs_to_jiffies for time conversion From: Joe Perches To: Aaron Sierra Cc: Nicholas Mc Guire , Nicholas Mc Guire , David Woodhouse , Brian Norris , Joe Schultz , Wolfram Sang , linux-mtd@lists.infradead.org, linux-kernel@vger.kernel.org Date: Wed, 01 Apr 2015 08:18:55 -0700 In-Reply-To: <699783288.22321.1427900904422.JavaMail.zimbra@xes-inc.com> References: <1426245828-15640-1-git-send-email-hofrat@osadl.org> <1162655988.11370.1427896685060.JavaMail.zimbra@xes-inc.com> <20150401142444.GA12125@opentech.at> <699783288.22321.1427900904422.JavaMail.zimbra@xes-inc.com> Content-Type: text/plain; charset="ISO-8859-1" X-Mailer: Evolution 3.12.10-0ubuntu1~14.10.1 Mime-Version: 1.0 Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 3151 Lines: 77 On Wed, 2015-04-01 at 10:08 -0500, Aaron Sierra wrote: > ----- Original Message ----- > > From: "Nicholas Mc Guire" > > Sent: Wednesday, April 1, 2015 9:24:44 AM > > > > On Wed, 01 Apr 2015, Aaron Sierra wrote: > > > > > ----- Original Message ----- > > > > From: "Nicholas Mc Guire" > > > > Sent: Friday, March 13, 2015 6:23:47 AM > > > > > > > > This is only an API consolidation and should make things more readable > > > > it replaces var * HZ / 1000 by msecs_to_jiffies(var) which helps > > > > readability > > > > and also handles all corner-cases properly. > > > > > > > > Signed-off-by: Nicholas Mc Guire > > > > --- > > > > > > > > Patch was compile tested with corenet64_smp_defconfig > > > > (implies CONFIG_MTD_NAND_FSL_IFC=y) > > > > > > > > Patch is against 4.0-rc3 (localversion-next is -next-20150313 > > > > > > > > drivers/mtd/nand/fsl_ifc_nand.c | 4 ++-- > > > > 1 file changed, 2 insertions(+), 2 deletions(-) > > > > > > > > diff --git a/drivers/mtd/nand/fsl_ifc_nand.c > > > > b/drivers/mtd/nand/fsl_ifc_nand.c > > > > index 4c05f4f..51394e5 100644 > > > > --- a/drivers/mtd/nand/fsl_ifc_nand.c > > > > +++ b/drivers/mtd/nand/fsl_ifc_nand.c > > > > @@ -317,7 +317,7 @@ static void fsl_ifc_run_command(struct mtd_info *mtd) > > > > > > > > /* wait for command complete flag or timeout */ > > > > wait_event_timeout(ctrl->nand_wait, ctrl->nand_stat, > > > > - IFC_TIMEOUT_MSECS * HZ/1000); > > > > + msecs_to_jiffies(IFC_TIMEOUT_MSECS)); > > > > > > Nicholas, > > > Your patch makes me think that this timeout value should be calculated > > > once during initialization and stored in a new member of > > > struct fsl_ifc_mtd. That would improve readability AND have some > > > positive impact on performance. > > > > > > > is it not a bit wasteful to put it into struct fsl_ifc_mtd > > which is used quite often in here ?cho > > Storing the timeout in the private structure would use 4 or 8 bytes, > but the structure is passed around as pointer reference, so there is > no added overhead there. > > > #define IFC_TIMEOUT msecs_to_jiffies(500) > > > > sould do - its only referenced twice and would achieve what you > > suggested - initializing it in one location and improved readability > > > > wait_event_timeout(ctrl->nand_wait, ctrl->nand_stat, IFC_TIMEOUT); > > > > would there be any disadvantage of this solution? > > I don't have an issue with the compactness of your code. The issue > to me is that msecs_to_jiffies() is a real function call, not a macro. > That means that there would be a branch to that function followed by a > non-trivial calculation *every* time fsl_ifc_run_command() is called. > > If the timeout value were calculated during init, then the cost of > accessing it would simply a pointer dereference. Nicholas, any progress on that builtin_const_p variant -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/