linux-arm-kernel.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
From: mturquette@linaro.org (Mike Turquette)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH] clk: clk-divider: fix divisor > 255 bug
Date: Thu, 02 Jan 2014 20:15:56 -0800	[thread overview]
Message-ID: <20140103041556.12054.53966@quantum> (raw)
In-Reply-To: <1387190498-15392-1-git-send-email-james.hogan@imgtec.com>

Quoting James Hogan (2013-12-16 02:41:38)
> Commit 6d9252bd9a4bb (clk: Add support for power of two type dividers)
> merged in v3.6 added the _get_val function to convert a divisor value to
> a register field value depending on the flags. However it used the type
> u8 for the div field, causing divisors larger than 255 to be masked
> and the resultant clock rate to be too high.
> 
> E.g. in my case an 11bit divider was supposed to divide 24.576 MHz down
> to 32.768KHz. The divisor was correctly calculated as 750 (0x2ee). This
> was masked to 238 (0xee) resulting in a frequency of 103.26KHz.
> 
> Signed-off-by: James Hogan <james.hogan@imgtec.com>

Taken into clk-next. Thanks for the fix!

Regards,
Mike

> Cc: Rajendra Nayak <rnayak@ti.com>
> Cc: Mike Turquette <mturquette@linaro.org>
> Cc: linux-arm-kernel at lists.infradead.org
> Cc: stable at vger.kernel.org
> ---
> Since this bug was introduced in 3.6, it probably should by applied to
> stable 3.10 and 3.12.
> ---
>  drivers/clk/clk-divider.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/clk/clk-divider.c b/drivers/clk/clk-divider.c
> index 8d3009e44fba..5543b7df8e16 100644
> --- a/drivers/clk/clk-divider.c
> +++ b/drivers/clk/clk-divider.c
> @@ -87,7 +87,7 @@ static unsigned int _get_table_val(const struct clk_div_table *table,
>         return 0;
>  }
>  
> -static unsigned int _get_val(struct clk_divider *divider, u8 div)
> +static unsigned int _get_val(struct clk_divider *divider, unsigned int div)
>  {
>         if (divider->flags & CLK_DIVIDER_ONE_BASED)
>                 return div;
> -- 
> 1.8.1.2
> 
> 

  reply	other threads:[~2014-01-03  4:15 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-12-16 10:41 [PATCH] clk: clk-divider: fix divisor > 255 bug James Hogan
2014-01-03  4:15 ` Mike Turquette [this message]
2014-01-06 10:07   ` James Hogan
2014-01-08 16:33     ` Mike Turquette

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=20140103041556.12054.53966@quantum \
    --to=mturquette@linaro.org \
    --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).