iio: adc: max1363: simplify using devm_regulator_get_enable()
authorMatti Vaittinen <mazziesaccount@gmail.com>
Fri, 19 Aug 2022 19:20:47 +0000 (22:20 +0300)
committerJonathan Cameron <Jonathan.Cameron@huawei.com>
Wed, 23 Nov 2022 19:44:01 +0000 (19:44 +0000)
Drop open-coded pattern: 'devm_regulator_get(), regulator_enable(),
add_action_or_reset(regulator_disable)' and use the
devm_regulator_get_enable() and drop the pointer to the regulator.
This simplifies code and makes it less tempting to add manual control
for the regulator which is also controlled by devm.

Signed-off-by: Matti Vaittinen <mazziesaccount@gmail.com>
Acked-by: Nuno Sá <nuno.sa@analog.com>
Link: https://lore.kernel.org/r/1286ea127d190e5708a0aaff271819b2d3f8802d.1660934107.git.mazziesaccount@gmail.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
drivers/iio/adc/max1363.c

index a28cf86cdce804672572da2e679914d98f204918..42d3479cefb73c48d73f83218576f0a5e6ab3c33 100644 (file)
@@ -148,7 +148,6 @@ struct max1363_chip_info {
  * @chip_info:         chip model specific constants, available modes, etc.
  * @current_mode:      the scan mode of this chip
  * @requestedmask:     a valid requested set of channels
- * @reg:               supply regulator
  * @lock:              lock to ensure state is consistent
  * @monitor_on:                whether monitor mode is enabled
  * @monitor_speed:     parameter corresponding to device monitor speed setting
@@ -168,7 +167,6 @@ struct max1363_state {
        const struct max1363_chip_info  *chip_info;
        const struct max1363_mode       *current_mode;
        u32                             requestedmask;
-       struct regulator                *reg;
        struct mutex                    lock;
 
        /* Using monitor modes and buffer at the same time is
@@ -1597,15 +1595,7 @@ static int max1363_probe(struct i2c_client *client,
        st = iio_priv(indio_dev);
 
        mutex_init(&st->lock);
-       st->reg = devm_regulator_get(&client->dev, "vcc");
-       if (IS_ERR(st->reg))
-               return PTR_ERR(st->reg);
-
-       ret = regulator_enable(st->reg);
-       if (ret)
-               return ret;
-
-       ret = devm_add_action_or_reset(&client->dev, max1363_reg_disable, st->reg);
+       ret = devm_regulator_get_enable(&client->dev, "vcc");
        if (ret)
                return ret;