linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Stephen Boyd <sboyd@kernel.org>
To: Nicolas Ferre <nicolas.ferre@microchip.com>, linux-clk@vger.kernel.org
Cc: Alexandre Belloni <alexandre.belloni@bootlin.com>,
	Ludovic Desroches <ludovic.desroches@microchip.com>,
	Claudiu Beznea <claudiu.beznea@microchip.com>,
	linux-arm-kernel@lists.infradead.org,
	linux-kernel@vger.kernel.org, mturquette@baylibre.com,
	matthias.wieloch@few-bauer.de, stable@vger.kernel.org,
	Nicolas Ferre <nicolas.ferre@microchip.com>
Subject: Re: [PATCH v2] clk: at91: fix programmable clock for sama5d2
Date: Mon, 18 Mar 2019 12:54:02 -0700	[thread overview]
Message-ID: <155293884206.20095.9858756917267939797@swboyd.mtv.corp.google.com> (raw)
In-Reply-To: <20190318105045.26943-1-nicolas.ferre@microchip.com>

Quoting Nicolas Ferre (2019-03-18 03:50:45)
> From: Matthias Wieloch <matthias.wieloch@few-bauer.de>
> 
> The prescaler formula of the programmable clock has changed for sama5d2. Update
> the driver accordingly.
> 
> Fixes: a2038077de9a ("clk: at91: add sama5d2 PMC driver")
> Cc: <stable@vger.kernel.org> # v4.20+
> Signed-off-by: Nicolas Ferre <nicolas.ferre@microchip.com>
> [nicolas.ferre@microchip.com: adapt the prescaler range,
>                 fix clk_programmable_recalc_rate, split patch]
> Signed-off-by: Matthias Wieloch <matthias.wieloch@few-bauer.de>
> Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
> ---
> v2: adapt to v5.1-rc1
>     remove unneeded sentence about DT in commit message
> 
> Stephen,
> 
> I think it would be good to see this fix going upstream during v5.1-rc phase.

Ok. I can apply this clk-fixes. I presume that things are real bad and
it can't wait until v5.2?

> @@ -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.

>                 }
>  
>                 if (tmp_rate > req->rate)

  reply	other threads:[~2019-03-18 19:54 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 [this message]
2019-03-19  8:28   ` Nicolas.Ferre
2019-03-19  9:24     ` Alexandre Belloni
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=155293884206.20095.9858756917267939797@swboyd.mtv.corp.google.com \
    --to=sboyd@kernel.org \
    --cc=alexandre.belloni@bootlin.com \
    --cc=claudiu.beznea@microchip.com \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-clk@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=ludovic.desroches@microchip.com \
    --cc=matthias.wieloch@few-bauer.de \
    --cc=mturquette@baylibre.com \
    --cc=nicolas.ferre@microchip.com \
    --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).