From: andrew@lunn.ch (Andrew Lunn)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH 1/5] clk: mvebu: Add core-divider clock
Date: Thu, 26 Sep 2013 17:56:56 +0200 [thread overview]
Message-ID: <20130926155656.GF18244@lunn.ch> (raw)
In-Reply-To: <20130926151240.GB4583@localhost>
> > > + /* Valid ratio are 1:4, 1:5, 1:6 and 1:8 */
> > > + u32 div;
> > > +
> > > + div = *parent_rate / rate;
> > > + if (div <= 4)
> > > + div = 4;
> > > + else if (div <= 5)
> > > + div = 5;
> > > + else if (div <= 6)
> > > + div = 6;
> > > + else
> > > + div = 8;
> > > +
> > > + return *parent_rate / div;
> > > +}
> >
> > This looks odd. Is not the following clearer?
> >
> > div = *parent_rate / rate;
> > if (div < 5)
> > div = 4;
> > else if (div > 6)
> > div = 8;
> >
>
> Mmmm... no, it's not at all clearer to me.
> IMHO, the original construction explicitly show the possible ratios:
>
> /* If it's smaller than or equal to 4, set to 4 */
> if (div <= 4)
> div = 4;
>
> /* Otherwise, if it's between 4 and 5, set to 5 */
> else if (div <= 5)
> div = 5;
If div was a float or double, i would probably agree. But its a u32.
It cannot be between 4 and 5. It must be 5. So it becomes
if (div <= 4)
div = 4;
else if (div == 5)
div = 5;
else if (div == 6)
div = 6
else
div = 8
Those two middle statements look odd to me...
Andrew
WARNING: multiple messages have this Message-ID (diff)
From: Andrew Lunn <andrew-g2DYL2Zd6BY@public.gmane.org>
To: Ezequiel Garcia
<ezequiel.garcia-wi1+55ScJUtKEb57/3fJTNBPR1lH4CV8@public.gmane.org>
Cc: Andrew Lunn <andrew-g2DYL2Zd6BY@public.gmane.org>,
linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r@public.gmane.org,
Jason Cooper <jason-NLaQJdtUoK4Be96aLqz0jA@public.gmane.org>,
Mike Turquette
<mturquette-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org>,
Emilio Lopez <elopez93-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>,
Gregory Clement
<gregory.clement-wi1+55ScJUtKEb57/3fJTNBPR1lH4CV8@public.gmane.org>,
Lior Amsalem <alior-eYqpPyKDWXRBDgjK7y7TUQ@public.gmane.org>,
Thomas Petazzoni
<thomas.petazzoni-wi1+55ScJUtKEb57/3fJTNBPR1lH4CV8@public.gmane.org>,
Tawfik Bayouk <tawfik-eYqpPyKDWXRBDgjK7y7TUQ@public.gmane.org>,
devicetree-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
Subject: Re: [PATCH 1/5] clk: mvebu: Add core-divider clock
Date: Thu, 26 Sep 2013 17:56:56 +0200 [thread overview]
Message-ID: <20130926155656.GF18244@lunn.ch> (raw)
In-Reply-To: <20130926151240.GB4583@localhost>
> > > + /* Valid ratio are 1:4, 1:5, 1:6 and 1:8 */
> > > + u32 div;
> > > +
> > > + div = *parent_rate / rate;
> > > + if (div <= 4)
> > > + div = 4;
> > > + else if (div <= 5)
> > > + div = 5;
> > > + else if (div <= 6)
> > > + div = 6;
> > > + else
> > > + div = 8;
> > > +
> > > + return *parent_rate / div;
> > > +}
> >
> > This looks odd. Is not the following clearer?
> >
> > div = *parent_rate / rate;
> > if (div < 5)
> > div = 4;
> > else if (div > 6)
> > div = 8;
> >
>
> Mmmm... no, it's not at all clearer to me.
> IMHO, the original construction explicitly show the possible ratios:
>
> /* If it's smaller than or equal to 4, set to 4 */
> if (div <= 4)
> div = 4;
>
> /* Otherwise, if it's between 4 and 5, set to 5 */
> else if (div <= 5)
> div = 5;
If div was a float or double, i would probably agree. But its a u32.
It cannot be between 4 and 5. It must be 5. So it becomes
if (div <= 4)
div = 4;
else if (div == 5)
div = 5;
else if (div == 6)
div = 6
else
div = 8
Those two middle statements look odd to me...
Andrew
--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
next prev parent reply other threads:[~2013-09-26 15:56 UTC|newest]
Thread overview: 33+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-09-25 21:28 [PATCH 0/5] Add Core Divider clock support for Armada 370/XP Ezequiel Garcia
2013-09-25 21:28 ` Ezequiel Garcia
2013-09-25 21:28 ` [PATCH 1/5] clk: mvebu: Add core-divider clock Ezequiel Garcia
2013-09-25 21:28 ` [PATCH 2/5] ARM: mvebu: Add Core Divider clock device-tree binding Ezequiel Garcia
2013-09-25 21:28 ` Ezequiel Garcia
2013-09-25 21:28 ` [PATCH 3/5] ARM: mvebu: Add a 2 GHz fixed-clock Armada 370/XP Ezequiel Garcia
2013-09-25 21:28 ` [PATCH 4/5] ARM: mvebu: Add the core-divider clock to " Ezequiel Garcia
2013-09-25 21:28 ` [PATCH 5/5] ARM: mvebu: Add NAND " Ezequiel Garcia
2013-09-25 21:37 ` [PATCH 0/5] Add Core Divider clock support for " Ezequiel Garcia
2013-09-25 21:37 ` Ezequiel Garcia
2013-09-26 7:38 ` Gregory CLEMENT
2013-09-26 7:38 ` Gregory CLEMENT
2013-09-26 15:26 ` Ezequiel Garcia
2013-09-26 15:26 ` Ezequiel Garcia
2013-09-26 15:47 ` Thomas Petazzoni
2013-09-26 15:47 ` Thomas Petazzoni
2013-09-26 16:00 ` Ezequiel Garcia
2013-09-26 16:00 ` Ezequiel Garcia
2013-09-26 16:12 ` Thomas Petazzoni
2013-09-26 16:12 ` Thomas Petazzoni
2013-09-26 8:24 ` [PATCH 1/5] clk: mvebu: Add core-divider clock Andrew Lunn
2013-09-26 8:24 ` Andrew Lunn
2013-09-26 15:12 ` Ezequiel Garcia
2013-09-26 15:12 ` Ezequiel Garcia
2013-09-26 15:56 ` Andrew Lunn [this message]
2013-09-26 15:56 ` Andrew Lunn
2013-09-26 16:55 ` Ben Dooks
2013-09-26 18:29 ` Ezequiel Garcia
2013-09-26 18:29 ` Ezequiel Garcia
2013-09-26 8:36 ` [PATCH 2/5] ARM: mvebu: Add Core Divider clock device-tree binding Andrew Lunn
2013-09-26 8:36 ` Andrew Lunn
2013-09-26 15:04 ` Ezequiel Garcia
2013-09-26 15:04 ` Ezequiel Garcia
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20130926155656.GF18244@lunn.ch \
--to=andrew@lunn.ch \
--cc=linux-arm-kernel@lists.infradead.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.