From: Alexandre Belloni <alexandre.belloni@bootlin.com>
To: Nicolas.Ferre@microchip.com
Cc: sboyd@kernel.org, mturquette@baylibre.com,
linux-kernel@vger.kernel.org, stable@vger.kernel.org,
Claudiu.Beznea@microchip.com, matthias.wieloch@few-bauer.de,
Ludovic.Desroches@microchip.com, linux-clk@vger.kernel.org,
linux-arm-kernel@lists.infradead.org
Subject: Re: [PATCH v2] clk: at91: fix programmable clock for sama5d2
Date: Tue, 19 Mar 2019 10:24:38 +0100 [thread overview]
Message-ID: <20190319092438.GC29054@piout.net> (raw)
In-Reply-To: <dd4a32fe-4942-83a8-a2c4-336e3c6e55b3@microchip.com>
On 19/03/2019 08:28:40+0000, Nicolas Ferre wrote:
> > Ok. I can apply this clk-fixes. I presume that things are real bad and
> > it can't wait until v5.2?
>
> To be perfectly clear, it's not a regression.
> But as we're at the very beginning of the '-rc' phase and as it's a bug,
> I was thinking about adding it now. But you to choose, no problem either
> way.
>
> >> @@ -60,10 +68,18 @@ static int clk_programmable_determine_rate(struct clk_hw *hw,
> >> continue;
> >>
> >> parent_rate = clk_hw_get_rate(parent);
> >> - for (shift = 0; shift < PROG_PRES_MASK; shift++) {
> >> - tmp_rate = parent_rate >> shift;
> >> - if (tmp_rate <= req->rate)
> >> - break;
> >> + if (layout->is_pres_direct) {
> >> + for (shift = 0; shift <= layout->pres_mask; shift++) {
> >> + tmp_rate = parent_rate / (shift + 1);
> >> + if (tmp_rate <= req->rate)
> >> + break;
> >> + }
> >> + } else {
> >> + for (shift = 0; shift < layout->pres_mask; shift++) {
> >> + tmp_rate = parent_rate >> shift;
> >> + if (tmp_rate <= req->rate)
> >> + break;
> >> + }
> >
> > This looks like a lot of copy paste when the if statement could have been
> > pulled into the for loop instead of duplicating the loops and
> > surrounding if condition check for tmp_rate.
>
> Stop condition of loops not being the same made me separate them instead
> of adding artificial test conditions for shift == layout->pres_mask. I'm
> not sure the other way around is more obvious then...
>
I also tried different ways (e.g. setting up a different determine_rate
for the sama5d2) but this ended up being the more concise one.
--
Alexandre Belloni, Bootlin
Embedded Linux and Kernel engineering
https://bootlin.com
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
next prev parent reply other threads:[~2019-03-19 9:25 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-03-18 10:50 [PATCH v2] clk: at91: fix programmable clock for sama5d2 Nicolas Ferre
2019-03-18 19:54 ` Stephen Boyd
2019-03-19 8:28 ` Nicolas.Ferre
2019-03-19 9:24 ` Alexandre Belloni [this message]
2019-03-19 19:44 ` Stephen Boyd
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=20190319092438.GC29054@piout.net \
--to=alexandre.belloni@bootlin.com \
--cc=Claudiu.Beznea@microchip.com \
--cc=Ludovic.Desroches@microchip.com \
--cc=Nicolas.Ferre@microchip.com \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-clk@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=matthias.wieloch@few-bauer.de \
--cc=mturquette@baylibre.com \
--cc=sboyd@kernel.org \
--cc=stable@vger.kernel.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).