[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20190319092438.GC29054@piout.net>
Date: Tue, 19 Mar 2019 10:24:38 +0100
From: Alexandre Belloni <alexandre.belloni@...tlin.com>
To: Nicolas.Ferre@...rochip.com
Cc: sboyd@...nel.org, linux-clk@...r.kernel.org,
Ludovic.Desroches@...rochip.com, Claudiu.Beznea@...rochip.com,
linux-arm-kernel@...ts.infradead.org, linux-kernel@...r.kernel.org,
mturquette@...libre.com, matthias.wieloch@...-bauer.de,
stable@...r.kernel.org
Subject: Re: [PATCH v2] clk: at91: fix programmable clock for sama5d2
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
Powered by blists - more mailing lists