From: Andrew Goodbody Date: Tue, 21 Oct 2025 16:08:25 +0000 (+0100) Subject: mmc: hi6220_dw_mmc: Fix error detection for clk_get_rate X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=e24a7b3b172379b50a7fa96ab4634de109c3e432;p=thirdparty%2Fu-boot.git mmc: hi6220_dw_mmc: Fix error detection for clk_get_rate clk_get_rate() returns a ulong and that return value is assigned to a member of a struct that is an unsigned int. So testing this value to <= 0 will only detect a return of 0. Also the code in the if block assumes ret holds the return value when it does not. So update the test to one that will work as intended and update the if block to actually refer to the return value. Signed-off-by: Andrew Goodbody --- diff --git a/drivers/mmc/hi6220_dw_mmc.c b/drivers/mmc/hi6220_dw_mmc.c index 0302f5c296b..27609e90b1f 100644 --- a/drivers/mmc/hi6220_dw_mmc.c +++ b/drivers/mmc/hi6220_dw_mmc.c @@ -114,9 +114,9 @@ static int hi6220_dwmmc_probe(struct udevice *dev) } host->bus_hz = clk_get_rate(priv->clks[HI6220_DWMMC_CLK_CIU]); - if (host->bus_hz <= 0) { - dev_err(dev, "Failed to get ciu clock rate(ret = %d).\n", ret); - return log_msg_ret("clk", ret); + if (!host->bus_hz || IS_ERR_VALUE(host->bus_hz)) { + dev_err(dev, "Failed to get ciu clock rate(ret = %d).\n", host->bus_hz); + return log_msg_ret("clk", host->bus_hz); } } dev_dbg(dev, "bus clock rate: %d.\n", host->bus_hz);