From: Stephen Boyd <sboyd@codeaurora.org>
To: Peter De Schrijver <pdeschrijver@nvidia.com>
Cc: Michael Turquette <mturquette@baylibre.com>,
linux-clk@vger.kernel.org, linux-kernel@vger.kernel.org,
Alex Frid <afrid@nvidia.com>
Subject: Re: [PATCH] clk: Don't write error code into divider register
Date: Tue, 25 Jul 2017 17:32:08 -0700 [thread overview]
Message-ID: <20170726003208.GF2146@codeaurora.org> (raw)
In-Reply-To: <1500977920-5533-1-git-send-email-pdeschrijver@nvidia.com>
On 07/25, Peter De Schrijver wrote:
> From: Alex Frid <afrid@nvidia.com>
>
> Add a check for error returned by divider value calculation to avoid
> writing error code into hw register.
>
> Signed-off-by: Alex Frid <afrid@nvidia.com>
> Reviewed-by: Peter De Schrijver <pdeschrijver@nvidia.com>
> Reviewed-by: Jon Mayo <jmayo@nvidia.com>
> ---
Fixes: bca9690b9426 ("clk: divider: Make generic for usage elsewhere")
perhaps?
Also, curious how this got triggered? Presumably round_rate would
have failed before a set_rate call with something invalid came
through so that's why nobody has reported anything so far.
> drivers/clk/clk-divider.c | 6 ++++--
> 1 file changed, 4 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/clk/clk-divider.c b/drivers/clk/clk-divider.c
> index 9bb472c..4ed516c 100644
> --- a/drivers/clk/clk-divider.c
> +++ b/drivers/clk/clk-divider.c
> @@ -385,12 +385,14 @@ static int clk_divider_set_rate(struct clk_hw *hw, unsigned long rate,
> unsigned long parent_rate)
> {
> struct clk_divider *divider = to_clk_divider(hw);
> - unsigned int value;
> + int value;
> unsigned long flags = 0;
> u32 val;
>
> value = divider_get_val(rate, parent_rate, divider->table,
> divider->width, divider->flags);
> + if (value < 0)
Perhaps value should be an s32 if we're doing a writel with it
shifted so much. And then, we could declare it as a u32 and test
it with
if ((s32)value < 0)
to see if there was an error. Sort of annoying that we've limited
the available space of divider_get_val() by combining the value
with the error code number space. We may want to not do that in
case people have huge dividers.
--
Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum,
a Linux Foundation Collaborative Project
next prev parent reply other threads:[~2017-07-26 0:32 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-07-25 10:18 [PATCH] clk: Don't write error code into divider register Peter De Schrijver
2017-07-26 0:32 ` Stephen Boyd [this message]
2017-07-26 8:25 ` Peter De Schrijver
2017-09-01 1:44 ` Stephen Boyd
2017-09-01 1:43 ` 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=20170726003208.GF2146@codeaurora.org \
--to=sboyd@codeaurora.org \
--cc=afrid@nvidia.com \
--cc=linux-clk@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mturquette@baylibre.com \
--cc=pdeschrijver@nvidia.com \
/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).