Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751287AbZJTITT (ORCPT ); Tue, 20 Oct 2009 04:19:19 -0400 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1750795AbZJTITS (ORCPT ); Tue, 20 Oct 2009 04:19:18 -0400 Received: from fanny.its.uu.se ([130.238.4.241]:48728 "EHLO fanny.its.uu.se" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750885AbZJTITR (ORCPT ); Tue, 20 Oct 2009 04:19:17 -0400 MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Message-ID: <19165.29312.300540.500942@pilspetsen.it.uu.se> Date: Tue, 20 Oct 2009 10:19:12 +0200 From: Mikael Pettersson To: Thomas Gleixner Cc: Linus Walleij , linux-mips@linux-mips.org, Ralf Baechle , Mikael Pettersson , linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org Subject: Re: [PATCH] Make MIPS dynamic clocksource/clockevent clock code generic In-Reply-To: References: <1255819715-19763-1-git-send-email-linus.walleij@stericsson.com> X-Mailer: VM 7.17 under Emacs 20.7.1 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1498 Lines: 56 Thomas Gleixner writes: > > +static inline void clockevent_set_clock(struct clock_event_device *dev, u32 hz) > > +{ > > + u64 temp; > > + u32 shift; > > + > > + /* Find a shift value */ > > + for (shift = 32; shift > 0; shift--) { > > + temp = (u64) hz << shift; > > + do_div(temp, NSEC_PER_SEC); > > + if ((temp >> 32) == 0) > > + break; > > + } > > + dev->shift = shift; > > + dev->mult = (u32) temp; > > +} > > + > > + > > +static inline void clocksource_set_clock(struct clocksource *cs, u32 hz) > > +{ > > + u64 temp; > > + u32 shift; > > + > > + /* Find a shift value */ > > + for (shift = 32; shift > 0; shift--) { > > + temp = (u64) NSEC_PER_SEC << shift; > > + do_div(temp, hz); > > + if ((temp >> 32) == 0) > > + break; > > + } > > + cs->shift = shift; > > + cs->mult = (u32) temp; > > +} > > + > > So that's the same function twice, right ? They are similar but not identical: > > + temp = (u64) hz << shift; > > + do_div(temp, NSEC_PER_SEC); vs > > + temp = (u64) NSEC_PER_SEC << shift; > > + do_div(temp, hz); I suppose both functions could be implemented by a suitably parametric third function, but IMO that would just obscure things. Making them non-inline I fully agree with. -- 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/