From: Mikko Perttunen <mperttunen@nvidia.com>
To: sboyd@kernel.org, thierry.reding@gmail.com,
linux-clk@vger.kernel.org, linux-tegra@vger.kernel.org,
linux-kernel@vger.kernel.org, Pei Xiao <xiaopei01@kylinos.cn>
Cc: Pei Xiao <xiaopei01@kylinos.cn>
Subject: Re: [PATCH] clk: tegra: super: Fix error handling and resolve unsigned compare warning
Date: Thu, 18 Sep 2025 10:55:08 +0900 [thread overview]
Message-ID: <3841056.aeNJFYEL58@senjougahara> (raw)
In-Reply-To: <03d0c47832c7a0fdc19733d15077197ad2c54946.1756430095.git.xiaopei01@kylinos.cn>
On Friday, August 29, 2025 10:16 AM Pei Xiao wrote:
> ./drivers/clk/tegra/clk-super.c:156:5-9: WARNING:
> Unsigned expression compared with zero: rate < 0
>
> The unsigned long 'rate' variable caused:
> - Incorrect handling of negative errors
> - Compile warning: "Unsigned expression compared with zero"
>
> Fix by changing to long type and adding req->rate cast.
>
> Signed-off-by: Pei Xiao <xiaopei01@kylinos.cn>
> ---
> drivers/clk/tegra/clk-super.c | 4 ++--
> 1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/clk/tegra/clk-super.c b/drivers/clk/tegra/clk-super.c
> index 7ec47942720c..643b3cb83cd0 100644
> --- a/drivers/clk/tegra/clk-super.c
> +++ b/drivers/clk/tegra/clk-super.c
> @@ -147,7 +147,7 @@ static int clk_super_determine_rate(struct clk_hw *hw,
> {
> struct tegra_clk_super_mux *super = to_clk_super_mux(hw);
> struct clk_hw *div_hw = &super->frac_div.hw;
> - unsigned long rate;
> + long rate;
>
> __clk_hw_set_clk(div_hw, hw);
>
> @@ -156,7 +156,7 @@ static int clk_super_determine_rate(struct clk_hw *hw,
> if (rate < 0)
> return rate;
>
> - req->rate = rate;
> + req->rate = (unsigned long)rate;
> return 0;
> }
>
>
The proper fix for this would be to implement and call div_ops->determine_rate instead of round_rate. With the cast-to-long approach, rates above 2147MHz will incorrectly show as errors. While for this clock in particular I don't think we can reach those rates, I don't think this improves the situation either, as the round_rate implementation invoked here never returns errors.
Mikko
next prev parent reply other threads:[~2025-09-18 1:55 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-08-29 1:16 [PATCH] clk: tegra: super: Fix error handling and resolve unsigned compare warning Pei Xiao
2025-09-18 1:55 ` Mikko Perttunen [this message]
2025-09-18 1:59 ` Mikko Perttunen
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=3841056.aeNJFYEL58@senjougahara \
--to=mperttunen@nvidia.com \
--cc=linux-clk@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-tegra@vger.kernel.org \
--cc=sboyd@kernel.org \
--cc=thierry.reding@gmail.com \
--cc=xiaopei01@kylinos.cn \
/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