[PATCH] power: supply: s2mu005-battery: return errors from dev_err_probe() in probe
Zongmin Zhou <[email protected]>
| Newsgroups | org.kernel.vger.linux-pm,org.kernel.vger.linux-kernel |
|---|---|
| Message-ID | <[email protected]> |
From: Zongmin Zhou <[email protected]> s2mu005_fg_i2c_probe() calls dev_err_probe() when devm_mutex_init() or devm_request_threaded_irq() fails, but drops the return value and carries on, finally returning 0. A failed probe is then reported as a success: the device stays registered with an uninitialized mutex and without its IRQ handler installed. Return the error from dev_err_probe() in both places so that the probe fails and the driver core logs the error state properly. Fixes: aa2132799817 ("power: supply: add support for S2MU005 battery fuel gauge device") Cc: Yassine Oudjana <[email protected]> Cc: Kaustabh Chakraborty <[email protected]> Cc: Sebastian Reichel <[email protected]> Signed-off-by: Zongmin Zhou <[email protected]> --- drivers/power/supply/s2mu005-battery.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/power/supply/s2mu005-battery.c b/drivers/power/supply/s2mu005-battery.c index 53de660..a76154e 100644 --- a/drivers/power/supply/s2mu005-battery.c +++ b/drivers/power/supply/s2mu005-battery.c @@ -262,7 +262,7 @@ static int s2mu005_fg_i2c_probe(struct i2c_client *client) ret = devm_mutex_init(dev, &priv->monout_mutex); if (ret) - dev_err_probe(dev, ret, "failed to initialize MONOUT mutex\n"); + return dev_err_probe(dev, ret, "failed to initialize MONOUT mutex\n"); psy_desc = device_get_match_data(dev); @@ -277,7 +277,7 @@ static int s2mu005_fg_i2c_probe(struct i2c_client *client) s2mu005_handle_irq, IRQF_ONESHOT, psy_desc->name, priv); if (ret) - dev_err_probe(dev, ret, "failed to request IRQ\n"); + return dev_err_probe(dev, ret, "failed to request IRQ\n"); return 0; } -- 2.34.1 No virus found Checked by Hillstone Network AntiVirus