[PATCH 1/6] mmc: hi6220_dw_mmc: Fix error detection for clk_get_rate

Andrew Goodbody andrew.goodbody at linaro.org
Tue Oct 21 18:08:25 CEST 2025


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 <andrew.goodbody at linaro.org>
---
 drivers/mmc/hi6220_dw_mmc.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/mmc/hi6220_dw_mmc.c b/drivers/mmc/hi6220_dw_mmc.c
index 0302f5c296b90c6fd89f7d32b91758291499f6af..27609e90b1f4741dcb1a95afff8be5ce2d5e5a8a 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);

-- 
2.47.3



More information about the U-Boot mailing list