diff options
author | Caleb Connolly <caleb.connolly@linaro.org> | 2023-11-14 12:51:12 +0000 |
---|---|---|
committer | Caleb Connolly <caleb.connolly@linaro.org> | 2024-01-16 12:26:53 +0000 |
commit | a4ba2a66639ed5db672800a52e6d02b4e83573c2 (patch) | |
tree | 8c661f91aaaa0fa7f84c6e32875d20dbdd2dbc4c /drivers | |
parent | 836b7f447429960fa6ff8b6d25c11e39b8c00b94 (diff) | |
download | u-boot-a4ba2a66639ed5db672800a52e6d02b4e83573c2.tar.gz u-boot-a4ba2a66639ed5db672800a52e6d02b4e83573c2.tar.bz2 u-boot-a4ba2a66639ed5db672800a52e6d02b4e83573c2.zip |
serial: msm-geni: handle devm_clk_get() errors
devm_clk_get() returns an ERR_PTR on failure, not null. Fix the check to
avoid the board crashing when the clock isn't available.
Additionally, add the missing error handling for this function.
Fixes: 324df15a292e ("serial: qcom: add support for GENI serial driver")
Signed-off-by: Caleb Connolly <caleb.connolly@linaro.org>
Diffstat (limited to 'drivers')
-rw-r--r-- | drivers/serial/serial_msm_geni.c | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/drivers/serial/serial_msm_geni.c b/drivers/serial/serial_msm_geni.c index 0e52e32ddf..e5c3dcffc1 100644 --- a/drivers/serial/serial_msm_geni.c +++ b/drivers/serial/serial_msm_geni.c @@ -188,8 +188,8 @@ static int geni_serial_set_clock_rate(struct udevice *dev, u64 rate) int ret; clk = devm_clk_get(dev, NULL); - if (!clk) - return -EINVAL; + if (IS_ERR(clk)) + return PTR_ERR(clk); ret = clk_set_rate(clk, rate); return ret; @@ -248,11 +248,16 @@ static int msm_serial_setbrg(struct udevice *dev, int baud) struct msm_serial_data *priv = dev_get_priv(dev); u64 clk_rate; u32 clk_div; + int ret; priv->baud = baud; clk_rate = get_clk_div_rate(baud, priv->oversampling, &clk_div); - geni_serial_set_clock_rate(dev, clk_rate); + ret = geni_serial_set_clock_rate(dev, clk_rate); + if (ret < 0) { + pr_err("%s: Couldn't set clock rate: %d\n", __func__, ret); + return ret; + } geni_serial_baud(priv->base, clk_div, baud); return 0; |