Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

clk: tegra: periph: Fix error handling and resolve unsigned compare warning

./drivers/clk/tegra/clk-periph.c:59: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>
Link: https://lore.kernel.org/r/79c7f01e29876c612e90d6d0157fb1572ca8b3fb.1752046270.git.xiaopei01@kylinos.cn
Acked-by: Thierry Reding <treding@nvidia.com>
Signed-off-by: Stephen Boyd <sboyd@kernel.org>

authored by

Pei Xiao and committed by
Stephen Boyd
2dc2ca90 ba6651a7

+2 -2
+2 -2
drivers/clk/tegra/clk-periph.c
··· 51 51 struct tegra_clk_periph *periph = to_clk_periph(hw); 52 52 const struct clk_ops *div_ops = periph->div_ops; 53 53 struct clk_hw *div_hw = &periph->divider.hw; 54 - unsigned long rate; 54 + long rate; 55 55 56 56 __clk_hw_set_clk(div_hw, hw); 57 57 ··· 59 59 if (rate < 0) 60 60 return rate; 61 61 62 - req->rate = rate; 62 + req->rate = (unsigned long)rate; 63 63 return 0; 64 64 } 65 65