i2c: npcm: Fix error detection

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>
This commit is contained in:
Andrew Goodbody 2025-10-21 17:08:28 +01:00 committed by Tom Rini
parent ae4f60801f
commit eb13583b9d

View File

@ -573,7 +573,7 @@ static int npcm_i2c_probe(struct udevice *dev)
return ret; return ret;
} }
bus->apb_clk = clk_get_rate(&clk); 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__); printf("%s: fail to get rate\n", __func__);
return -EINVAL; return -EINVAL;
} }