]> git.ipfire.org Git - thirdparty/u-boot.git/commitdiff
clk: cdce9xx: Fix use of dev_read_u32_default
authorAndrew Goodbody <andrew.goodbody@linaro.org>
Fri, 25 Jul 2025 10:41:12 +0000 (11:41 +0100)
committerTom Rini <trini@konsulko.com>
Mon, 11 Aug 2025 21:11:22 +0000 (15:11 -0600)
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@linaro.org>
Fixes: 260777fc2333 ("clk: cdce9xx: add support for cdce9xx clock synthesizer")
Acked-by: Quentin Schulz <quentin.schulz@cherry.de>
drivers/clk/clk-cdce9xx.c

index e5f74e714d54712e8b413c85bef5099993f0f57f..996cc30683ea198ecfa06efc7feb25836b6bc7a8 100644 (file)
@@ -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;