Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932701AbbESOEF (ORCPT ); Tue, 19 May 2015 10:04:05 -0400 Received: from smtprelay0101.hostedemail.com ([216.40.44.101]:38312 "EHLO smtprelay.hostedemail.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S932507AbbESOED (ORCPT ); Tue, 19 May 2015 10:04:03 -0400 X-Session-Marker: 6A6F6540706572636865732E636F6D X-Spam-Summary: 2,0,0,,d41d8cd98f00b204,,:::::::::::::::::::::::,RULES_HIT:41:355:379:541:599:968:973:988:989:1260:1277:1311:1313:1314:1345:1359:1373:1381:1437:1515:1516:1518:1534:1541:1593:1594:1711:1730:1747:1777:1792:1981:2194:2199:2393:2559:2562:2828:3138:3139:3140:3141:3142:3353:3622:3865:3866:3867:3868:3870:3871:3872:3874:4250:4321:5007:6261:6737:7875:7904:10004:10400:10848:11026:11232:11473:11658:11914:12043:12048:12517:12519:12740:13069:13311:13357: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: soda19_22de285bf2c41 X-Filterd-Recvd-Size: 2520 Message-ID: <1432044238.2870.148.camel@perches.com> Subject: Re: [tip:timers/core] time: Refactor msecs_to_jiffies From: Joe Perches To: yamada.m@jp.panasonic.com, linux-kernel@vger.kernel.org, sam@ravnborg.org, hpa@zytor.com, john.stultz@linaro.org, mmarek@suse.cz, hofrat@osadl.org, tglx@linutronix.de, mingo@kernel.org, joe@perches.com, pjt@google.com, ahh@google.com Date: Tue, 19 May 2015 07:03:58 -0700 In-Reply-To: References: <1431951554-5563-2-git-send-email-hofrat@osadl.org> Content-Type: text/plain; charset="ISO-8859-1" X-Mailer: Evolution 3.12.11-0ubuntu3 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: 1711 Lines: 48 On Tue, 2015-05-19 at 06:36 -0700, tip-bot for Nicholas Mc Guire wrote: > Refactor the msecs_to_jiffies conditional code part in time.c and > jiffies.h putting it into conditional functions rather than #ifdefs > to improve readability. [] > diff --git a/include/linux/jiffies.h b/include/linux/jiffies.h [] > +static inline unsigned long _msecs_to_jiffies(const unsigned int m) > +{ > + return (m + (MSEC_PER_SEC / HZ) - 1) / (MSEC_PER_SEC / HZ); > +} > +#elif HZ > MSEC_PER_SEC && !(HZ % MSEC_PER_SEC) > +/* > + * HZ is larger than 1000, and HZ is a nice round multiple of 1000 - > + * simply multiply with the factor between them. > + * > + * But first make sure the multiplication result cannot overflow: > + */ > +static inline unsigned long _msecs_to_jiffies(const unsigned int m) > +{ > + if (m > jiffies_to_msecs(MAX_JIFFY_OFFSET)) > + return MAX_JIFFY_OFFSET; > + return m * (HZ / MSEC_PER_SEC); > +} > +#else > +/* > + * Generic case - multiply, round and divide. But first check that if > + * we are doing a net multiplication, that we wouldn't overflow: > + */ > +static inline unsigned long _msecs_to_jiffies(const unsigned int m) > +{ > + if (HZ > MSEC_PER_SEC && m > jiffies_to_msecs(MAX_JIFFY_OFFSET)) > + return MAX_JIFFY_OFFSET; > + > + return (MSEC_TO_HZ_MUL32 * m + MSEC_TO_HZ_ADJ32) > + >> MSEC_TO_HZ_SHR32; > +} > +#endif It'd be nicer to remove 1 level of unnecessary tab indentation in all the _msecs_to_jiffies functions here. -- 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/