[PATCH v2] clk: cdce9xx: Fix use of dev_read_u32_default

Andrew Goodbody andrew.goodbody at linaro.org
Fri Jul 25 12:41:12 CEST 2025


The function dev_read_u32_default does not return an error and the
variable 'val' is unsigned so testing for >= 0 will always be true. It
looks like the code was attempting to return -1 if xtal-load-pf was not
present but that cannot work. Instead use dev_read_u32 which returns an
error code separately from writing the value into the passed pointer.

This issue was found by Smatch.

Signed-off-by: Andrew Goodbody <andrew.goodbody at linaro.org>
---
Changes in v2:
- Instead of removing the always true test use the non-default version
  of dev_read_u32 which can return an error while writing to a u32.
- Link to v1: https://lore.kernel.org/r/20250723-cdce9xx_clk-v1-1-9cb1f734637b@linaro.org
---
 drivers/clk/clk-cdce9xx.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/clk/clk-cdce9xx.c b/drivers/clk/clk-cdce9xx.c
index e5f74e714d5..996cc30683e 100644
--- a/drivers/clk/clk-cdce9xx.c
+++ b/drivers/clk/clk-cdce9xx.c
@@ -116,8 +116,7 @@ static int cdce9xx_clk_probe(struct udevice *dev)
 	ret = clk_get_by_index(dev, 0, &clk);
 	data->xtal_rate = clk_get_rate(&clk);
 
-	val = dev_read_u32_default(dev, "xtal-load-pf", -1);
-	if (val >= 0)
+	if (!dev_read_u32(dev, "xtal-load-pf", &val))
 		cdce9xx_reg_write(dev, CDCE9XX_REG_XCSEL, val << 3);
 
 	return 0;

---
base-commit: bd0ade7d090a334b3986936d63a34001d99722ad
change-id: 20250723-cdce9xx_clk-9e1008c78db7

Best regards,
-- 
Andrew Goodbody <andrew.goodbody at linaro.org>



More information about the U-Boot mailing list