Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752169AbZKDALz (ORCPT ); Tue, 3 Nov 2009 19:11:55 -0500 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1751326AbZKDALz (ORCPT ); Tue, 3 Nov 2009 19:11:55 -0500 Received: from mail1.asahi-net.or.jp ([202.224.39.197]:13452 "EHLO mail1.asahi-net.or.jp" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751416AbZKDALy (ORCPT ); Tue, 3 Nov 2009 19:11:54 -0500 Date: Wed, 04 Nov 2009 09:11:36 +0900 Message-ID: From: Hirokazu Takata To: Julia Lawall Cc: takata@linux-m32r.org, linux-m32r@ml.linux-m32r.org, linux-kernel@vger.kernel.org, kernel-janitors@vger.kernel.org Subject: Re: [PATCH 8/15] arch/m32r: Use DIV_ROUND_CLOSEST In-Reply-To: References: User-Agent: Wanderlust/2.14.0 (Africa) Emacs/22.2 Mule/5.0 (SAKAKI) MIME-Version: 1.0 (generated by SEMI 1.14.6 - "Maruoka") Content-Type: text/plain; charset=US-ASCII Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 2216 Lines: 75 At Sun, 2 Aug 2009 10:47:27 +0200 (CEST), Julia Lawall wrote: > > From: Julia Lawall > > The kernel.h macro DIV_ROUND_CLOSEST performs the computation (x + d/2)/d > but is perhaps more readable. > > The semantic patch that makes this change is as follows: > (http://www.emn.fr/x-info/coccinelle/) > > // > @haskernel@ > @@ > > #include > > @depends on haskernel@ > expression x,__divisor; > @@ > > - (((x) + ((__divisor) / 2)) / (__divisor)) > + DIV_ROUND_CLOSEST(x,__divisor) > // > > Signed-off-by: Julia Lawall > > --- > arch/m32r/kernel/time.c | 6 +++--- > 1 files changed, 3 insertions(+), 3 deletions(-) > > diff --git a/arch/m32r/kernel/time.c b/arch/m32r/kernel/time.c > index cada3ba..49648ba 100644 > --- a/arch/m32r/kernel/time.c > +++ b/arch/m32r/kernel/time.c > @@ -66,7 +66,7 @@ static unsigned long do_gettimeoffset(void) > count = 0; > > count = (latch - count) * TICK_SIZE; > - elapsed_time = (count + latch / 2) / latch; > + elapsed_time = DIV_ROUND_CLOSEST(count, latch); > /* NOTE: LATCH is equal to the "interval" value (= reload count). */ > > #else /* CONFIG_SMP */ > @@ -84,7 +84,7 @@ static unsigned long do_gettimeoffset(void) > p_count = count; > > count = (latch - count) * TICK_SIZE; > - elapsed_time = (count + latch / 2) / latch; > + elapsed_time = DIV_ROUND_CLOSEST(count, latch); > /* NOTE: LATCH is equal to the "interval" value (= reload count). */ > #endif /* CONFIG_SMP */ > #elif defined(CONFIG_CHIP_M32310) > @@ -270,7 +270,7 @@ void __init time_init(void) > > bus_clock = boot_cpu_data.bus_clock; > divide = boot_cpu_data.timer_divide; > - latch = (bus_clock/divide + HZ / 2) / HZ; > + latch = DIV_ROUND_CLOSEST(bus_clock/divide, HZ); > > printk("Timer start : latch = %ld\n", latch); > > Acked-by: Hirokazu Takata I've merged this patch into my tree. Thank you. -- Takata -- 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/