diff options
| author | Tom Rini <[email protected]> | 2025-12-04 09:38:46 -0600 |
|---|---|---|
| committer | Tom Rini <[email protected]> | 2025-12-04 09:38:46 -0600 |
| commit | 8eed8a355843897258c3f22727b32abe95464b08 (patch) | |
| tree | 4da301a1b2470ecba5c84a241f8aaff1f7bd9fd4 | |
| parent | 2d08dfc1dc4fc159b13d54535fdca4566b5808d1 (diff) | |
| parent | ce219307a21fe7166b13542ba923ee09aef7f2f5 (diff) | |
Merge patch series "clk: Fix some error detection"
Andrew Goodbody <[email protected]> says:
The function clk_get_rate() returns a ulong with 0 meaning an invalid
clock rate and also negative error codes being returned for other
errors. But being an unsigned return value this cannot simply be tested
for with a < 0 test. Instead use the IS_ERR_VALUE() macro to check for
negative errors appearing as very large positive values. Fix those
places that test for <= 0. Also fix some places checking the return of
clk_register() that incorrectly used ERR_PTR().
Link: https://lore.kernel.org/r/[email protected]
| -rw-r--r-- | drivers/clk/microchip/mpfs_clk_cfg.c | 2 | ||||
| -rw-r--r-- | drivers/clk/microchip/mpfs_clk_msspll.c | 2 | ||||
| -rw-r--r-- | drivers/clk/microchip/mpfs_clk_periph.c | 2 | ||||
| -rw-r--r-- | drivers/i2c/imx_lpi2c.c | 2 | ||||
| -rw-r--r-- | drivers/i2c/npcm_i2c.c | 2 | ||||
| -rw-r--r-- | drivers/mmc/fsl_esdhc_imx.c | 2 | ||||
| -rw-r--r-- | drivers/mmc/hi6220_dw_mmc.c | 6 | ||||
| -rw-r--r-- | drivers/timer/imx-gpt-timer.c | 2 |
8 files changed, 10 insertions, 10 deletions
diff --git a/drivers/clk/microchip/mpfs_clk_cfg.c b/drivers/clk/microchip/mpfs_clk_cfg.c index 7da1fc77120..b64fb6b7193 100644 --- a/drivers/clk/microchip/mpfs_clk_cfg.c +++ b/drivers/clk/microchip/mpfs_clk_cfg.c @@ -131,7 +131,7 @@ int mpfs_clk_register_cfgs(struct clk *parent, struct regmap *regmap) name = mpfs_cfg_clks[i].cfg.name; ret = clk_register(hw, MPFS_CFG_CLOCK, name, parent->dev->name); if (ret) - ERR_PTR(ret); + return ret; id = mpfs_cfg_clks[i].cfg.id; clk_dm(id, hw); } diff --git a/drivers/clk/microchip/mpfs_clk_msspll.c b/drivers/clk/microchip/mpfs_clk_msspll.c index d0e7b1ff844..02b4a344467 100644 --- a/drivers/clk/microchip/mpfs_clk_msspll.c +++ b/drivers/clk/microchip/mpfs_clk_msspll.c @@ -99,7 +99,7 @@ int mpfs_clk_register_msspll(void __iomem *base, struct clk *parent) name = mpfs_msspll_clks[0].name; ret = clk_register(hw, MPFS_MSSPLL_CLOCK, name, parent->dev->name); if (ret) - ERR_PTR(ret); + return ret; id = mpfs_msspll_clks[0].id; clk_dm(id, hw); diff --git a/drivers/clk/microchip/mpfs_clk_periph.c b/drivers/clk/microchip/mpfs_clk_periph.c index b734f49d81a..706d6841ee4 100644 --- a/drivers/clk/microchip/mpfs_clk_periph.c +++ b/drivers/clk/microchip/mpfs_clk_periph.c @@ -176,7 +176,7 @@ int mpfs_clk_register_periphs(struct udevice *dev, struct regmap *regmap) name = mpfs_periph_clks[i].periph.name; ret = clk_register(hw, MPFS_PERIPH_CLOCK, name, parent.dev->name); if (ret) - ERR_PTR(ret); + return ret; id = mpfs_periph_clks[i].periph.id; clk_dm(id, hw); } diff --git a/drivers/i2c/imx_lpi2c.c b/drivers/i2c/imx_lpi2c.c index 4636da9f301..a309fd6f07c 100644 --- a/drivers/i2c/imx_lpi2c.c +++ b/drivers/i2c/imx_lpi2c.c @@ -304,7 +304,7 @@ static int bus_i2c_set_bus_speed(struct udevice *bus, int speed) if (CONFIG_IS_ENABLED(CLK)) { clock_rate = clk_get_rate(&i2c_bus->per_clk); - if (clock_rate <= 0) { + if (!clock_rate || IS_ERR_VALUE(clock_rate)) { dev_err(bus, "Failed to get i2c clk: %d\n", clock_rate); return clock_rate; } diff --git a/drivers/i2c/npcm_i2c.c b/drivers/i2c/npcm_i2c.c index bff0d04f1a5..d57237a6df1 100644 --- a/drivers/i2c/npcm_i2c.c +++ b/drivers/i2c/npcm_i2c.c @@ -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; } diff --git a/drivers/mmc/fsl_esdhc_imx.c b/drivers/mmc/fsl_esdhc_imx.c index 926113f79d3..7dc76563b7e 100644 --- a/drivers/mmc/fsl_esdhc_imx.c +++ b/drivers/mmc/fsl_esdhc_imx.c @@ -1543,7 +1543,7 @@ static int fsl_esdhc_probe(struct udevice *dev) init_clk_usdhc(dev_seq(dev)); priv->sdhc_clk = mxc_get_clock(MXC_ESDHC_CLK + dev_seq(dev)); - if (priv->sdhc_clk <= 0) { + if (!priv->sdhc_clk || IS_ERR_VALUE(priv->sdhc_clk)) { dev_err(dev, "Unable to get clk for %s\n", dev->name); return -EINVAL; } 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); diff --git a/drivers/timer/imx-gpt-timer.c b/drivers/timer/imx-gpt-timer.c index 07b9fdb5e18..7708d1ba17f 100644 --- a/drivers/timer/imx-gpt-timer.c +++ b/drivers/timer/imx-gpt-timer.c @@ -127,7 +127,7 @@ static int imx_gpt_timer_probe(struct udevice *dev) /* Get timer clock rate */ clk_rate = clk_get_rate(&clk); - if (clk_rate <= 0) { + if (!clk_rate || IS_ERR_VALUE(clk_rate)) { dev_err(dev, "Could not get clock rate...\n"); return -EINVAL; } |
