From: Haojian Zhuang <haojian.zhuang@gmail.com>
To: "linux-arm-kernel@lists.infradead.org"
<linux-arm-kernel@lists.infradead.org>,
"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
Mike Turquette <mike.turquette@linaro.org>,
Bergmann Arnd <arnd@arndb.de>
Cc: Haojian Zhuang <haojian.zhuang@gmail.com>
Subject: Re: [PATCH] clk: factor: calculate rate by do_div
Date: Sun, 16 Dec 2012 00:42:26 +0800 [thread overview]
Message-ID: <CAN1soZw=TjxENOPLLHb08FuWpVYH-s-3mVvLd7yTymU2UGovww@mail.gmail.com> (raw)
In-Reply-To: <CAN1soZze6Ogn_zi7JJN0JNzoMFkHLJyKyjTV7rSWUmQhwRU0NQ@mail.gmail.com>
On Tue, Dec 4, 2012 at 9:32 AM, Haojian Zhuang <haojian.zhuang@gmail.com> wrote:
> On Mon, Dec 3, 2012 at 4:14 PM, Haojian Zhuang <haojian.zhuang@gmail.com> wrote:
>> clk->rate = parent->rate / div * mult
>>
>> The formula is OK. But it may overflow while we do operate with
>> unsigned long. So use do_div instead.
>>
>> Signed-off-by: Haojian Zhuang <haojian.zhuang@gmail.com>
>> ---
>> drivers/clk/clk-fixed-factor.c | 5 ++++-
>> 1 file changed, 4 insertions(+), 1 deletion(-)
>>
>> diff --git a/drivers/clk/clk-fixed-factor.c b/drivers/clk/clk-fixed-factor.c
>> index a489985..1ef271e 100644
>> --- a/drivers/clk/clk-fixed-factor.c
>> +++ b/drivers/clk/clk-fixed-factor.c
>> @@ -28,8 +28,11 @@ static unsigned long clk_factor_recalc_rate(struct clk_hw *hw,
>> unsigned long parent_rate)
>> {
>> struct clk_fixed_factor *fix = to_clk_fixed_factor(hw);
>> + unsigned long long int rate;
>>
>> - return parent_rate * fix->mult / fix->div;
>> + rate = (unsigned long long int)parent_rate * fix->mult;
>> + do_div(rate, fix->div);
>> + return (unsigned long)rate;
>> }
>>
>> static long clk_factor_round_rate(struct clk_hw *hw, unsigned long rate,
>> --
>> 1.7.10.4
>>
>
> Correct Mike's email address.
Any comments? It's the bug what needs to be fixed.
prev parent reply other threads:[~2012-12-15 16:42 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-12-03 8:14 [PATCH] clk: factor: calculate rate by do_div Haojian Zhuang
2012-12-04 1:32 ` Haojian Zhuang
2012-12-15 16:41 ` Haojian Zhuang
2012-12-15 20:54 ` Mike Turquette
2012-12-16 6:27 ` Haojian Zhuang
2012-12-15 16:42 ` Haojian Zhuang [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='CAN1soZw=TjxENOPLLHb08FuWpVYH-s-3mVvLd7yTymU2UGovww@mail.gmail.com' \
--to=haojian.zhuang@gmail.com \
--cc=arnd@arndb.de \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mike.turquette@linaro.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).