linux-mips
[Top] [All Lists]

Re: [PATCH 1/9] kernel: export sound/core/pcm_timer.c gcd implementation

To: Andrew Morton <akpm@linux-foundation.org>
Subject: Re: [PATCH 1/9] kernel: export sound/core/pcm_timer.c gcd implementation
From: Florian Fainelli <florian@openwrt.org>
Date: Tue, 2 Jun 2009 09:19:22 +0200
Cc: linux-kernel@vger.kernel.org, Takashi Iwai <tiwai@suse.de>, linux-mips@linux-mips.org, Ralf Baechle <ralf@linux-mips.org>, Ingo Molnar <mingo@elte.hu>
Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:sender:from:to:subject:date :user-agent:cc:references:in-reply-to:mime-version:content-type :content-transfer-encoding:message-id; bh=/LCqDd5Rt0h4z/FKRGfnjk/Sym7dJ9/mKrZmXxtfK7s=; b=Il6BFFc0LBR428TXHueYldB47g5IxSJvFSqkOhaZFQY2H8THVjaLBzlkHVI5x6/NxF 79ZUo+NV/Jr5LKmZglzvHtRK7uWyI3tpK5+ANEo+SPMccuB7QhFXu8zuL5J9v8xmxMmm eKeGhNh4r/sdI7T9I4XgJr0AgCq8pOmuVIqZ8=
Domainkey-signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=sender:from:to:subject:date:user-agent:cc:references:in-reply-to :mime-version:content-type:content-transfer-encoding:message-id; b=eebZ8A/S+6Y00ce10Bf+LlJ4ALwLU/lBKCRLsMngpjgcfU69xy9qGEs3GUOzoT4F1V ryhTlnAMFNCbGyP2gVHf3ykTUCwBtH07NVqggelK6AkT+m0a7aLSdVPYiOjYJoL103BC tZ6tDKYTO9CTgMFcPOBOOeoGVMFMMDcyZoO+w=
In-reply-to: <20090601215034.7352ddca.akpm@linux-foundation.org>
Original-recipient: rfc822;linux-mips@linux-mips.org
References: <200906011357.09966.florian@openwrt.org> <20090601215034.7352ddca.akpm@linux-foundation.org>
Sender: linux-mips-bounce@linux-mips.org
User-agent: KMail/1.9.9
Le Tuesday 02 June 2009 06:50:34 Andrew Morton, vous avez écrit :
> On Mon, 1 Jun 2009 13:57:09 +0200 Florian Fainelli <florian@openwrt.org> 
wrote:
> > This patch exports the gcd implementation from
> > sound/core/pcm_timer.c into include/linux/kernel.h.
> > AR7 uses it in its clock routines.
> >
> > ...
> >
> > diff --git a/include/linux/kernel.h b/include/linux/kernel.h
> > index 883cd44..878a27a 100644
> > --- a/include/linux/kernel.h
> > +++ b/include/linux/kernel.h
> > @@ -147,6 +147,22 @@ extern int _cond_resched(void);
> >             (__x < 0) ? -__x : __x;         \
> >     })
> >
> > +/* Greatest common divisor */
> > +static inline unsigned long gcd(unsigned long a, unsigned long b)
> > +{
> > +        unsigned long r;
> > +        if (a < b) {
> > +                r = a;
> > +                a = b;
> > +                b = r;
> > +        }
> > +        while ((r = a % b) != 0) {
> > +                a = b;
> > +                b = r;
> > +        }
> > +        return b;
> > +}
>
> a) the name's a bit sucky.   Is there some convention for this name?

We might want something better like greatest_common_divisor which is a bit 
more self-explanatory ?

>
> b) It looks too large to be inlined.  lib/gdc.c?

And its users select it in order not to increase the size of kernel.h, sounds 
good.

>
> b) there's an implementation of gcd() in
>    net/netfilter/ipvs/ip_vs_wrr.c.  I expect that this patch broke the
>    build.

I did forget about this. That gcd implementation only treats the a > b case.

What do you prefer, each user keeps its gcd implementation locally or we make 
a lib/gcd.c for it ?

Thanks
-- 
Best regards, Florian Fainelli
Email : florian@openwrt.org
http://openwrt.org
-------------------------------

Attachment: signature.asc
Description: This is a digitally signed message part.

<Prev in Thread] Current Thread [Next in Thread>