]> git.ipfire.org Git - thirdparty/u-boot.git/commitdiff
i2c: npcm: Fix error detection
authorAndrew Goodbody <andrew.goodbody@linaro.org>
Tue, 21 Oct 2025 16:08:28 +0000 (17:08 +0100)
committerTom Rini <trini@konsulko.com>
Thu, 4 Dec 2025 15:38:17 +0000 (09:38 -0600)
Testing an unisgned member of a struct to be <= 0 will only detect the
case when it is 0. So correct this error test to a working version that
will behave as expected.

Signed-off-by: Andrew Goodbody <andrew.goodbody@linaro.org>
Reviewed-by: Heiko Schocher <hs@nabladev.com>
drivers/i2c/npcm_i2c.c

index bff0d04f1a5ae2c261657a5776b38e4ab6ad4d28..d57237a6df167d579ab4b8d45f3989a8cac0fc68 100644 (file)
@@ -573,7 +573,7 @@ static int npcm_i2c_probe(struct udevice *dev)
                return ret;
        }
        bus->apb_clk = clk_get_rate(&clk);
-       if (bus->apb_clk <= 0) {
+       if (!bus->apb_clk || IS_ERR_VALUE(bus->apb_clk)) {
                printf("%s: fail to get rate\n", __func__);
                return -EINVAL;
        }