Skip to contentSkip to conversation

clk: actions: owl-pll: cast delay to unsigned long for uelay()

PATCH Superseded Rosen Penev 2 participants 2 messages Sep 4 – Sep 12

Subsystems (2)

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 clk: actions: owl-pll: cast delay to unsigned long for uelay()

The 'delay' field in struct owl_pll_hw is u8, but udelay() internally compares its argument against MAX_UDELAY_MS * 1000 (2000). Since a u8 can never exceed 255, the compiler warns of a tautological comparison that is always false:

drivers/clk/actions/owl-pll.c:189:2: error: result of comparison of constant 2000 with expression of type 'u8' is always false

Cast the delay value to unsigned long to widen the type and silence the warning without changing behavior.

Assisted-by opencode:big-pickle
---
 drivers/clk/actions/owl-pll.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/clk/actions/owl-pll.c +1 -1
index 869690b79cc1..5e30ce35f2f5 100644
@@ -186,7 +186,7 @@ static int owl_pll_set_rate(struct clk_hw *hw, unsigned long rate,
 
 	regmap_write(common->regmap, pll_hw->reg, reg);
 
-	udelay(pll_hw->delay);
+	udelay((unsigned long)pll_hw->delay);
 
 	return 0;
 }
Signature · 1 line
2.55.0
#1 lore raw

Hi Rosen,

The subject has a typo: s/uelay/udelay/

Quoted 10 lines · Rosen Penev

The 'delay' field in struct owl_pll_hw is u8, but udelay() internally compares its argument against MAX_UDELAY_MS * 1000 (2000). Since a u8 can never exceed 255, the compiler warns of a tautological comparison that is always false:

drivers/clk/actions/owl-pll.c:189:2: error: result of comparison of constant 2000 with expression of type 'u8' is always false

Cast the delay value to unsigned long to widen the type and silence the warning without changing behavior.

Just to clarify: This only shows up with a W=1 build, right? If so, it would be good to clarify that in the commit message.

Quoted 2 lines
Assisted-by opencode:big-pickle

The new guidance is:

Assisted-by LLM

Brian