Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932168AbbESOrr (ORCPT ); Tue, 19 May 2015 10:47:47 -0400 Received: from hofr.at ([212.69.189.236]:32987 "EHLO mail.hofr.at" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932527AbbESOrq (ORCPT ); Tue, 19 May 2015 10:47:46 -0400 Date: Tue, 19 May 2015 16:47:44 +0200 From: Nicholas Mc Guire To: Joe Perches Cc: 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, pjt@google.com, ahh@google.com Subject: Re: [tip:timers/core] time: Refactor msecs_to_jiffies Message-ID: <20150519144744.GA30261@opentech.at> References: <1431951554-5563-2-git-send-email-hofrat@osadl.org> <1432044238.2870.148.camel@perches.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1432044238.2870.148.camel@perches.com> User-Agent: Mutt/1.5.18 (2008-05-17) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1911 Lines: 53 On Tue, 19 May 2015, Joe Perches wrote: > 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. > oops - sorry - no idea how I did that - will fix up and resend thx! hofrat -- 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/