mfd: lp87565: fix error handling while getting reset GPIO
PATCH 1/1 mfd: lp87565: fix error handling while getting reset GPIO
If devm_gpiod_get_optional() returns an error the driver code just goes on, soon using a pointer that holds an error. The only exception is -EPROBE_DEFER which is correctly handled.
Fix and also simplify code by always calling dev_err_probe().
Fixes 50e4d7a2a667 ("mfd: lp87565: Handle optional reset pin")
Reported-by Dan Carpenter <[email protected]>
Signed-off-by Luca Ceresoli <[email protected]>
--- drivers/mfd/lp87565.c | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-)
drivers/mfd/lp87565.c +3 -5
@@ -67,11 +67,9 @@ static int lp87565_probe(struct i2c_client *client, lp87565->reset_gpio =devm_gpiod_get_optional (lp87565->dev,"reset" ,GPIOD_OUT_LOW ); -if (IS_ERR (lp87565->reset_gpio)) { - ret =PTR_ERR (lp87565->reset_gpio); -if (ret == -EPROBE_DEFER ) -return ret; - } +if (IS_ERR (lp87565->reset_gpio)) +return dev_err_probe (lp87565->dev,PTR_ERR (lp87565->reset_gpio), +"Failed getting reset GPIO" );if (lp87565->reset_gpio) {gpiod_set_value_cansleep (lp87565->reset_gpio,1 );
Signature · 1 line
2.34.0