[PATCH 04/15] clk: tegra: Fix -Wtype-limits compiler warning

Sascha Hauer s.hauer at pengutronix.de
Mon May 17 11:54:13 PDT 2021


divider_ux1 is checked for being smaller than 0 which can never happen
for an unsigned variable. Fix the check in a way it's currently done in
Linux

Signed-off-by: Sascha Hauer <s.hauer at pengutronix.de>
---
 drivers/clk/tegra/clk-divider.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/clk/tegra/clk-divider.c b/drivers/clk/tegra/clk-divider.c
index cc8b85520c..8ac8c98e9f 100644
--- a/drivers/clk/tegra/clk-divider.c
+++ b/drivers/clk/tegra/clk-divider.c
@@ -46,11 +46,11 @@ static int get_div(struct tegra_clk_frac_div *divider, unsigned long rate,
 	if (flags & TEGRA_DIVIDER_INT)
 		divider_ux1 *= mul;
 
-	divider_ux1 -= mul;
-
-	if (divider_ux1 < 0)
+	if (divider_ux1 < mul)
 		return 0;
 
+	divider_ux1 -= mul;
+
 	if (divider_ux1 > get_max_div(divider))
 		return -EINVAL;
 
-- 
2.29.2




More information about the barebox mailing list