From: boris.brezillon@free-electrons.com (Boris Brezillon)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH] clk: at91: pll: fix input range validity check
Date: Thu, 18 Jun 2015 12:59:21 +0200 [thread overview]
Message-ID: <20150618125921.0b807f39@bbrezillon> (raw)
In-Reply-To: <1427594023-9697-1-git-send-email-boris.brezillon@free-electrons.com>
On Sun, 29 Mar 2015 03:53:43 +0200
Boris Brezillon <boris.brezillon@free-electrons.com> wrote:
> The PLL impose a certain input range to work correctly, but it appears that
> this input range does not apply on the input clock (or parent clock) but
> on the input clock after it has passed the PLL divisor.
> Fix the implementation accordingly.
Ping (I was expecting this patch to be part of 4.1 :-/).
>
> Cc: <stable@vger.kernel.org> # v3.14+
> Signed-off-by: Boris Brezillon <boris.brezillon@free-electrons.com>
> Reported-by: Jonas Andersson <jonas@microbit.se>
> ---
> drivers/clk/at91/clk-pll.c | 12 ++++++++++--
> 1 file changed, 10 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/clk/at91/clk-pll.c b/drivers/clk/at91/clk-pll.c
> index 6ec79db..cbbe403 100644
> --- a/drivers/clk/at91/clk-pll.c
> +++ b/drivers/clk/at91/clk-pll.c
> @@ -173,8 +173,7 @@ static long clk_pll_get_best_div_mul(struct clk_pll *pll, unsigned long rate,
> int i = 0;
>
> /* Check if parent_rate is a valid input rate */
> - if (parent_rate < characteristics->input.min ||
> - parent_rate > characteristics->input.max)
> + if (parent_rate < characteristics->input.min)
> return -ERANGE;
>
> /*
> @@ -187,6 +186,15 @@ static long clk_pll_get_best_div_mul(struct clk_pll *pll, unsigned long rate,
> if (!mindiv)
> mindiv = 1;
>
> + if (parent_rate > characteristics->input.max) {
> + tmpdiv = DIV_ROUND_UP(parent_rate, characteristics->input.max);
> + if (tmpdiv > PLL_DIV_MAX)
> + return -ERANGE;
> +
> + if (tmpdiv > mindiv)
> + mindiv = tmpdiv;
> + }
> +
> /*
> * Calculate the maximum divider which is limited by PLL register
> * layout (limited by the MUL or DIV field size).
--
Boris Brezillon, Free Electrons
Embedded Linux and Kernel engineering
http://free-electrons.com
prev parent reply other threads:[~2015-06-18 10:59 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-03-29 1:53 [PATCH] clk: at91: pll: fix input range validity check Boris Brezillon
2015-04-13 4:37 ` Michael Turquette
2015-04-14 17:48 ` Boris Brezillon
2015-06-18 10:59 ` Boris Brezillon [this message]
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=20150618125921.0b807f39@bbrezillon \
--to=boris.brezillon@free-electrons.com \
--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 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).