From: David Heidelberg Date: Wed, 2 Apr 2025 19:33:26 +0000 (+0200) Subject: iio: light: al3320a: Fix an error handling path in al3320a_probe() X-Git-Url: https://www.infradead.org/git/?a=commitdiff_plain;h=b8154f3477c46453c8be3257d194cf5fdf5b5a23;p=users%2Fjedix%2Flinux-maple.git iio: light: al3320a: Fix an error handling path in al3320a_probe() If regmap_write() fails in al3320a_init(), al3320a_set_pwr_off is not called. In order to avoid such a situation, move the devm_add_action_or_reset() which calls al3320a_set_pwr_off right after a successful al3320a_set_pwr_on. Signed-off-by: David Heidelberg Link: https://patch.msgid.link/20250402-al3010-iio-regmap-v4-3-d189bea87261@ixit.cz Signed-off-by: Jonathan Cameron --- diff --git a/drivers/iio/light/al3320a.c b/drivers/iio/light/al3320a.c index 1b2b0359ed5d..86ed23461cee 100644 --- a/drivers/iio/light/al3320a.c +++ b/drivers/iio/light/al3320a.c @@ -101,6 +101,12 @@ static int al3320a_init(struct al3320a_data *data) if (ret < 0) return ret; + ret = devm_add_action_or_reset(&data->client->dev, + al3320a_set_pwr_off, + data); + if (ret) + return ret; + ret = i2c_smbus_write_byte_data(data->client, AL3320A_REG_CONFIG_RANGE, FIELD_PREP(AL3320A_GAIN_MASK, AL3320A_RANGE_3)); @@ -211,10 +217,6 @@ static int al3320a_probe(struct i2c_client *client) return ret; } - ret = devm_add_action_or_reset(dev, al3320a_set_pwr_off, data); - if (ret < 0) - return ret; - return devm_iio_device_register(dev, indio_dev); }