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

iio: adc: ad7192: Simplify using devm_regulator_get_enable()

Use devm_regulator_get_enable() instead of open coded get, enable,
add-action-to-disable-at-detach - pattern. Also drop the seemingly unused
struct member 'dvdd'.

Signed-off-by: Matti Vaittinen <mazziesaccount@gmail.com>
Link: https://lore.kernel.org/r/9719c445c095d3d308e2fc9f4f93294f5806c41c.1660934107.git.mazziesaccount@gmail.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>

authored by

Matti Vaittinen and committed by
Jonathan Cameron
1ccef2e6 62bfa12c

+2 -13
+2 -13
drivers/iio/adc/ad7192.c
··· 177 177 struct ad7192_state { 178 178 const struct ad7192_chip_info *chip_info; 179 179 struct regulator *avdd; 180 - struct regulator *dvdd; 181 180 struct clk *mclk; 182 181 u16 int_vref_mv; 183 182 u32 fclk; ··· 1014 1015 if (ret) 1015 1016 return ret; 1016 1017 1017 - st->dvdd = devm_regulator_get(&spi->dev, "dvdd"); 1018 - if (IS_ERR(st->dvdd)) 1019 - return PTR_ERR(st->dvdd); 1020 - 1021 - ret = regulator_enable(st->dvdd); 1022 - if (ret) { 1023 - dev_err(&spi->dev, "Failed to enable specified DVdd supply\n"); 1024 - return ret; 1025 - } 1026 - 1027 - ret = devm_add_action_or_reset(&spi->dev, ad7192_reg_disable, st->dvdd); 1018 + ret = devm_regulator_get_enable(&spi->dev, "dvdd"); 1028 1019 if (ret) 1029 - return ret; 1020 + return dev_err_probe(&spi->dev, ret, "Failed to enable specified DVdd supply\n"); 1030 1021 1031 1022 ret = regulator_get_voltage(st->avdd); 1032 1023 if (ret < 0) {