Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

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>

authored by

David Heidelberg and committed by
Jonathan Cameron
c0461f8e 42b1a266

+5 -4
+5 -4
drivers/iio/light/al3000a.c
··· 85 85 86 86 static int al3000a_init(struct al3000a_data *data) 87 87 { 88 + struct device *dev = regmap_get_device(data->regmap); 88 89 int ret; 89 90 90 91 ret = al3000a_set_pwr_on(data); 91 92 if (ret) 92 93 return ret; 94 + 95 + ret = devm_add_action_or_reset(dev, al3000a_set_pwr_off, data); 96 + if (ret) 97 + return dev_err_probe(dev, ret, "failed to add action\n"); 93 98 94 99 ret = regmap_write(data->regmap, AL3000A_REG_SYSTEM, AL3000A_CONFIG_RESET); 95 100 if (ret) ··· 161 156 ret = al3000a_init(data); 162 157 if (ret) 163 158 return dev_err_probe(dev, ret, "failed to init ALS\n"); 164 - 165 - ret = devm_add_action_or_reset(dev, al3000a_set_pwr_off, data); 166 - if (ret) 167 - return dev_err_probe(dev, ret, "failed to add action\n"); 168 159 169 160 return devm_iio_device_register(dev, indio_dev); 170 161 }