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 <[email protected]>
---
v2 => v3
Split to own patch.
---
drivers/iio/adc/ad7192.c | 15 ++-------------
1 file changed, 2 insertions(+), 13 deletions(-)
diff --git a/drivers/iio/adc/ad7192.c b/drivers/iio/adc/ad7192.c
index d71977be7d22..8a52c0dec3f9 100644
--- a/drivers/iio/adc/ad7192.c
+++ b/drivers/iio/adc/ad7192.c
@@ -177,7 +177,6 @@ struct ad7192_chip_info {
struct ad7192_state {
const struct ad7192_chip_info *chip_info;
struct regulator *avdd;
- struct regulator *dvdd;
struct clk *mclk;
u16 int_vref_mv;
u32 fclk;
@@ -1015,19 +1014,9 @@ static int ad7192_probe(struct spi_device *spi)
if (ret)
return ret;
- st->dvdd = devm_regulator_get(&spi->dev, "dvdd");
- if (IS_ERR(st->dvdd))
- return PTR_ERR(st->dvdd);
-
- ret = regulator_enable(st->dvdd);
- if (ret) {
- dev_err(&spi->dev, "Failed to enable specified DVdd supply\n");
- return ret;
- }
-
- ret = devm_add_action_or_reset(&spi->dev, ad7192_reg_disable, st->dvdd);
+ ret = devm_regulator_get_enable(&spi->dev, "dvdd");
if (ret)
- return ret;
+ return dev_err_probe(&spi->dev, ret, "Failed to enable specified DVdd supply\n");
ret = regulator_get_voltage(st->avdd);
if (ret < 0) {
--
2.37.1
--
Matti Vaittinen, Linux device drivers
ROHM Semiconductors, Finland SWDC
Kiviharjunlenkki 1E
90220 OULU
FINLAND
~~~ "I don't think so," said Rene Descartes. Just then he vanished ~~~
Simon says - in Latin please.
~~~ "non cogito me" dixit Rene Descarte, deinde evanescavit ~~~
Thanks to Simon Glass for the translation =]
On Fri, 19 Aug 2022 22:19:01 +0300
Matti Vaittinen <[email protected]> wrote:
> 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 <[email protected]>
Now the required dependencies are upstream...
Applied to the togreg branch of iio.git.
Thanks,
Jonathan
>
> ---
> v2 => v3
> Split to own patch.
> ---
> drivers/iio/adc/ad7192.c | 15 ++-------------
> 1 file changed, 2 insertions(+), 13 deletions(-)
>
> diff --git a/drivers/iio/adc/ad7192.c b/drivers/iio/adc/ad7192.c
> index d71977be7d22..8a52c0dec3f9 100644
> --- a/drivers/iio/adc/ad7192.c
> +++ b/drivers/iio/adc/ad7192.c
> @@ -177,7 +177,6 @@ struct ad7192_chip_info {
> struct ad7192_state {
> const struct ad7192_chip_info *chip_info;
> struct regulator *avdd;
> - struct regulator *dvdd;
> struct clk *mclk;
> u16 int_vref_mv;
> u32 fclk;
> @@ -1015,19 +1014,9 @@ static int ad7192_probe(struct spi_device *spi)
> if (ret)
> return ret;
>
> - st->dvdd = devm_regulator_get(&spi->dev, "dvdd");
> - if (IS_ERR(st->dvdd))
> - return PTR_ERR(st->dvdd);
> -
> - ret = regulator_enable(st->dvdd);
> - if (ret) {
> - dev_err(&spi->dev, "Failed to enable specified DVdd supply\n");
> - return ret;
> - }
> -
> - ret = devm_add_action_or_reset(&spi->dev, ad7192_reg_disable, st->dvdd);
> + ret = devm_regulator_get_enable(&spi->dev, "dvdd");
> if (ret)
> - return ret;
> + return dev_err_probe(&spi->dev, ret, "Failed to enable specified DVdd supply\n");
>
> ret = regulator_get_voltage(st->avdd);
> if (ret < 0) {