mirror of
https://github.com/torvalds/linux.git
synced 2026-06-01 02:53:36 +02:00
iio: light: al3000a: Fix an error handling path in al3000a_probe()
If regmap_write() fails in al3000a_init(), al3000a_set_pwr_off is not called. In order to avoid such a situation, move the devm_add_action_or_reset() which calls al3000a_set_pwr_off right after a successful al3000a_set_pwr_on. Signed-off-by: David Heidelberg <david@ixit.cz> Link: https://patch.msgid.link/20250402-al3010-iio-regmap-v4-2-d189bea87261@ixit.cz Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
This commit is contained in:
parent
42b1a2663f
commit
c0461f8e84
|
|
@ -85,12 +85,17 @@ static void al3000a_set_pwr_off(void *_data)
|
|||
|
||||
static int al3000a_init(struct al3000a_data *data)
|
||||
{
|
||||
struct device *dev = regmap_get_device(data->regmap);
|
||||
int ret;
|
||||
|
||||
ret = al3000a_set_pwr_on(data);
|
||||
if (ret)
|
||||
return ret;
|
||||
|
||||
ret = devm_add_action_or_reset(dev, al3000a_set_pwr_off, data);
|
||||
if (ret)
|
||||
return dev_err_probe(dev, ret, "failed to add action\n");
|
||||
|
||||
ret = regmap_write(data->regmap, AL3000A_REG_SYSTEM, AL3000A_CONFIG_RESET);
|
||||
if (ret)
|
||||
return ret;
|
||||
|
|
@ -157,10 +162,6 @@ static int al3000a_probe(struct i2c_client *client)
|
|||
if (ret)
|
||||
return dev_err_probe(dev, ret, "failed to init ALS\n");
|
||||
|
||||
ret = devm_add_action_or_reset(dev, al3000a_set_pwr_off, data);
|
||||
if (ret)
|
||||
return dev_err_probe(dev, ret, "failed to add action\n");
|
||||
|
||||
return devm_iio_device_register(dev, indio_dev);
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user