All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 00/14] IIO: More devm_regulator[_bulk]_get_enable() users
@ 2022-10-16 16:33 Jonathan Cameron
  2022-10-16 16:33 ` [PATCH 01/14] iio: accel: adxl367: Use devm_regulator_bulk_get_enable() Jonathan Cameron
                   ` (14 more replies)
  0 siblings, 15 replies; 39+ messages in thread
From: Jonathan Cameron @ 2022-10-16 16:33 UTC (permalink / raw)
  To: linux-iio
  Cc: Matti Vaittinen, Matti Vaittinen, Cosmin Tanislav, Jagath Jog J,
	Sean Nyekjaer, Dmitry Rokosov, Linus Walleij, Andy Shevchenko,
	Michael Hennerich, Lorenzo Bianconi, Martyn Welch,
	Gwendal Grignou, Stephen Boyd, Tomasz Duszynski,
	Jonathan Cameron

From: Jonathan Cameron <Jonathan.Cameron@huawei.com>

Also one general devm conversion that was too easy to ignore after
dealing with the regulators.

These new macros allow dropping of some boilerplate.  They are not
useful in many cases in IIO because they do not expose the
struct regulator, however for simple drivers that just turn the power
on at probe() they ensure that it is turned off again at remove.

Jonathan Cameron (14):
  iio: accel: adxl367: Use devm_regulator_bulk_get_enable()
  iio: accel: bma400: Use devm_regulator_bulk_get_enable()
  iio: accel: fxls8962af: Use devm_regulator_get_enable()
  iio: accel: kxcjk-1013: Use devm_regulator_bulk_get_enable()
  iio: accel: msa311: Use devm_regulator_get_enable()
  iio: cdc: ad7150: Use devm_regulator_get_enable()
  iio: st_sensors: core and lsm9ds0 switch to
    devm_regulator_bulk_get_enable()
  iio: frequency: ad9523: Use devm_regulator_get_enable()
  iio: humidity: hts211: Use devm_regulator_get_enable()
  iio: light: ltr501: Use devm_regulator_bulk_get_enable()
  iio: light: noa1305: Use devm_regulator_get_enable()
  iio: proximity: sx_common: Use devm_regulator_bulk_get_enable()
  iio: pressure: ms5611: Use devm_regulator_get_enable()
  iio: pressure: ms5611: Switch to fully devm_ managed registration.

 drivers/iio/accel/adxl367.c                   | 28 ++------
 drivers/iio/accel/bma400.h                    |  4 --
 drivers/iio/accel/bma400_core.c               | 29 ++-------
 drivers/iio/accel/fxls8962af-core.c           | 24 +------
 drivers/iio/accel/kxcjk-1013.c                | 25 ++-----
 drivers/iio/accel/msa311.c                    | 21 +-----
 drivers/iio/cdc/ad7150.c                      | 18 +----
 .../iio/common/st_sensors/st_sensors_core.c   | 39 ++---------
 drivers/iio/frequency/ad9523.c                | 22 +------
 drivers/iio/humidity/hts221.h                 |  2 -
 drivers/iio/humidity/hts221_core.c            | 27 ++------
 drivers/iio/imu/st_lsm9ds0/st_lsm9ds0_core.c  | 65 ++-----------------
 drivers/iio/light/ltr501.c                    | 27 ++------
 drivers/iio/light/noa1305.c                   | 26 +-------
 drivers/iio/pressure/ms5611.h                 |  4 --
 drivers/iio/pressure/ms5611_core.c            | 49 +++-----------
 drivers/iio/pressure/ms5611_i2c.c             |  6 --
 drivers/iio/pressure/ms5611_spi.c             |  6 --
 drivers/iio/proximity/sx_common.c             | 23 +------
 drivers/iio/proximity/sx_common.h             |  2 -
 include/linux/iio/common/st_sensors.h         |  4 --
 21 files changed, 57 insertions(+), 394 deletions(-)

-- 
2.37.2


^ permalink raw reply	[flat|nested] 39+ messages in thread

* [PATCH 01/14] iio: accel: adxl367: Use devm_regulator_bulk_get_enable()
  2022-10-16 16:33 [PATCH 00/14] IIO: More devm_regulator[_bulk]_get_enable() users Jonathan Cameron
@ 2022-10-16 16:33 ` Jonathan Cameron
  2022-10-17  5:26   ` Matti Vaittinen
  2022-10-16 16:33 ` [PATCH 02/14] iio: accel: bma400: " Jonathan Cameron
                   ` (13 subsequent siblings)
  14 siblings, 1 reply; 39+ messages in thread
From: Jonathan Cameron @ 2022-10-16 16:33 UTC (permalink / raw)
  To: linux-iio
  Cc: Matti Vaittinen, Matti Vaittinen, Cosmin Tanislav, Jagath Jog J,
	Sean Nyekjaer, Dmitry Rokosov, Linus Walleij, Andy Shevchenko,
	Michael Hennerich, Lorenzo Bianconi, Martyn Welch,
	Gwendal Grignou, Stephen Boyd, Tomasz Duszynski,
	Jonathan Cameron

From: Jonathan Cameron <Jonathan.Cameron@huawei.com>

This driver only turns the power on at probe and off via a custom
devm_add_action_or_reset() callback. The new
devm_regulator_bulk_get_enable() replaces this boilerplate code.

Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Cc: Cosmin Tanislav <cosmin.tanislav@analog.com>
---
 drivers/iio/accel/adxl367.c | 28 ++++------------------------
 1 file changed, 4 insertions(+), 24 deletions(-)

diff --git a/drivers/iio/accel/adxl367.c b/drivers/iio/accel/adxl367.c
index 47feb375b70b..d0a47ab9d82f 100644
--- a/drivers/iio/accel/adxl367.c
+++ b/drivers/iio/accel/adxl367.c
@@ -160,8 +160,6 @@ struct adxl367_state {
 	struct device			*dev;
 	struct regmap			*regmap;
 
-	struct regulator_bulk_data	regulators[2];
-
 	/*
 	 * Synchronize access to members of driver state, and ensure atomicity
 	 * of consecutive regmap operations.
@@ -1474,16 +1472,10 @@ static int adxl367_setup(struct adxl367_state *st)
 	return adxl367_set_measure_en(st, true);
 }
 
-static void adxl367_disable_regulators(void *data)
-{
-	struct adxl367_state *st = data;
-
-	regulator_bulk_disable(ARRAY_SIZE(st->regulators), st->regulators);
-}
-
 int adxl367_probe(struct device *dev, const struct adxl367_ops *ops,
 		  void *context, struct regmap *regmap, int irq)
 {
+	static const char * const regulator_names[] = { "vdd", "vddio" };
 	struct iio_dev *indio_dev;
 	struct adxl367_state *st;
 	int ret;
@@ -1507,25 +1499,13 @@ int adxl367_probe(struct device *dev, const struct adxl367_ops *ops,
 	indio_dev->info = &adxl367_info;
 	indio_dev->modes = INDIO_DIRECT_MODE;
 
-	st->regulators[0].supply = "vdd";
-	st->regulators[1].supply = "vddio";
-
-	ret = devm_regulator_bulk_get(st->dev, ARRAY_SIZE(st->regulators),
-				      st->regulators);
+	ret = devm_regulator_bulk_get_enable(st->dev,
+					     ARRAY_SIZE(regulator_names),
+					     regulator_names);
 	if (ret)
 		return dev_err_probe(st->dev, ret,
 				     "Failed to get regulators\n");
 
-	ret = regulator_bulk_enable(ARRAY_SIZE(st->regulators), st->regulators);
-	if (ret)
-		return dev_err_probe(st->dev, ret,
-				     "Failed to enable regulators\n");
-
-	ret = devm_add_action_or_reset(st->dev, adxl367_disable_regulators, st);
-	if (ret)
-		return dev_err_probe(st->dev, ret,
-				     "Failed to add regulators disable action\n");
-
 	ret = regmap_write(st->regmap, ADXL367_REG_RESET, ADXL367_RESET_CODE);
 	if (ret)
 		return ret;
-- 
2.37.2


^ permalink raw reply related	[flat|nested] 39+ messages in thread

* [PATCH 02/14] iio: accel: bma400: Use devm_regulator_bulk_get_enable()
  2022-10-16 16:33 [PATCH 00/14] IIO: More devm_regulator[_bulk]_get_enable() users Jonathan Cameron
  2022-10-16 16:33 ` [PATCH 01/14] iio: accel: adxl367: Use devm_regulator_bulk_get_enable() Jonathan Cameron
@ 2022-10-16 16:33 ` Jonathan Cameron
  2022-10-17  5:27   ` Matti Vaittinen
  2022-10-16 16:33 ` [PATCH 03/14] iio: accel: fxls8962af: Use devm_regulator_get_enable() Jonathan Cameron
                   ` (12 subsequent siblings)
  14 siblings, 1 reply; 39+ messages in thread
From: Jonathan Cameron @ 2022-10-16 16:33 UTC (permalink / raw)
  To: linux-iio
  Cc: Matti Vaittinen, Matti Vaittinen, Cosmin Tanislav, Jagath Jog J,
	Sean Nyekjaer, Dmitry Rokosov, Linus Walleij, Andy Shevchenko,
	Michael Hennerich, Lorenzo Bianconi, Martyn Welch,
	Gwendal Grignou, Stephen Boyd, Tomasz Duszynski,
	Jonathan Cameron

From: Jonathan Cameron <Jonathan.Cameron@huawei.com>

This driver only turns the power on at probe and off via a custom
devm_add_action_or_reset() callback. The new
devm_regulator_bulk_get_enable() replaces this boilerplate code.

Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Cc: Jagath Jog J <jagathjog1996@gmail.com>
---
 drivers/iio/accel/bma400.h      |  4 ----
 drivers/iio/accel/bma400_core.c | 29 ++++-------------------------
 2 files changed, 4 insertions(+), 29 deletions(-)

diff --git a/drivers/iio/accel/bma400.h b/drivers/iio/accel/bma400.h
index 36edbaff4f7f..932358b45f17 100644
--- a/drivers/iio/accel/bma400.h
+++ b/drivers/iio/accel/bma400.h
@@ -141,10 +141,6 @@
 #define BMA400_SCALE_MIN            9577
 #define BMA400_SCALE_MAX            76617
 
-#define BMA400_NUM_REGULATORS       2
-#define BMA400_VDD_REGULATOR        0
-#define BMA400_VDDIO_REGULATOR      1
-
 extern const struct regmap_config bma400_regmap_config;
 
 int bma400_probe(struct device *dev, struct regmap *regmap, int irq,
diff --git a/drivers/iio/accel/bma400_core.c b/drivers/iio/accel/bma400_core.c
index e8de88e6cfb9..3ac464c1007c 100644
--- a/drivers/iio/accel/bma400_core.c
+++ b/drivers/iio/accel/bma400_core.c
@@ -98,7 +98,6 @@ enum bma400_activity {
 struct bma400_data {
 	struct device *dev;
 	struct regmap *regmap;
-	struct regulator_bulk_data regulators[BMA400_NUM_REGULATORS];
 	struct mutex mutex; /* data register lock */
 	struct iio_mount_matrix orientation;
 	enum bma400_power_mode power_mode;
@@ -830,13 +829,6 @@ static void bma400_init_tables(void)
 	}
 }
 
-static void bma400_regulators_disable(void *data_ptr)
-{
-	struct bma400_data *data = data_ptr;
-
-	regulator_bulk_disable(ARRAY_SIZE(data->regulators), data->regulators);
-}
-
 static void bma400_power_disable(void *data_ptr)
 {
 	struct bma400_data *data = data_ptr;
@@ -866,6 +858,7 @@ static enum iio_modifier bma400_act_to_mod(enum bma400_activity activity)
 
 static int bma400_init(struct bma400_data *data)
 {
+	static const char * const regulator_names[] = { "vdd", "vddio" };
 	unsigned int val;
 	int ret;
 
@@ -881,27 +874,13 @@ static int bma400_init(struct bma400_data *data)
 		return -ENODEV;
 	}
 
-	data->regulators[BMA400_VDD_REGULATOR].supply = "vdd";
-	data->regulators[BMA400_VDDIO_REGULATOR].supply = "vddio";
-	ret = devm_regulator_bulk_get(data->dev,
-				      ARRAY_SIZE(data->regulators),
-				      data->regulators);
+	ret = devm_regulator_bulk_get_enable(data->dev,
+					     ARRAY_SIZE(regulator_names),
+					     regulator_names);
 	if (ret)
 		return dev_err_probe(data->dev, ret, "Failed to get regulators: %d\n",
 				     ret);
 
-	ret = regulator_bulk_enable(ARRAY_SIZE(data->regulators),
-				    data->regulators);
-	if (ret) {
-		dev_err(data->dev, "Failed to enable regulators: %d\n",
-			ret);
-		return ret;
-	}
-
-	ret = devm_add_action_or_reset(data->dev, bma400_regulators_disable, data);
-	if (ret)
-		return ret;
-
 	ret = bma400_get_power_mode(data);
 	if (ret) {
 		dev_err(data->dev, "Failed to get the initial power-mode\n");
-- 
2.37.2


^ permalink raw reply related	[flat|nested] 39+ messages in thread

* [PATCH 03/14] iio: accel: fxls8962af: Use devm_regulator_get_enable()
  2022-10-16 16:33 [PATCH 00/14] IIO: More devm_regulator[_bulk]_get_enable() users Jonathan Cameron
  2022-10-16 16:33 ` [PATCH 01/14] iio: accel: adxl367: Use devm_regulator_bulk_get_enable() Jonathan Cameron
  2022-10-16 16:33 ` [PATCH 02/14] iio: accel: bma400: " Jonathan Cameron
@ 2022-10-16 16:33 ` Jonathan Cameron
  2022-10-17  5:27   ` Matti Vaittinen
  2022-10-17  9:23   ` Sean Nyekjaer
  2022-10-16 16:33 ` [PATCH 04/14] iio: accel: kxcjk-1013: Use devm_regulator_bulk_get_enable() Jonathan Cameron
                   ` (11 subsequent siblings)
  14 siblings, 2 replies; 39+ messages in thread
From: Jonathan Cameron @ 2022-10-16 16:33 UTC (permalink / raw)
  To: linux-iio
  Cc: Matti Vaittinen, Matti Vaittinen, Cosmin Tanislav, Jagath Jog J,
	Sean Nyekjaer, Dmitry Rokosov, Linus Walleij, Andy Shevchenko,
	Michael Hennerich, Lorenzo Bianconi, Martyn Welch,
	Gwendal Grignou, Stephen Boyd, Tomasz Duszynski,
	Jonathan Cameron

From: Jonathan Cameron <Jonathan.Cameron@huawei.com>

This driver only turns the power on at probe and off via a custom
devm_add_action_or_reset() callback. The new devm_regulator_get_enable()
replaces this boilerplate code.

Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Cc: Sean Nyekjaer <sean@geanix.com>
---
 drivers/iio/accel/fxls8962af-core.c | 24 +++---------------------
 1 file changed, 3 insertions(+), 21 deletions(-)

diff --git a/drivers/iio/accel/fxls8962af-core.c b/drivers/iio/accel/fxls8962af-core.c
index bf259db281f5..0d672b1469e8 100644
--- a/drivers/iio/accel/fxls8962af-core.c
+++ b/drivers/iio/accel/fxls8962af-core.c
@@ -159,7 +159,6 @@ struct fxls8962af_chip_info {
 struct fxls8962af_data {
 	struct regmap *regmap;
 	const struct fxls8962af_chip_info *chip_info;
-	struct regulator *vdd_reg;
 	struct {
 		__le16 channels[3];
 		s64 ts __aligned(8);
@@ -1051,13 +1050,6 @@ static irqreturn_t fxls8962af_interrupt(int irq, void *p)
 	return IRQ_NONE;
 }
 
-static void fxls8962af_regulator_disable(void *data_ptr)
-{
-	struct fxls8962af_data *data = data_ptr;
-
-	regulator_disable(data->vdd_reg);
-}
-
 static void fxls8962af_pm_disable(void *dev_ptr)
 {
 	struct device *dev = dev_ptr;
@@ -1171,20 +1163,10 @@ int fxls8962af_core_probe(struct device *dev, struct regmap *regmap, int irq)
 	if (ret)
 		return ret;
 
-	data->vdd_reg = devm_regulator_get(dev, "vdd");
-	if (IS_ERR(data->vdd_reg))
-		return dev_err_probe(dev, PTR_ERR(data->vdd_reg),
-				     "Failed to get vdd regulator\n");
-
-	ret = regulator_enable(data->vdd_reg);
-	if (ret) {
-		dev_err(dev, "Failed to enable vdd regulator: %d\n", ret);
-		return ret;
-	}
-
-	ret = devm_add_action_or_reset(dev, fxls8962af_regulator_disable, data);
+	ret = devm_regulator_get_enable(dev, "vdd");
 	if (ret)
-		return ret;
+		return dev_err_probe(dev, ret,
+				     "Failed to get vdd regulator\n");
 
 	ret = regmap_read(data->regmap, FXLS8962AF_WHO_AM_I, &reg);
 	if (ret)
-- 
2.37.2


^ permalink raw reply related	[flat|nested] 39+ messages in thread

* [PATCH 04/14] iio: accel: kxcjk-1013: Use devm_regulator_bulk_get_enable()
  2022-10-16 16:33 [PATCH 00/14] IIO: More devm_regulator[_bulk]_get_enable() users Jonathan Cameron
                   ` (2 preceding siblings ...)
  2022-10-16 16:33 ` [PATCH 03/14] iio: accel: fxls8962af: Use devm_regulator_get_enable() Jonathan Cameron
@ 2022-10-16 16:33 ` Jonathan Cameron
  2022-10-17  5:28   ` Matti Vaittinen
  2022-10-16 16:34 ` [PATCH 05/14] iio: accel: msa311: Use devm_regulator_get_enable() Jonathan Cameron
                   ` (10 subsequent siblings)
  14 siblings, 1 reply; 39+ messages in thread
From: Jonathan Cameron @ 2022-10-16 16:33 UTC (permalink / raw)
  To: linux-iio
  Cc: Matti Vaittinen, Matti Vaittinen, Cosmin Tanislav, Jagath Jog J,
	Sean Nyekjaer, Dmitry Rokosov, Linus Walleij, Andy Shevchenko,
	Michael Hennerich, Lorenzo Bianconi, Martyn Welch,
	Gwendal Grignou, Stephen Boyd, Tomasz Duszynski,
	Jonathan Cameron

From: Jonathan Cameron <Jonathan.Cameron@huawei.com>

This driver only turns the power on at probe and off via a custom
devm_add_action_or_reset() callback. The new
devm_regulator_bulk_get_enable() replaces this boilerplate code.

Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
---
 drivers/iio/accel/kxcjk-1013.c | 25 ++++---------------------
 1 file changed, 4 insertions(+), 21 deletions(-)

diff --git a/drivers/iio/accel/kxcjk-1013.c b/drivers/iio/accel/kxcjk-1013.c
index adc66b3615c0..e626b6fa8a36 100644
--- a/drivers/iio/accel/kxcjk-1013.c
+++ b/drivers/iio/accel/kxcjk-1013.c
@@ -241,7 +241,6 @@ enum kxcjk1013_axis {
 };
 
 struct kxcjk1013_data {
-	struct regulator_bulk_data regulators[2];
 	struct i2c_client *client;
 	struct iio_trigger *dready_trig;
 	struct iio_trigger *motion_trig;
@@ -1425,16 +1424,10 @@ static const char *kxcjk1013_match_acpi_device(struct device *dev,
 	return dev_name(dev);
 }
 
-static void kxcjk1013_disable_regulators(void *d)
-{
-	struct kxcjk1013_data *data = d;
-
-	regulator_bulk_disable(ARRAY_SIZE(data->regulators), data->regulators);
-}
-
 static int kxcjk1013_probe(struct i2c_client *client,
 			   const struct i2c_device_id *id)
 {
+	static const char * const regulator_names[] = { "vdd", "vddio" };
 	struct kxcjk1013_data *data;
 	struct iio_dev *indio_dev;
 	struct kxcjk_1013_platform_data *pdata;
@@ -1461,22 +1454,12 @@ static int kxcjk1013_probe(struct i2c_client *client,
 			return ret;
 	}
 
-	data->regulators[0].supply = "vdd";
-	data->regulators[1].supply = "vddio";
-	ret = devm_regulator_bulk_get(&client->dev, ARRAY_SIZE(data->regulators),
-				      data->regulators);
+	ret = devm_regulator_bulk_get_enable(&client->dev,
+					     ARRAY_SIZE(regulator_names),
+					     regulator_names);
 	if (ret)
 		return dev_err_probe(&client->dev, ret, "Failed to get regulators\n");
 
-	ret = regulator_bulk_enable(ARRAY_SIZE(data->regulators),
-				    data->regulators);
-	if (ret)
-		return ret;
-
-	ret = devm_add_action_or_reset(&client->dev, kxcjk1013_disable_regulators, data);
-	if (ret)
-		return ret;
-
 	/*
 	 * A typical delay of 10ms is required for powering up
 	 * according to the data sheets of supported chips.
-- 
2.37.2


^ permalink raw reply related	[flat|nested] 39+ messages in thread

* [PATCH 05/14] iio: accel: msa311: Use devm_regulator_get_enable()
  2022-10-16 16:33 [PATCH 00/14] IIO: More devm_regulator[_bulk]_get_enable() users Jonathan Cameron
                   ` (3 preceding siblings ...)
  2022-10-16 16:33 ` [PATCH 04/14] iio: accel: kxcjk-1013: Use devm_regulator_bulk_get_enable() Jonathan Cameron
@ 2022-10-16 16:34 ` Jonathan Cameron
  2022-10-18 15:14   ` Dmitry Rokosov
  2022-10-16 16:34 ` [PATCH 06/14] iio: cdc: ad7150: " Jonathan Cameron
                   ` (9 subsequent siblings)
  14 siblings, 1 reply; 39+ messages in thread
From: Jonathan Cameron @ 2022-10-16 16:34 UTC (permalink / raw)
  To: linux-iio
  Cc: Matti Vaittinen, Matti Vaittinen, Cosmin Tanislav, Jagath Jog J,
	Sean Nyekjaer, Dmitry Rokosov, Linus Walleij, Andy Shevchenko,
	Michael Hennerich, Lorenzo Bianconi, Martyn Welch,
	Gwendal Grignou, Stephen Boyd, Tomasz Duszynski,
	Jonathan Cameron

From: Jonathan Cameron <Jonathan.Cameron@huawei.com>

This driver only turns the power on at probe and off via a custom
devm_add_action_or_reset() callback. The new devm_regulator_get_enable()
replaces this boilerplate code.

Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Cc: Dmitry Rokosov <DDRokosov@sberdevices.ru>
---
 drivers/iio/accel/msa311.c | 21 ++-------------------
 1 file changed, 2 insertions(+), 19 deletions(-)

diff --git a/drivers/iio/accel/msa311.c b/drivers/iio/accel/msa311.c
index 2fded3759171..af94d3adf6d8 100644
--- a/drivers/iio/accel/msa311.c
+++ b/drivers/iio/accel/msa311.c
@@ -351,7 +351,6 @@ static const struct regmap_config msa311_regmap_config = {
  * @chip_name: Chip name in the format "msa311-%02x" % partid
  * @new_data_trig: Optional NEW_DATA interrupt driven trigger used
  *                 to notify external consumers a new sample is ready
- * @vdd: Optional external voltage regulator for the device power supply
  */
 struct msa311_priv {
 	struct regmap *regs;
@@ -362,7 +361,6 @@ struct msa311_priv {
 	char *chip_name;
 
 	struct iio_trigger *new_data_trig;
-	struct regulator *vdd;
 };
 
 enum msa311_si {
@@ -1146,11 +1144,6 @@ static void msa311_powerdown(void *msa311)
 	msa311_set_pwr_mode(msa311, MSA311_PWR_MODE_SUSPEND);
 }
 
-static void msa311_vdd_disable(void *vdd)
-{
-	regulator_disable(vdd);
-}
-
 static int msa311_probe(struct i2c_client *i2c)
 {
 	struct device *dev = &i2c->dev;
@@ -1173,19 +1166,9 @@ static int msa311_probe(struct i2c_client *i2c)
 
 	mutex_init(&msa311->lock);
 
-	msa311->vdd = devm_regulator_get(dev, "vdd");
-	if (IS_ERR(msa311->vdd))
-		return dev_err_probe(dev, PTR_ERR(msa311->vdd),
-				     "can't get vdd supply\n");
-
-	err = regulator_enable(msa311->vdd);
+	err = devm_regulator_get_enable(dev, "vdd");
 	if (err)
-		return dev_err_probe(dev, err, "can't enable vdd supply\n");
-
-	err = devm_add_action_or_reset(dev, msa311_vdd_disable, msa311->vdd);
-	if (err)
-		return dev_err_probe(dev, err,
-				     "can't add vdd disable action\n");
+		return dev_err_probe(dev, err, "can't get vdd supply\n");
 
 	err = msa311_check_partid(msa311);
 	if (err)
-- 
2.37.2


^ permalink raw reply related	[flat|nested] 39+ messages in thread

* [PATCH 06/14] iio: cdc: ad7150: Use devm_regulator_get_enable()
  2022-10-16 16:33 [PATCH 00/14] IIO: More devm_regulator[_bulk]_get_enable() users Jonathan Cameron
                   ` (4 preceding siblings ...)
  2022-10-16 16:34 ` [PATCH 05/14] iio: accel: msa311: Use devm_regulator_get_enable() Jonathan Cameron
@ 2022-10-16 16:34 ` Jonathan Cameron
  2022-10-17  5:27   ` Matti Vaittinen
  2022-10-16 16:34 ` [PATCH 07/14] iio: st_sensors: core and lsm9ds0 switch to devm_regulator_bulk_get_enable() Jonathan Cameron
                   ` (8 subsequent siblings)
  14 siblings, 1 reply; 39+ messages in thread
From: Jonathan Cameron @ 2022-10-16 16:34 UTC (permalink / raw)
  To: linux-iio
  Cc: Matti Vaittinen, Matti Vaittinen, Cosmin Tanislav, Jagath Jog J,
	Sean Nyekjaer, Dmitry Rokosov, Linus Walleij, Andy Shevchenko,
	Michael Hennerich, Lorenzo Bianconi, Martyn Welch,
	Gwendal Grignou, Stephen Boyd, Tomasz Duszynski,
	Jonathan Cameron

From: Jonathan Cameron <Jonathan.Cameron@huawei.com>

This driver only turns the power on at probe and off via a custom
devm_add_action_or_reset() callback. The new devm_regulator_get_enable()
replaces this boilerplate code.

Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
---
 drivers/iio/cdc/ad7150.c | 18 +-----------------
 1 file changed, 1 insertion(+), 17 deletions(-)

diff --git a/drivers/iio/cdc/ad7150.c b/drivers/iio/cdc/ad7150.c
index ebe112b4618b..1113745890ca 100644
--- a/drivers/iio/cdc/ad7150.c
+++ b/drivers/iio/cdc/ad7150.c
@@ -536,19 +536,11 @@ static const struct iio_info ad7150_info_no_irq = {
 	.read_raw = &ad7150_read_raw,
 };
 
-static void ad7150_reg_disable(void *data)
-{
-	struct regulator *reg = data;
-
-	regulator_disable(reg);
-}
-
 static int ad7150_probe(struct i2c_client *client,
 			const struct i2c_device_id *id)
 {
 	struct ad7150_chip_info *chip;
 	struct iio_dev *indio_dev;
-	struct regulator *reg;
 	int ret;
 
 	indio_dev = devm_iio_device_alloc(&client->dev, sizeof(*chip));
@@ -563,15 +555,7 @@ static int ad7150_probe(struct i2c_client *client,
 
 	indio_dev->modes = INDIO_DIRECT_MODE;
 
-	reg = devm_regulator_get(&client->dev, "vdd");
-	if (IS_ERR(reg))
-		return PTR_ERR(reg);
-
-	ret = regulator_enable(reg);
-	if (ret)
-		return ret;
-
-	ret = devm_add_action_or_reset(&client->dev, ad7150_reg_disable, reg);
+	ret = devm_regulator_get_enable(&client->dev, "vdd");
 	if (ret)
 		return ret;
 
-- 
2.37.2


^ permalink raw reply related	[flat|nested] 39+ messages in thread

* [PATCH 07/14] iio: st_sensors: core and lsm9ds0 switch to devm_regulator_bulk_get_enable()
  2022-10-16 16:33 [PATCH 00/14] IIO: More devm_regulator[_bulk]_get_enable() users Jonathan Cameron
                   ` (5 preceding siblings ...)
  2022-10-16 16:34 ` [PATCH 06/14] iio: cdc: ad7150: " Jonathan Cameron
@ 2022-10-16 16:34 ` Jonathan Cameron
  2022-10-17  5:44   ` Matti Vaittinen
  2022-10-16 16:34 ` [PATCH 08/14] iio: frequency: ad9523: Use devm_regulator_get_enable() Jonathan Cameron
                   ` (7 subsequent siblings)
  14 siblings, 1 reply; 39+ messages in thread
From: Jonathan Cameron @ 2022-10-16 16:34 UTC (permalink / raw)
  To: linux-iio
  Cc: Matti Vaittinen, Matti Vaittinen, Cosmin Tanislav, Jagath Jog J,
	Sean Nyekjaer, Dmitry Rokosov, Linus Walleij, Andy Shevchenko,
	Michael Hennerich, Lorenzo Bianconi, Martyn Welch,
	Gwendal Grignou, Stephen Boyd, Tomasz Duszynski,
	Jonathan Cameron

From: Jonathan Cameron <Jonathan.Cameron@huawei.com>

These drivers only turns the power on at probe and off via a custom
devm_add_action_or_reset() callback. The two regulators were handled
separately so also switch to bulk registration.
The new devm_regulator_bulk_get_enable() replaces all this boilerplate
code.

Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Cc: Linus Walleij <linus.walleij@linaro.org>
Cc: Andy Shevchenko <andriy.shevchenko@linux.intel.com>

---

An alternative here would be to also refactor st_sensors_power_enable()
to take the struct dev of the parent device (I2C or SPI).

Then we could use the same function for st_lsm9d0_probe().
My view is it isn't worth the churn.
---
 .../iio/common/st_sensors/st_sensors_core.c   | 39 ++---------
 drivers/iio/imu/st_lsm9ds0/st_lsm9ds0_core.c  | 65 ++-----------------
 include/linux/iio/common/st_sensors.h         |  4 --
 3 files changed, 14 insertions(+), 94 deletions(-)

diff --git a/drivers/iio/common/st_sensors/st_sensors_core.c b/drivers/iio/common/st_sensors/st_sensors_core.c
index 35720c64fea8..c77d7bdcc121 100644
--- a/drivers/iio/common/st_sensors/st_sensors_core.c
+++ b/drivers/iio/common/st_sensors/st_sensors_core.c
@@ -219,47 +219,22 @@ int st_sensors_set_axis_enable(struct iio_dev *indio_dev, u8 axis_enable)
 }
 EXPORT_SYMBOL_NS(st_sensors_set_axis_enable, IIO_ST_SENSORS);
 
-static void st_reg_disable(void *reg)
-{
-	regulator_disable(reg);
-}
 
 int st_sensors_power_enable(struct iio_dev *indio_dev)
 {
-	struct st_sensor_data *pdata = iio_priv(indio_dev);
+	static const char * const regulator_names[] = { "vdd", "vddio" };
 	struct device *parent = indio_dev->dev.parent;
 	int err;
 
 	/* Regulators not mandatory, but if requested we should enable them. */
-	pdata->vdd = devm_regulator_get(parent, "vdd");
-	if (IS_ERR(pdata->vdd))
-		return dev_err_probe(&indio_dev->dev, PTR_ERR(pdata->vdd),
-				     "unable to get Vdd supply\n");
-
-	err = regulator_enable(pdata->vdd);
-	if (err != 0) {
-		dev_warn(&indio_dev->dev,
-			 "Failed to enable specified Vdd supply\n");
-		return err;
-	}
-
-	err = devm_add_action_or_reset(parent, st_reg_disable, pdata->vdd);
+	err = devm_regulator_bulk_get_enable(parent,
+					     ARRAY_SIZE(regulator_names),
+					     regulator_names);
 	if (err)
-		return err;
+		return dev_err_probe(&indio_dev->dev, err,
+				     "unable to enable supplies\n");
 
-	pdata->vdd_io = devm_regulator_get(parent, "vddio");
-	if (IS_ERR(pdata->vdd_io))
-		return dev_err_probe(&indio_dev->dev, PTR_ERR(pdata->vdd_io),
-				     "unable to get Vdd_IO supply\n");
-
-	err = regulator_enable(pdata->vdd_io);
-	if (err != 0) {
-		dev_warn(&indio_dev->dev,
-			 "Failed to enable specified Vdd_IO supply\n");
-		return err;
-	}
-
-	return devm_add_action_or_reset(parent, st_reg_disable, pdata->vdd_io);
+	return 0;
 }
 EXPORT_SYMBOL_NS(st_sensors_power_enable, IIO_ST_SENSORS);
 
diff --git a/drivers/iio/imu/st_lsm9ds0/st_lsm9ds0_core.c b/drivers/iio/imu/st_lsm9ds0/st_lsm9ds0_core.c
index ae7bc815382f..e887b45cdbcd 100644
--- a/drivers/iio/imu/st_lsm9ds0/st_lsm9ds0_core.c
+++ b/drivers/iio/imu/st_lsm9ds0/st_lsm9ds0_core.c
@@ -18,58 +18,6 @@
 
 #include "st_lsm9ds0.h"
 
-static int st_lsm9ds0_power_enable(struct device *dev, struct st_lsm9ds0 *lsm9ds0)
-{
-	int ret;
-
-	/* Regulators not mandatory, but if requested we should enable them. */
-	lsm9ds0->vdd = devm_regulator_get(dev, "vdd");
-	if (IS_ERR(lsm9ds0->vdd))
-		return dev_err_probe(dev, PTR_ERR(lsm9ds0->vdd),
-				     "unable to get Vdd supply\n");
-
-	ret = regulator_enable(lsm9ds0->vdd);
-	if (ret) {
-		dev_warn(dev, "Failed to enable specified Vdd supply\n");
-		return ret;
-	}
-
-	lsm9ds0->vdd_io = devm_regulator_get(dev, "vddio");
-	if (IS_ERR(lsm9ds0->vdd_io)) {
-		regulator_disable(lsm9ds0->vdd);
-		return dev_err_probe(dev, PTR_ERR(lsm9ds0->vdd_io),
-				     "unable to get Vdd_IO supply\n");
-	}
-	ret = regulator_enable(lsm9ds0->vdd_io);
-	if (ret) {
-		dev_warn(dev, "Failed to enable specified Vdd_IO supply\n");
-		regulator_disable(lsm9ds0->vdd);
-		return ret;
-	}
-
-	return 0;
-}
-
-static void st_lsm9ds0_power_disable(void *data)
-{
-	struct st_lsm9ds0 *lsm9ds0 = data;
-
-	regulator_disable(lsm9ds0->vdd_io);
-	regulator_disable(lsm9ds0->vdd);
-}
-
-static int devm_st_lsm9ds0_power_enable(struct st_lsm9ds0 *lsm9ds0)
-{
-	struct device *dev = lsm9ds0->dev;
-	int ret;
-
-	ret = st_lsm9ds0_power_enable(dev, lsm9ds0);
-	if (ret)
-		return ret;
-
-	return devm_add_action_or_reset(dev, st_lsm9ds0_power_disable, lsm9ds0);
-}
-
 static int st_lsm9ds0_probe_accel(struct st_lsm9ds0 *lsm9ds0, struct regmap *regmap)
 {
 	const struct st_sensor_settings *settings;
@@ -92,8 +40,6 @@ static int st_lsm9ds0_probe_accel(struct st_lsm9ds0 *lsm9ds0, struct regmap *reg
 	data->sensor_settings = (struct st_sensor_settings *)settings;
 	data->irq = lsm9ds0->irq;
 	data->regmap = regmap;
-	data->vdd = lsm9ds0->vdd;
-	data->vdd_io = lsm9ds0->vdd_io;
 
 	return st_accel_common_probe(lsm9ds0->accel);
 }
@@ -120,19 +66,22 @@ static int st_lsm9ds0_probe_magn(struct st_lsm9ds0 *lsm9ds0, struct regmap *regm
 	data->sensor_settings = (struct st_sensor_settings *)settings;
 	data->irq = lsm9ds0->irq;
 	data->regmap = regmap;
-	data->vdd = lsm9ds0->vdd;
-	data->vdd_io = lsm9ds0->vdd_io;
 
 	return st_magn_common_probe(lsm9ds0->magn);
 }
 
 int st_lsm9ds0_probe(struct st_lsm9ds0 *lsm9ds0, struct regmap *regmap)
 {
+	struct device *dev = lsm9ds0->dev;
+	static const char * const regulator_names[] = { "vdd", "vddio" };
 	int ret;
 
-	ret = devm_st_lsm9ds0_power_enable(lsm9ds0);
+	/* Regulators not mandatory, but if requested we should enable them. */
+	ret = devm_regulator_bulk_get_enable(dev, ARRAY_SIZE(regulator_names),
+					     regulator_names);
 	if (ret)
-		return ret;
+		return dev_err_probe(dev, ret,
+				     "unable to enable Vdd supply\n");
 
 	/* Setup accelerometer device */
 	ret = st_lsm9ds0_probe_accel(lsm9ds0, regmap);
diff --git a/include/linux/iio/common/st_sensors.h b/include/linux/iio/common/st_sensors.h
index db4a1b260348..f5f3ee57bc70 100644
--- a/include/linux/iio/common/st_sensors.h
+++ b/include/linux/iio/common/st_sensors.h
@@ -224,8 +224,6 @@ struct st_sensor_settings {
  * @mount_matrix: The mounting matrix of the sensor.
  * @sensor_settings: Pointer to the specific sensor settings in use.
  * @current_fullscale: Maximum range of measure by the sensor.
- * @vdd: Pointer to sensor's Vdd power supply
- * @vdd_io: Pointer to sensor's Vdd-IO power supply
  * @regmap: Pointer to specific sensor regmap configuration.
  * @enabled: Status of the sensor (false->off, true->on).
  * @odr: Output data rate of the sensor [Hz].
@@ -244,8 +242,6 @@ struct st_sensor_data {
 	struct iio_mount_matrix mount_matrix;
 	struct st_sensor_settings *sensor_settings;
 	struct st_sensor_fullscale_avl *current_fullscale;
-	struct regulator *vdd;
-	struct regulator *vdd_io;
 	struct regmap *regmap;
 
 	bool enabled;
-- 
2.37.2


^ permalink raw reply related	[flat|nested] 39+ messages in thread

* [PATCH 08/14] iio: frequency: ad9523: Use devm_regulator_get_enable()
  2022-10-16 16:33 [PATCH 00/14] IIO: More devm_regulator[_bulk]_get_enable() users Jonathan Cameron
                   ` (6 preceding siblings ...)
  2022-10-16 16:34 ` [PATCH 07/14] iio: st_sensors: core and lsm9ds0 switch to devm_regulator_bulk_get_enable() Jonathan Cameron
@ 2022-10-16 16:34 ` Jonathan Cameron
  2022-10-17  5:48   ` Matti Vaittinen
  2022-10-16 16:34 ` [PATCH 09/14] iio: humidity: hts211: " Jonathan Cameron
                   ` (6 subsequent siblings)
  14 siblings, 1 reply; 39+ messages in thread
From: Jonathan Cameron @ 2022-10-16 16:34 UTC (permalink / raw)
  To: linux-iio
  Cc: Matti Vaittinen, Matti Vaittinen, Cosmin Tanislav, Jagath Jog J,
	Sean Nyekjaer, Dmitry Rokosov, Linus Walleij, Andy Shevchenko,
	Michael Hennerich, Lorenzo Bianconi, Martyn Welch,
	Gwendal Grignou, Stephen Boyd, Tomasz Duszynski,
	Jonathan Cameron

From: Jonathan Cameron <Jonathan.Cameron@huawei.com>

This driver only turns the power on at probe and off via a custom
devm_add_action_or_reset() callback. The new devm_regulator_get_enable()
replaces this boilerplate code.

Note that in event of an error on the devm_regulator_get() the driver
would have continued without enabling the regulator which is probably
not a good idea.  So here we handle any error as a reason to fail the
probe(). In theory this may expose breakage on a platform that was
previously papered over but it seems low risk.

Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Cc: Michael Hennerich <michael.hennerich@analog.com>
---
 drivers/iio/frequency/ad9523.c | 22 +++-------------------
 1 file changed, 3 insertions(+), 19 deletions(-)

diff --git a/drivers/iio/frequency/ad9523.c b/drivers/iio/frequency/ad9523.c
index 97662ca1ca96..b391c6e27ab0 100644
--- a/drivers/iio/frequency/ad9523.c
+++ b/drivers/iio/frequency/ad9523.c
@@ -265,7 +265,6 @@ enum {
 
 struct ad9523_state {
 	struct spi_device		*spi;
-	struct regulator		*reg;
 	struct ad9523_platform_data	*pdata;
 	struct iio_chan_spec		ad9523_channels[AD9523_NUM_CHAN];
 	struct gpio_desc		*pwrdown_gpio;
@@ -969,13 +968,6 @@ static int ad9523_setup(struct iio_dev *indio_dev)
 	return 0;
 }
 
-static void ad9523_reg_disable(void *data)
-{
-	struct regulator *reg = data;
-
-	regulator_disable(reg);
-}
-
 static int ad9523_probe(struct spi_device *spi)
 {
 	struct ad9523_platform_data *pdata = spi->dev.platform_data;
@@ -996,17 +988,9 @@ static int ad9523_probe(struct spi_device *spi)
 
 	mutex_init(&st->lock);
 
-	st->reg = devm_regulator_get(&spi->dev, "vcc");
-	if (!IS_ERR(st->reg)) {
-		ret = regulator_enable(st->reg);
-		if (ret)
-			return ret;
-
-		ret = devm_add_action_or_reset(&spi->dev, ad9523_reg_disable,
-					       st->reg);
-		if (ret)
-			return ret;
-	}
+	ret = devm_regulator_get_enable(&spi->dev, "vcc");
+	if (ret)
+		return ret;
 
 	st->pwrdown_gpio = devm_gpiod_get_optional(&spi->dev, "powerdown",
 		GPIOD_OUT_HIGH);
-- 
2.37.2


^ permalink raw reply related	[flat|nested] 39+ messages in thread

* [PATCH 09/14] iio: humidity: hts211: Use devm_regulator_get_enable()
  2022-10-16 16:33 [PATCH 00/14] IIO: More devm_regulator[_bulk]_get_enable() users Jonathan Cameron
                   ` (7 preceding siblings ...)
  2022-10-16 16:34 ` [PATCH 08/14] iio: frequency: ad9523: Use devm_regulator_get_enable() Jonathan Cameron
@ 2022-10-16 16:34 ` Jonathan Cameron
  2022-10-17  5:53   ` Matti Vaittinen
  2022-10-17  7:11   ` Lorenzo Bianconi
  2022-10-16 16:34 ` [PATCH 10/14] iio: light: ltr501: Use devm_regulator_bulk_get_enable() Jonathan Cameron
                   ` (5 subsequent siblings)
  14 siblings, 2 replies; 39+ messages in thread
From: Jonathan Cameron @ 2022-10-16 16:34 UTC (permalink / raw)
  To: linux-iio
  Cc: Matti Vaittinen, Matti Vaittinen, Cosmin Tanislav, Jagath Jog J,
	Sean Nyekjaer, Dmitry Rokosov, Linus Walleij, Andy Shevchenko,
	Michael Hennerich, Lorenzo Bianconi, Martyn Welch,
	Gwendal Grignou, Stephen Boyd, Tomasz Duszynski,
	Jonathan Cameron

From: Jonathan Cameron <Jonathan.Cameron@huawei.com>

This driver only turns the power on at probe and off via a custom
devm_add_action_or_reset() callback. The new devm_regulator_get_enable()
replaces this boilerplate code.

Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Cc: Lorenzo Bianconi <lorenzo@kernel.org>
---
 drivers/iio/humidity/hts221.h      |  2 --
 drivers/iio/humidity/hts221_core.c | 27 ++++-----------------------
 2 files changed, 4 insertions(+), 25 deletions(-)

diff --git a/drivers/iio/humidity/hts221.h b/drivers/iio/humidity/hts221.h
index cf3d8d2dccd6..721359e226cb 100644
--- a/drivers/iio/humidity/hts221.h
+++ b/drivers/iio/humidity/hts221.h
@@ -13,7 +13,6 @@
 #define HTS221_DEV_NAME		"hts221"
 
 #include <linux/iio/iio.h>
-#include <linux/regulator/consumer.h>
 
 enum hts221_sensor_type {
 	HTS221_SENSOR_H,
@@ -30,7 +29,6 @@ struct hts221_hw {
 	const char *name;
 	struct device *dev;
 	struct regmap *regmap;
-	struct regulator *vdd;
 
 	struct iio_trigger *trig;
 	int irq;
diff --git a/drivers/iio/humidity/hts221_core.c b/drivers/iio/humidity/hts221_core.c
index 517158307d8c..2a413da87b76 100644
--- a/drivers/iio/humidity/hts221_core.c
+++ b/drivers/iio/humidity/hts221_core.c
@@ -14,6 +14,7 @@
 #include <linux/delay.h>
 #include <linux/pm.h>
 #include <linux/regmap.h>
+#include <linux/regulator/consumer.h>
 #include <linux/bitfield.h>
 
 #include "hts221.h"
@@ -549,33 +550,17 @@ static const unsigned long hts221_scan_masks[] = {0x3, 0x0};
 
 static int hts221_init_regulators(struct device *dev)
 {
-	struct iio_dev *iio_dev = dev_get_drvdata(dev);
-	struct hts221_hw *hw = iio_priv(iio_dev);
 	int err;
 
-	hw->vdd = devm_regulator_get(dev, "vdd");
-	if (IS_ERR(hw->vdd))
-		return dev_err_probe(dev, PTR_ERR(hw->vdd),
-				     "failed to get vdd regulator\n");
-
-	err = regulator_enable(hw->vdd);
-	if (err) {
-		dev_err(dev, "failed to enable vdd regulator: %d\n", err);
-		return err;
-	}
+	err = devm_regulator_get_enable(dev, "vdd");
+	if (err)
+		return dev_err_probe(dev, err, "failed to get vdd regulator\n");
 
 	msleep(50);
 
 	return 0;
 }
 
-static void hts221_chip_uninit(void *data)
-{
-	struct hts221_hw *hw = data;
-
-	regulator_disable(hw->vdd);
-}
-
 int hts221_probe(struct device *dev, int irq, const char *name,
 		 struct regmap *regmap)
 {
@@ -600,10 +585,6 @@ int hts221_probe(struct device *dev, int irq, const char *name,
 	if (err)
 		return err;
 
-	err = devm_add_action_or_reset(dev, hts221_chip_uninit, hw);
-	if (err)
-		return err;
-
 	err = hts221_check_whoami(hw);
 	if (err < 0)
 		return err;
-- 
2.37.2


^ permalink raw reply related	[flat|nested] 39+ messages in thread

* [PATCH 10/14] iio: light: ltr501: Use devm_regulator_bulk_get_enable()
  2022-10-16 16:33 [PATCH 00/14] IIO: More devm_regulator[_bulk]_get_enable() users Jonathan Cameron
                   ` (8 preceding siblings ...)
  2022-10-16 16:34 ` [PATCH 09/14] iio: humidity: hts211: " Jonathan Cameron
@ 2022-10-16 16:34 ` Jonathan Cameron
  2022-10-17  5:56   ` Matti Vaittinen
  2022-10-17  6:03   ` Matti Vaittinen
  2022-10-16 16:34 ` [PATCH 11/14] iio: light: noa1305: Use devm_regulator_get_enable() Jonathan Cameron
                   ` (4 subsequent siblings)
  14 siblings, 2 replies; 39+ messages in thread
From: Jonathan Cameron @ 2022-10-16 16:34 UTC (permalink / raw)
  To: linux-iio
  Cc: Matti Vaittinen, Matti Vaittinen, Cosmin Tanislav, Jagath Jog J,
	Sean Nyekjaer, Dmitry Rokosov, Linus Walleij, Andy Shevchenko,
	Michael Hennerich, Lorenzo Bianconi, Martyn Welch,
	Gwendal Grignou, Stephen Boyd, Tomasz Duszynski,
	Jonathan Cameron

From: Jonathan Cameron <Jonathan.Cameron@huawei.com>

This driver only turns the power for some regulators on at probe and off
via a custom devm_add_action_or_reset() callback. The new
devm_regulator_bulk_get_enable() replaces all this boilerplate code.

Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
---
 drivers/iio/light/ltr501.c | 27 ++++-----------------------
 1 file changed, 4 insertions(+), 23 deletions(-)

diff --git a/drivers/iio/light/ltr501.c b/drivers/iio/light/ltr501.c
index 74a1ccda8b9c..453b845ef265 100644
--- a/drivers/iio/light/ltr501.c
+++ b/drivers/iio/light/ltr501.c
@@ -153,7 +153,6 @@ struct ltr501_chip_info {
 
 struct ltr501_data {
 	struct i2c_client *client;
-	struct regulator_bulk_data regulators[2];
 	struct mutex lock_als, lock_ps;
 	const struct ltr501_chip_info *chip_info;
 	u8 als_contr, ps_contr;
@@ -1415,13 +1414,6 @@ static const struct regmap_config ltr501_regmap_config = {
 	.volatile_reg = ltr501_is_volatile_reg,
 };
 
-static void ltr501_disable_regulators(void *d)
-{
-	struct ltr501_data *data = d;
-
-	regulator_bulk_disable(ARRAY_SIZE(data->regulators), data->regulators);
-}
-
 static int ltr501_powerdown(struct ltr501_data *data)
 {
 	return ltr501_write_contr(data, data->als_contr &
@@ -1443,6 +1435,7 @@ static const char *ltr501_match_acpi_device(struct device *dev, int *chip_idx)
 static int ltr501_probe(struct i2c_client *client,
 			const struct i2c_device_id *id)
 {
+	static const char * const regulator_names[] = { "vdd", "vddio" };
 	struct ltr501_data *data;
 	struct iio_dev *indio_dev;
 	struct regmap *regmap;
@@ -1466,25 +1459,13 @@ static int ltr501_probe(struct i2c_client *client,
 	mutex_init(&data->lock_als);
 	mutex_init(&data->lock_ps);
 
-	data->regulators[0].supply = "vdd";
-	data->regulators[1].supply = "vddio";
-	ret = devm_regulator_bulk_get(&client->dev,
-				      ARRAY_SIZE(data->regulators),
-				      data->regulators);
+	ret = devm_regulator_bulk_get_enable(&client->dev,
+					     ARRAY_SIZE(regulator_names),
+					     regulator_names);
 	if (ret)
 		return dev_err_probe(&client->dev, ret,
 				     "Failed to get regulators\n");
 
-	ret = regulator_bulk_enable(ARRAY_SIZE(data->regulators),
-				    data->regulators);
-	if (ret)
-		return ret;
-
-	ret = devm_add_action_or_reset(&client->dev,
-				       ltr501_disable_regulators, data);
-	if (ret)
-		return ret;
-
 	data->reg_it = devm_regmap_field_alloc(&client->dev, regmap,
 					       reg_field_it);
 	if (IS_ERR(data->reg_it)) {
-- 
2.37.2


^ permalink raw reply related	[flat|nested] 39+ messages in thread

* [PATCH 11/14] iio: light: noa1305: Use devm_regulator_get_enable()
  2022-10-16 16:33 [PATCH 00/14] IIO: More devm_regulator[_bulk]_get_enable() users Jonathan Cameron
                   ` (9 preceding siblings ...)
  2022-10-16 16:34 ` [PATCH 10/14] iio: light: ltr501: Use devm_regulator_bulk_get_enable() Jonathan Cameron
@ 2022-10-16 16:34 ` Jonathan Cameron
  2022-10-17  6:06   ` Matti Vaittinen
  2022-10-16 16:34 ` [PATCH 12/14] iio: proximity: sx_common: Use devm_regulator_bulk_get_enable() Jonathan Cameron
                   ` (3 subsequent siblings)
  14 siblings, 1 reply; 39+ messages in thread
From: Jonathan Cameron @ 2022-10-16 16:34 UTC (permalink / raw)
  To: linux-iio
  Cc: Matti Vaittinen, Matti Vaittinen, Cosmin Tanislav, Jagath Jog J,
	Sean Nyekjaer, Dmitry Rokosov, Linus Walleij, Andy Shevchenko,
	Michael Hennerich, Lorenzo Bianconi, Martyn Welch,
	Gwendal Grignou, Stephen Boyd, Tomasz Duszynski,
	Jonathan Cameron

From: Jonathan Cameron <Jonathan.Cameron@huawei.com>

This driver only turns the power on at probe and off via a custom
devm_add_action_or_reset() callback. The new devm_regulator_get_enable()
replaces this boilerplate code.

Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Cc: Martyn Welch <martyn.welch@collabora.com>
---
 drivers/iio/light/noa1305.c | 26 +++-----------------------
 1 file changed, 3 insertions(+), 23 deletions(-)

diff --git a/drivers/iio/light/noa1305.c b/drivers/iio/light/noa1305.c
index ee81fe083e4c..be3536b390fc 100644
--- a/drivers/iio/light/noa1305.c
+++ b/drivers/iio/light/noa1305.c
@@ -46,7 +46,6 @@
 struct noa1305_priv {
 	struct i2c_client *client;
 	struct regmap *regmap;
-	struct regulator *vin_reg;
 };
 
 static int noa1305_measure(struct noa1305_priv *priv)
@@ -187,13 +186,6 @@ static const struct regmap_config noa1305_regmap_config = {
 	.writeable_reg = noa1305_writable_reg,
 };
 
-static void noa1305_reg_remove(void *data)
-{
-	struct noa1305_priv *priv = data;
-
-	regulator_disable(priv->vin_reg);
-}
-
 static int noa1305_probe(struct i2c_client *client,
 			 const struct i2c_device_id *id)
 {
@@ -216,23 +208,11 @@ static int noa1305_probe(struct i2c_client *client,
 
 	priv = iio_priv(indio_dev);
 
-	priv->vin_reg = devm_regulator_get(&client->dev, "vin");
-	if (IS_ERR(priv->vin_reg))
-		return dev_err_probe(&client->dev, PTR_ERR(priv->vin_reg),
+	ret = devm_regulator_get_enable(&client->dev, "vin");
+	if (ret)
+		return dev_err_probe(&client->dev, ret,
 				     "get regulator vin failed\n");
 
-	ret = regulator_enable(priv->vin_reg);
-	if (ret) {
-		dev_err(&client->dev, "enable regulator vin failed\n");
-		return ret;
-	}
-
-	ret = devm_add_action_or_reset(&client->dev, noa1305_reg_remove, priv);
-	if (ret) {
-		dev_err(&client->dev, "addition of devm action failed\n");
-		return ret;
-	}
-
 	i2c_set_clientdata(client, indio_dev);
 	priv->client = client;
 	priv->regmap = regmap;
-- 
2.37.2


^ permalink raw reply related	[flat|nested] 39+ messages in thread

* [PATCH 12/14] iio: proximity: sx_common: Use devm_regulator_bulk_get_enable()
  2022-10-16 16:33 [PATCH 00/14] IIO: More devm_regulator[_bulk]_get_enable() users Jonathan Cameron
                   ` (10 preceding siblings ...)
  2022-10-16 16:34 ` [PATCH 11/14] iio: light: noa1305: Use devm_regulator_get_enable() Jonathan Cameron
@ 2022-10-16 16:34 ` Jonathan Cameron
  2022-10-17  6:09   ` Matti Vaittinen
  2022-10-18 22:21   ` Stephen Boyd
  2022-10-16 16:34 ` [PATCH 13/14] iio: pressure: ms5611: Use devm_regulator_get_enable() Jonathan Cameron
                   ` (2 subsequent siblings)
  14 siblings, 2 replies; 39+ messages in thread
From: Jonathan Cameron @ 2022-10-16 16:34 UTC (permalink / raw)
  To: linux-iio
  Cc: Matti Vaittinen, Matti Vaittinen, Cosmin Tanislav, Jagath Jog J,
	Sean Nyekjaer, Dmitry Rokosov, Linus Walleij, Andy Shevchenko,
	Michael Hennerich, Lorenzo Bianconi, Martyn Welch,
	Gwendal Grignou, Stephen Boyd, Tomasz Duszynski,
	Jonathan Cameron

From: Jonathan Cameron <Jonathan.Cameron@huawei.com>

This driver only turns the power for some regulators on at probe and off
via a custom devm_add_action_or_reset() callback. The new
devm_regulator_bulk_get_enable() replaces all this boilerplate code.

Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Cc: Gwendal Grignou <gwendal@chromium.org>
Cc: Stephen Boyd <swboyd@chromium.org>
---
 drivers/iio/proximity/sx_common.c | 23 +++--------------------
 drivers/iio/proximity/sx_common.h |  2 --
 2 files changed, 3 insertions(+), 22 deletions(-)

diff --git a/drivers/iio/proximity/sx_common.c b/drivers/iio/proximity/sx_common.c
index d70a6b4f0bf8..eba9256730ec 100644
--- a/drivers/iio/proximity/sx_common.c
+++ b/drivers/iio/proximity/sx_common.c
@@ -424,13 +424,6 @@ static const struct iio_buffer_setup_ops sx_common_buffer_setup_ops = {
 	.postdisable = sx_common_buffer_postdisable,
 };
 
-static void sx_common_regulator_disable(void *_data)
-{
-	struct sx_common_data *data = _data;
-
-	regulator_bulk_disable(ARRAY_SIZE(data->supplies), data->supplies);
-}
-
 #define SX_COMMON_SOFT_RESET				0xde
 
 static int sx_common_init_device(struct device *dev, struct iio_dev *indio_dev)
@@ -474,6 +467,7 @@ int sx_common_probe(struct i2c_client *client,
 		    const struct sx_common_chip_info *chip_info,
 		    const struct regmap_config *regmap_config)
 {
+	static const char * const regulator_names[] = { "vdd", "svdd" };
 	struct device *dev = &client->dev;
 	struct iio_dev *indio_dev;
 	struct sx_common_data *data;
@@ -487,8 +481,6 @@ int sx_common_probe(struct i2c_client *client,
 
 	data->chip_info = chip_info;
 	data->client = client;
-	data->supplies[0].supply = "vdd";
-	data->supplies[1].supply = "svdd";
 	mutex_init(&data->mutex);
 	init_completion(&data->completion);
 
@@ -497,23 +489,14 @@ int sx_common_probe(struct i2c_client *client,
 		return dev_err_probe(dev, PTR_ERR(data->regmap),
 				     "Could init register map\n");
 
-	ret = devm_regulator_bulk_get(dev, ARRAY_SIZE(data->supplies),
-				      data->supplies);
+	ret = devm_regulator_bulk_get_enable(dev, ARRAY_SIZE(regulator_names),
+					     regulator_names);
 	if (ret)
 		return dev_err_probe(dev, ret, "Unable to get regulators\n");
 
-	ret = regulator_bulk_enable(ARRAY_SIZE(data->supplies), data->supplies);
-	if (ret)
-		return dev_err_probe(dev, ret, "Unable to enable regulators\n");
-
 	/* Must wait for Tpor time after initial power up */
 	usleep_range(1000, 1100);
 
-	ret = devm_add_action_or_reset(dev, sx_common_regulator_disable, data);
-	if (ret)
-		return dev_err_probe(dev, ret,
-				     "Unable to register regulators deleter\n");
-
 	ret = data->chip_info->ops.check_whoami(dev, indio_dev);
 	if (ret)
 		return dev_err_probe(dev, ret, "error reading WHOAMI\n");
diff --git a/drivers/iio/proximity/sx_common.h b/drivers/iio/proximity/sx_common.h
index 5d3edeb75f4e..49d4517103b0 100644
--- a/drivers/iio/proximity/sx_common.h
+++ b/drivers/iio/proximity/sx_common.h
@@ -102,7 +102,6 @@ struct sx_common_chip_info {
  * @trig:		IIO trigger object.
  * @regmap:		Register map.
  * @num_default_regs:	Number of default registers to set at init.
- * @supplies:		Power supplies object.
  * @chan_prox_stat:	Last reading of the proximity status for each channel.
  *			We only send an event to user space when this changes.
  * @trigger_enabled:	True when the device trigger is enabled.
@@ -120,7 +119,6 @@ struct sx_common_data {
 	struct iio_trigger *trig;
 	struct regmap *regmap;
 
-	struct regulator_bulk_data supplies[2];
 	unsigned long chan_prox_stat;
 	bool trigger_enabled;
 
-- 
2.37.2


^ permalink raw reply related	[flat|nested] 39+ messages in thread

* [PATCH 13/14] iio: pressure: ms5611: Use devm_regulator_get_enable()
  2022-10-16 16:33 [PATCH 00/14] IIO: More devm_regulator[_bulk]_get_enable() users Jonathan Cameron
                   ` (11 preceding siblings ...)
  2022-10-16 16:34 ` [PATCH 12/14] iio: proximity: sx_common: Use devm_regulator_bulk_get_enable() Jonathan Cameron
@ 2022-10-16 16:34 ` Jonathan Cameron
  2022-10-17  6:26   ` Matti Vaittinen
  2022-10-17  6:26   ` Matti Vaittinen
  2022-10-16 16:34 ` [PATCH 14/14] iio: pressure: ms5611: Switch to fully devm_ managed registration Jonathan Cameron
  2022-10-17 11:27 ` [PATCH 00/14] IIO: More devm_regulator[_bulk]_get_enable() users Sa, Nuno
  14 siblings, 2 replies; 39+ messages in thread
From: Jonathan Cameron @ 2022-10-16 16:34 UTC (permalink / raw)
  To: linux-iio
  Cc: Matti Vaittinen, Matti Vaittinen, Cosmin Tanislav, Jagath Jog J,
	Sean Nyekjaer, Dmitry Rokosov, Linus Walleij, Andy Shevchenko,
	Michael Hennerich, Lorenzo Bianconi, Martyn Welch,
	Gwendal Grignou, Stephen Boyd, Tomasz Duszynski,
	Jonathan Cameron

From: Jonathan Cameron <Jonathan.Cameron@huawei.com>

This driver only turns the power on at probe and off via a custom
devm_add_action_or_reset() callback. The new devm_regulator_get_enable()
replaces this boilerplate code. Some additional refactoring to drop
now unnecessary unwinding after this change.

Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Cc: Tomasz Duszynski <tduszyns@gmail.com>
---
 drivers/iio/pressure/ms5611.h      |  3 ---
 drivers/iio/pressure/ms5611_core.c | 32 +++++-------------------------
 2 files changed, 5 insertions(+), 30 deletions(-)

diff --git a/drivers/iio/pressure/ms5611.h b/drivers/iio/pressure/ms5611.h
index cbc9349c342a..816e83befd23 100644
--- a/drivers/iio/pressure/ms5611.h
+++ b/drivers/iio/pressure/ms5611.h
@@ -13,8 +13,6 @@
 #include <linux/iio/iio.h>
 #include <linux/mutex.h>
 
-struct regulator;
-
 #define MS5611_RESET			0x1e
 #define MS5611_READ_ADC			0x00
 #define MS5611_READ_PROM_WORD		0xA0
@@ -56,7 +54,6 @@ struct ms5611_state {
 					  s32 *temp, s32 *pressure);
 
 	struct ms5611_chip_info *chip_info;
-	struct regulator *vdd;
 };
 
 int ms5611_probe(struct iio_dev *indio_dev, struct device *dev,
diff --git a/drivers/iio/pressure/ms5611_core.c b/drivers/iio/pressure/ms5611_core.c
index 717521de66c4..b95ee6034548 100644
--- a/drivers/iio/pressure/ms5611_core.c
+++ b/drivers/iio/pressure/ms5611_core.c
@@ -390,40 +390,21 @@ static const struct iio_info ms5611_info = {
 static int ms5611_init(struct iio_dev *indio_dev)
 {
 	int ret;
-	struct ms5611_state *st = iio_priv(indio_dev);
 
 	/* Enable attached regulator if any. */
-	st->vdd = devm_regulator_get(indio_dev->dev.parent, "vdd");
-	if (IS_ERR(st->vdd))
-		return PTR_ERR(st->vdd);
-
-	ret = regulator_enable(st->vdd);
-	if (ret) {
-		dev_err(indio_dev->dev.parent,
-			"failed to enable Vdd supply: %d\n", ret);
+	ret = devm_regulator_get_enable(indio_dev->dev.parent, "vdd");
+	if (ret)
 		return ret;
-	}
 
 	ret = ms5611_reset(indio_dev);
 	if (ret < 0)
-		goto err_regulator_disable;
+		return ret;
 
 	ret = ms5611_read_prom(indio_dev);
 	if (ret < 0)
-		goto err_regulator_disable;
+		return ret;
 
 	return 0;
-
-err_regulator_disable:
-	regulator_disable(st->vdd);
-	return ret;
-}
-
-static void ms5611_fini(const struct iio_dev *indio_dev)
-{
-	const struct ms5611_state *st = iio_priv(indio_dev);
-
-	regulator_disable(st->vdd);
 }
 
 int ms5611_probe(struct iio_dev *indio_dev, struct device *dev,
@@ -454,7 +435,7 @@ int ms5611_probe(struct iio_dev *indio_dev, struct device *dev,
 					 ms5611_trigger_handler, NULL);
 	if (ret < 0) {
 		dev_err(dev, "iio triggered buffer setup failed\n");
-		goto err_fini;
+		return ret;
 	}
 
 	ret = iio_device_register(indio_dev);
@@ -467,8 +448,6 @@ int ms5611_probe(struct iio_dev *indio_dev, struct device *dev,
 
 err_buffer_cleanup:
 	iio_triggered_buffer_cleanup(indio_dev);
-err_fini:
-	ms5611_fini(indio_dev);
 	return ret;
 }
 EXPORT_SYMBOL_NS(ms5611_probe, IIO_MS5611);
@@ -477,7 +456,6 @@ void ms5611_remove(struct iio_dev *indio_dev)
 {
 	iio_device_unregister(indio_dev);
 	iio_triggered_buffer_cleanup(indio_dev);
-	ms5611_fini(indio_dev);
 }
 EXPORT_SYMBOL_NS(ms5611_remove, IIO_MS5611);
 
-- 
2.37.2


^ permalink raw reply related	[flat|nested] 39+ messages in thread

* [PATCH 14/14] iio: pressure: ms5611: Switch to fully devm_ managed registration.
  2022-10-16 16:33 [PATCH 00/14] IIO: More devm_regulator[_bulk]_get_enable() users Jonathan Cameron
                   ` (12 preceding siblings ...)
  2022-10-16 16:34 ` [PATCH 13/14] iio: pressure: ms5611: Use devm_regulator_get_enable() Jonathan Cameron
@ 2022-10-16 16:34 ` Jonathan Cameron
  2022-10-17  6:30   ` Matti Vaittinen
  2022-10-17 11:27 ` [PATCH 00/14] IIO: More devm_regulator[_bulk]_get_enable() users Sa, Nuno
  14 siblings, 1 reply; 39+ messages in thread
From: Jonathan Cameron @ 2022-10-16 16:34 UTC (permalink / raw)
  To: linux-iio
  Cc: Matti Vaittinen, Matti Vaittinen, Cosmin Tanislav, Jagath Jog J,
	Sean Nyekjaer, Dmitry Rokosov, Linus Walleij, Andy Shevchenko,
	Michael Hennerich, Lorenzo Bianconi, Martyn Welch,
	Gwendal Grignou, Stephen Boyd, Tomasz Duszynski,
	Jonathan Cameron

From: Jonathan Cameron <Jonathan.Cameron@huawei.com>

All the remaining calls in probe() have devm_ equivalents so
switching to those allows the remove() callbacks to be deleted.
No functional change.

Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Cc: Tomasz Duszynski <tduszyns@gmail.com>
---
 drivers/iio/pressure/ms5611.h      |  1 -
 drivers/iio/pressure/ms5611_core.c | 17 +++--------------
 drivers/iio/pressure/ms5611_i2c.c  |  6 ------
 drivers/iio/pressure/ms5611_spi.c  |  6 ------
 4 files changed, 3 insertions(+), 27 deletions(-)

diff --git a/drivers/iio/pressure/ms5611.h b/drivers/iio/pressure/ms5611.h
index 816e83befd23..f7066315fde3 100644
--- a/drivers/iio/pressure/ms5611.h
+++ b/drivers/iio/pressure/ms5611.h
@@ -58,6 +58,5 @@ struct ms5611_state {
 
 int ms5611_probe(struct iio_dev *indio_dev, struct device *dev,
 		 const char *name, int type);
-void ms5611_remove(struct iio_dev *indio_dev);
 
 #endif /* _MS5611_H */
diff --git a/drivers/iio/pressure/ms5611_core.c b/drivers/iio/pressure/ms5611_core.c
index b95ee6034548..75a98470dcea 100644
--- a/drivers/iio/pressure/ms5611_core.c
+++ b/drivers/iio/pressure/ms5611_core.c
@@ -431,34 +431,23 @@ int ms5611_probe(struct iio_dev *indio_dev, struct device *dev,
 	if (ret < 0)
 		return ret;
 
-	ret = iio_triggered_buffer_setup(indio_dev, NULL,
+	ret = devm_iio_triggered_buffer_setup(dev, indio_dev, NULL,
 					 ms5611_trigger_handler, NULL);
 	if (ret < 0) {
 		dev_err(dev, "iio triggered buffer setup failed\n");
 		return ret;
 	}
 
-	ret = iio_device_register(indio_dev);
+	ret = devm_iio_device_register(dev, indio_dev);
 	if (ret < 0) {
 		dev_err(dev, "unable to register iio device\n");
-		goto err_buffer_cleanup;
+		return ret;
 	}
 
 	return 0;
-
-err_buffer_cleanup:
-	iio_triggered_buffer_cleanup(indio_dev);
-	return ret;
 }
 EXPORT_SYMBOL_NS(ms5611_probe, IIO_MS5611);
 
-void ms5611_remove(struct iio_dev *indio_dev)
-{
-	iio_device_unregister(indio_dev);
-	iio_triggered_buffer_cleanup(indio_dev);
-}
-EXPORT_SYMBOL_NS(ms5611_remove, IIO_MS5611);
-
 MODULE_AUTHOR("Tomasz Duszynski <tduszyns@gmail.com>");
 MODULE_DESCRIPTION("MS5611 core driver");
 MODULE_LICENSE("GPL v2");
diff --git a/drivers/iio/pressure/ms5611_i2c.c b/drivers/iio/pressure/ms5611_i2c.c
index b681a4183909..2bab509a8c1d 100644
--- a/drivers/iio/pressure/ms5611_i2c.c
+++ b/drivers/iio/pressure/ms5611_i2c.c
@@ -105,11 +105,6 @@ static int ms5611_i2c_probe(struct i2c_client *client,
 	return ms5611_probe(indio_dev, &client->dev, id->name, id->driver_data);
 }
 
-static void ms5611_i2c_remove(struct i2c_client *client)
-{
-	ms5611_remove(i2c_get_clientdata(client));
-}
-
 static const struct of_device_id ms5611_i2c_matches[] = {
 	{ .compatible = "meas,ms5611" },
 	{ .compatible = "meas,ms5607" },
@@ -131,7 +126,6 @@ static struct i2c_driver ms5611_driver = {
 	},
 	.id_table = ms5611_id,
 	.probe = ms5611_i2c_probe,
-	.remove = ms5611_i2c_remove,
 };
 module_i2c_driver(ms5611_driver);
 
diff --git a/drivers/iio/pressure/ms5611_spi.c b/drivers/iio/pressure/ms5611_spi.c
index 432e912096f4..f0f5b46d8f9c 100644
--- a/drivers/iio/pressure/ms5611_spi.c
+++ b/drivers/iio/pressure/ms5611_spi.c
@@ -107,11 +107,6 @@ static int ms5611_spi_probe(struct spi_device *spi)
 			    spi_get_device_id(spi)->driver_data);
 }
 
-static void ms5611_spi_remove(struct spi_device *spi)
-{
-	ms5611_remove(spi_get_drvdata(spi));
-}
-
 static const struct of_device_id ms5611_spi_matches[] = {
 	{ .compatible = "meas,ms5611" },
 	{ .compatible = "meas,ms5607" },
@@ -133,7 +128,6 @@ static struct spi_driver ms5611_driver = {
 	},
 	.id_table = ms5611_id,
 	.probe = ms5611_spi_probe,
-	.remove = ms5611_spi_remove,
 };
 module_spi_driver(ms5611_driver);
 
-- 
2.37.2


^ permalink raw reply related	[flat|nested] 39+ messages in thread

* Re: [PATCH 01/14] iio: accel: adxl367: Use devm_regulator_bulk_get_enable()
  2022-10-16 16:33 ` [PATCH 01/14] iio: accel: adxl367: Use devm_regulator_bulk_get_enable() Jonathan Cameron
@ 2022-10-17  5:26   ` Matti Vaittinen
  0 siblings, 0 replies; 39+ messages in thread
From: Matti Vaittinen @ 2022-10-17  5:26 UTC (permalink / raw)
  To: Jonathan Cameron, linux-iio
  Cc: Matti Vaittinen, Cosmin Tanislav, Jagath Jog J, Sean Nyekjaer,
	Dmitry Rokosov, Linus Walleij, Andy Shevchenko,
	Michael Hennerich, Lorenzo Bianconi, Martyn Welch,
	Gwendal Grignou, Stephen Boyd, Tomasz Duszynski,
	Jonathan Cameron


[-- Attachment #1.1.1: Type: text/plain, Size: 627 bytes --]

On 10/16/22 19:33, Jonathan Cameron wrote:
> From: Jonathan Cameron <Jonathan.Cameron@huawei.com>
> 
> This driver only turns the power on at probe and off via a custom
> devm_add_action_or_reset() callback. The new
> devm_regulator_bulk_get_enable() replaces this boilerplate code.
> 
> Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
> Cc: Cosmin Tanislav <cosmin.tanislav@analog.com>

Reviewed-by: Matti Vaittinen <mazziesaccount@gmail.com>

-- 
Matti Vaittinen
Linux kernel developer at ROHM Semiconductors
Oulu Finland

~~ When things go utterly wrong vim users can always type :help! ~~


[-- Attachment #1.1.2: OpenPGP public key --]
[-- Type: application/pgp-keys, Size: 5335 bytes --]

[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 495 bytes --]

^ permalink raw reply	[flat|nested] 39+ messages in thread

* Re: [PATCH 06/14] iio: cdc: ad7150: Use devm_regulator_get_enable()
  2022-10-16 16:34 ` [PATCH 06/14] iio: cdc: ad7150: " Jonathan Cameron
@ 2022-10-17  5:27   ` Matti Vaittinen
  0 siblings, 0 replies; 39+ messages in thread
From: Matti Vaittinen @ 2022-10-17  5:27 UTC (permalink / raw)
  To: Jonathan Cameron, linux-iio
  Cc: Matti Vaittinen, Cosmin Tanislav, Jagath Jog J, Sean Nyekjaer,
	Dmitry Rokosov, Linus Walleij, Andy Shevchenko,
	Michael Hennerich, Lorenzo Bianconi, Martyn Welch,
	Gwendal Grignou, Stephen Boyd, Tomasz Duszynski,
	Jonathan Cameron


[-- Attachment #1.1.1: Type: text/plain, Size: 570 bytes --]

On 10/16/22 19:34, Jonathan Cameron wrote:
> From: Jonathan Cameron <Jonathan.Cameron@huawei.com>
> 
> This driver only turns the power on at probe and off via a custom
> devm_add_action_or_reset() callback. The new devm_regulator_get_enable()
> replaces this boilerplate code.
> 
> Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>

Reviewed-by: Matti Vaittinen <mazziesaccount@gmail.com>

-- 
Matti Vaittinen
Linux kernel developer at ROHM Semiconductors
Oulu Finland

~~ When things go utterly wrong vim users can always type :help! ~~


[-- Attachment #1.1.2: OpenPGP public key --]
[-- Type: application/pgp-keys, Size: 5335 bytes --]

[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 495 bytes --]

^ permalink raw reply	[flat|nested] 39+ messages in thread

* Re: [PATCH 02/14] iio: accel: bma400: Use devm_regulator_bulk_get_enable()
  2022-10-16 16:33 ` [PATCH 02/14] iio: accel: bma400: " Jonathan Cameron
@ 2022-10-17  5:27   ` Matti Vaittinen
  2022-12-04 18:15     ` Jonathan Cameron
  0 siblings, 1 reply; 39+ messages in thread
From: Matti Vaittinen @ 2022-10-17  5:27 UTC (permalink / raw)
  To: Jonathan Cameron, linux-iio
  Cc: Matti Vaittinen, Cosmin Tanislav, Jagath Jog J, Sean Nyekjaer,
	Dmitry Rokosov, Linus Walleij, Andy Shevchenko,
	Michael Hennerich, Lorenzo Bianconi, Martyn Welch,
	Gwendal Grignou, Stephen Boyd, Tomasz Duszynski,
	Jonathan Cameron


[-- Attachment #1.1.1: Type: text/plain, Size: 621 bytes --]

On 10/16/22 19:33, Jonathan Cameron wrote:
> From: Jonathan Cameron <Jonathan.Cameron@huawei.com>
> 
> This driver only turns the power on at probe and off via a custom
> devm_add_action_or_reset() callback. The new
> devm_regulator_bulk_get_enable() replaces this boilerplate code.
> 
> Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
> Cc: Jagath Jog J <jagathjog1996@gmail.com>

Reviewed-by: Matti Vaittinen <mazziesaccount@gmail.com>

-- 
Matti Vaittinen
Linux kernel developer at ROHM Semiconductors
Oulu Finland

~~ When things go utterly wrong vim users can always type :help! ~~


[-- Attachment #1.1.2: OpenPGP public key --]
[-- Type: application/pgp-keys, Size: 5335 bytes --]

[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 495 bytes --]

^ permalink raw reply	[flat|nested] 39+ messages in thread

* Re: [PATCH 03/14] iio: accel: fxls8962af: Use devm_regulator_get_enable()
  2022-10-16 16:33 ` [PATCH 03/14] iio: accel: fxls8962af: Use devm_regulator_get_enable() Jonathan Cameron
@ 2022-10-17  5:27   ` Matti Vaittinen
  2022-10-17  9:23   ` Sean Nyekjaer
  1 sibling, 0 replies; 39+ messages in thread
From: Matti Vaittinen @ 2022-10-17  5:27 UTC (permalink / raw)
  To: Jonathan Cameron, linux-iio
  Cc: Matti Vaittinen, Cosmin Tanislav, Jagath Jog J, Sean Nyekjaer,
	Dmitry Rokosov, Linus Walleij, Andy Shevchenko,
	Michael Hennerich, Lorenzo Bianconi, Martyn Welch,
	Gwendal Grignou, Stephen Boyd, Tomasz Duszynski,
	Jonathan Cameron


[-- Attachment #1.1.1: Type: text/plain, Size: 609 bytes --]

On 10/16/22 19:33, Jonathan Cameron wrote:
> From: Jonathan Cameron <Jonathan.Cameron@huawei.com>
> 
> This driver only turns the power on at probe and off via a custom
> devm_add_action_or_reset() callback. The new devm_regulator_get_enable()
> replaces this boilerplate code.
> 
> Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
> Cc: Sean Nyekjaer <sean@geanix.com>

Reviewed-by: Matti Vaittinen <mazziesaccount@gmail.com>

-- 
Matti Vaittinen
Linux kernel developer at ROHM Semiconductors
Oulu Finland

~~ When things go utterly wrong vim users can always type :help! ~~


[-- Attachment #1.1.2: OpenPGP public key --]
[-- Type: application/pgp-keys, Size: 5335 bytes --]

[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 495 bytes --]

^ permalink raw reply	[flat|nested] 39+ messages in thread

* Re: [PATCH 04/14] iio: accel: kxcjk-1013: Use devm_regulator_bulk_get_enable()
  2022-10-16 16:33 ` [PATCH 04/14] iio: accel: kxcjk-1013: Use devm_regulator_bulk_get_enable() Jonathan Cameron
@ 2022-10-17  5:28   ` Matti Vaittinen
  0 siblings, 0 replies; 39+ messages in thread
From: Matti Vaittinen @ 2022-10-17  5:28 UTC (permalink / raw)
  To: Jonathan Cameron, linux-iio
  Cc: Matti Vaittinen, Cosmin Tanislav, Jagath Jog J, Sean Nyekjaer,
	Dmitry Rokosov, Linus Walleij, Andy Shevchenko,
	Michael Hennerich, Lorenzo Bianconi, Martyn Welch,
	Gwendal Grignou, Stephen Boyd, Tomasz Duszynski,
	Jonathan Cameron


[-- Attachment #1.1.1: Type: text/plain, Size: 575 bytes --]

On 10/16/22 19:33, Jonathan Cameron wrote:
> From: Jonathan Cameron <Jonathan.Cameron@huawei.com>
> 
> This driver only turns the power on at probe and off via a custom
> devm_add_action_or_reset() callback. The new
> devm_regulator_bulk_get_enable() replaces this boilerplate code.
> 
> Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>

Reviewed-by: Matti Vaittinen <mazziesaccount@gmail.com>

-- 
Matti Vaittinen
Linux kernel developer at ROHM Semiconductors
Oulu Finland

~~ When things go utterly wrong vim users can always type :help! ~~


[-- Attachment #1.1.2: OpenPGP public key --]
[-- Type: application/pgp-keys, Size: 5335 bytes --]

[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 495 bytes --]

^ permalink raw reply	[flat|nested] 39+ messages in thread

* Re: [PATCH 07/14] iio: st_sensors: core and lsm9ds0 switch to devm_regulator_bulk_get_enable()
  2022-10-16 16:34 ` [PATCH 07/14] iio: st_sensors: core and lsm9ds0 switch to devm_regulator_bulk_get_enable() Jonathan Cameron
@ 2022-10-17  5:44   ` Matti Vaittinen
  0 siblings, 0 replies; 39+ messages in thread
From: Matti Vaittinen @ 2022-10-17  5:44 UTC (permalink / raw)
  To: Jonathan Cameron, linux-iio
  Cc: Matti Vaittinen, Cosmin Tanislav, Jagath Jog J, Sean Nyekjaer,
	Dmitry Rokosov, Linus Walleij, Andy Shevchenko,
	Michael Hennerich, Lorenzo Bianconi, Martyn Welch,
	Gwendal Grignou, Stephen Boyd, Tomasz Duszynski,
	Jonathan Cameron

On 10/16/22 19:34, Jonathan Cameron wrote:
> From: Jonathan Cameron <Jonathan.Cameron@huawei.com>
> 
> These drivers only turns the power on at probe and off via a custom
> devm_add_action_or_reset() callback. The two regulators were handled
> separately so also switch to bulk registration.
> The new devm_regulator_bulk_get_enable() replaces all this boilerplate
> code.
> 
> Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
> Cc: Linus Walleij <linus.walleij@linaro.org>
> Cc: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
> 
> ---

I like this change. Especially since the st_sensors_power_enable() is 
exported. Looks much safer (to me) now.

Reviewed-by: Matti Vaittinen <mazziesaccount@gmail.com>

-- 
Matti Vaittinen
Linux kernel developer at ROHM Semiconductors
Oulu Finland

~~ When things go utterly wrong vim users can always type :help! ~~


^ permalink raw reply	[flat|nested] 39+ messages in thread

* Re: [PATCH 08/14] iio: frequency: ad9523: Use devm_regulator_get_enable()
  2022-10-16 16:34 ` [PATCH 08/14] iio: frequency: ad9523: Use devm_regulator_get_enable() Jonathan Cameron
@ 2022-10-17  5:48   ` Matti Vaittinen
  0 siblings, 0 replies; 39+ messages in thread
From: Matti Vaittinen @ 2022-10-17  5:48 UTC (permalink / raw)
  To: Jonathan Cameron, linux-iio
  Cc: Matti Vaittinen, Cosmin Tanislav, Jagath Jog J, Sean Nyekjaer,
	Dmitry Rokosov, Linus Walleij, Andy Shevchenko,
	Michael Hennerich, Lorenzo Bianconi, Martyn Welch,
	Gwendal Grignou, Stephen Boyd, Tomasz Duszynski,
	Jonathan Cameron

On 10/16/22 19:34, Jonathan Cameron wrote:
> From: Jonathan Cameron <Jonathan.Cameron@huawei.com>
> 
> This driver only turns the power on at probe and off via a custom
> devm_add_action_or_reset() callback. The new devm_regulator_get_enable()
> replaces this boilerplate code.
> 
> Note that in event of an error on the devm_regulator_get() the driver
> would have continued without enabling the regulator which is probably
> not a good idea.  So here we handle any error as a reason to fail the
> probe(). In theory this may expose breakage on a platform that was
> previously papered over but it seems low risk.
> 
> Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
> Cc: Michael Hennerich <michael.hennerich@analog.com>

Reviewed-by: Matti Vaittinen <mazziesaccount@gmail.com>

> ---
>   drivers/iio/frequency/ad9523.c | 22 +++-------------------
>   1 file changed, 3 insertions(+), 19 deletions(-)

-- 
Matti Vaittinen
Linux kernel developer at ROHM Semiconductors
Oulu Finland

~~ When things go utterly wrong vim users can always type :help! ~~


^ permalink raw reply	[flat|nested] 39+ messages in thread

* Re: [PATCH 09/14] iio: humidity: hts211: Use devm_regulator_get_enable()
  2022-10-16 16:34 ` [PATCH 09/14] iio: humidity: hts211: " Jonathan Cameron
@ 2022-10-17  5:53   ` Matti Vaittinen
  2022-10-17  7:11   ` Lorenzo Bianconi
  1 sibling, 0 replies; 39+ messages in thread
From: Matti Vaittinen @ 2022-10-17  5:53 UTC (permalink / raw)
  To: Jonathan Cameron, linux-iio
  Cc: Matti Vaittinen, Cosmin Tanislav, Jagath Jog J, Sean Nyekjaer,
	Dmitry Rokosov, Linus Walleij, Andy Shevchenko,
	Michael Hennerich, Lorenzo Bianconi, Martyn Welch,
	Gwendal Grignou, Stephen Boyd, Tomasz Duszynski,
	Jonathan Cameron

On 10/16/22 19:34, Jonathan Cameron wrote:
> From: Jonathan Cameron <Jonathan.Cameron@huawei.com>
> 
> This driver only turns the power on at probe and off via a custom
> devm_add_action_or_reset() callback. The new devm_regulator_get_enable()
> replaces this boilerplate code.
> 
> Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
> Cc: Lorenzo Bianconi <lorenzo@kernel.org>

Reviewed-by: Matti Vaittinen <mazziesaccount@gmail.com>

> ---
>   drivers/iio/humidity/hts221.h      |  2 --
>   drivers/iio/humidity/hts221_core.c | 27 ++++-----------------------
>   2 files changed, 4 insertions(+), 25 deletions(-)
> 
-- 
Matti Vaittinen
Linux kernel developer at ROHM Semiconductors
Oulu Finland

~~ When things go utterly wrong vim users can always type :help! ~~


^ permalink raw reply	[flat|nested] 39+ messages in thread

* Re: [PATCH 10/14] iio: light: ltr501: Use devm_regulator_bulk_get_enable()
  2022-10-16 16:34 ` [PATCH 10/14] iio: light: ltr501: Use devm_regulator_bulk_get_enable() Jonathan Cameron
@ 2022-10-17  5:56   ` Matti Vaittinen
  2022-10-17  6:03   ` Matti Vaittinen
  1 sibling, 0 replies; 39+ messages in thread
From: Matti Vaittinen @ 2022-10-17  5:56 UTC (permalink / raw)
  To: Jonathan Cameron, linux-iio
  Cc: Matti Vaittinen, Cosmin Tanislav, Jagath Jog J, Sean Nyekjaer,
	Dmitry Rokosov, Linus Walleij, Andy Shevchenko,
	Michael Hennerich, Lorenzo Bianconi, Martyn Welch,
	Gwendal Grignou, Stephen Boyd, Tomasz Duszynski,
	Jonathan Cameron

On 10/16/22 19:34, Jonathan Cameron wrote:
> From: Jonathan Cameron <Jonathan.Cameron@huawei.com>
> 
> This driver only turns the power for some regulators on at probe and off
> via a custom devm_add_action_or_reset() callback. The new
> devm_regulator_bulk_get_enable() replaces all this boilerplate code.
> 
> Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>

Reviewed-by: Matti Vaittinen <mazziesaccount@gmail.com>

> ---
>   drivers/iio/light/ltr501.c | 27 ++++-----------------------
>   1 file changed, 4 insertions(+), 23 deletions(-)

-- 
Matti Vaittinen
Linux kernel developer at ROHM Semiconductors
Oulu Finland

~~ When things go utterly wrong vim users can always type :help! ~~


^ permalink raw reply	[flat|nested] 39+ messages in thread

* Re: [PATCH 10/14] iio: light: ltr501: Use devm_regulator_bulk_get_enable()
  2022-10-16 16:34 ` [PATCH 10/14] iio: light: ltr501: Use devm_regulator_bulk_get_enable() Jonathan Cameron
  2022-10-17  5:56   ` Matti Vaittinen
@ 2022-10-17  6:03   ` Matti Vaittinen
  1 sibling, 0 replies; 39+ messages in thread
From: Matti Vaittinen @ 2022-10-17  6:03 UTC (permalink / raw)
  To: Jonathan Cameron, linux-iio
  Cc: Matti Vaittinen, Cosmin Tanislav, Jagath Jog J, Sean Nyekjaer,
	Dmitry Rokosov, Linus Walleij, Andy Shevchenko,
	Michael Hennerich, Lorenzo Bianconi, Martyn Welch,
	Gwendal Grignou, Stephen Boyd, Tomasz Duszynski,
	Jonathan Cameron

On 10/16/22 19:34, Jonathan Cameron wrote:
> From: Jonathan Cameron <Jonathan.Cameron@huawei.com>
> 
> This driver only turns the power for some regulators on at probe and off
> via a custom devm_add_action_or_reset() callback. The new
> devm_regulator_bulk_get_enable() replaces all this boilerplate code.
> 
> Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>

Reviewed-by: Matti Vaittinen <mazziesaccount@gmail.com>

> ---
>   drivers/iio/light/ltr501.c | 27 ++++-----------------------
>   1 file changed, 4 insertions(+), 23 deletions(-)
> 
-- 
Matti Vaittinen
Linux kernel developer at ROHM Semiconductors
Oulu Finland

~~ When things go utterly wrong vim users can always type :help! ~~


^ permalink raw reply	[flat|nested] 39+ messages in thread

* Re: [PATCH 11/14] iio: light: noa1305: Use devm_regulator_get_enable()
  2022-10-16 16:34 ` [PATCH 11/14] iio: light: noa1305: Use devm_regulator_get_enable() Jonathan Cameron
@ 2022-10-17  6:06   ` Matti Vaittinen
  0 siblings, 0 replies; 39+ messages in thread
From: Matti Vaittinen @ 2022-10-17  6:06 UTC (permalink / raw)
  To: Jonathan Cameron, linux-iio
  Cc: Matti Vaittinen, Cosmin Tanislav, Jagath Jog J, Sean Nyekjaer,
	Dmitry Rokosov, Linus Walleij, Andy Shevchenko,
	Michael Hennerich, Lorenzo Bianconi, Martyn Welch,
	Gwendal Grignou, Stephen Boyd, Tomasz Duszynski,
	Jonathan Cameron


[-- Attachment #1.1.1: Type: text/plain, Size: 749 bytes --]

On 10/16/22 19:34, Jonathan Cameron wrote:
> From: Jonathan Cameron <Jonathan.Cameron@huawei.com>
> 
> This driver only turns the power on at probe and off via a custom
> devm_add_action_or_reset() callback. The new devm_regulator_get_enable()
> replaces this boilerplate code.
> 
> Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
> Cc: Martyn Welch <martyn.welch@collabora.com>

Reviewed-by: Matti Vaittinen <mazziesaccount@gmail.com>

> ---
>   drivers/iio/light/noa1305.c | 26 +++-----------------------
>   1 file changed, 3 insertions(+), 23 deletions(-)
> 
-- 
Matti Vaittinen
Linux kernel developer at ROHM Semiconductors
Oulu Finland

~~ When things go utterly wrong vim users can always type :help! ~~


[-- Attachment #1.1.2: OpenPGP public key --]
[-- Type: application/pgp-keys, Size: 5335 bytes --]

[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 495 bytes --]

^ permalink raw reply	[flat|nested] 39+ messages in thread

* Re: [PATCH 12/14] iio: proximity: sx_common: Use devm_regulator_bulk_get_enable()
  2022-10-16 16:34 ` [PATCH 12/14] iio: proximity: sx_common: Use devm_regulator_bulk_get_enable() Jonathan Cameron
@ 2022-10-17  6:09   ` Matti Vaittinen
  2022-10-18 22:21   ` Stephen Boyd
  1 sibling, 0 replies; 39+ messages in thread
From: Matti Vaittinen @ 2022-10-17  6:09 UTC (permalink / raw)
  To: Jonathan Cameron, linux-iio
  Cc: Matti Vaittinen, Cosmin Tanislav, Jagath Jog J, Sean Nyekjaer,
	Dmitry Rokosov, Linus Walleij, Andy Shevchenko,
	Michael Hennerich, Lorenzo Bianconi, Martyn Welch,
	Gwendal Grignou, Stephen Boyd, Tomasz Duszynski,
	Jonathan Cameron


[-- Attachment #1.1.1: Type: text/plain, Size: 870 bytes --]

On 10/16/22 19:34, Jonathan Cameron wrote:
> From: Jonathan Cameron <Jonathan.Cameron@huawei.com>
> 
> This driver only turns the power for some regulators on at probe and off
> via a custom devm_add_action_or_reset() callback. The new
> devm_regulator_bulk_get_enable() replaces all this boilerplate code.
> 
> Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
> Cc: Gwendal Grignou <gwendal@chromium.org>
> Cc: Stephen Boyd <swboyd@chromium.org>

Reviewed-by: Matti Vaittinen <mazziesaccount@gmail.com>

> ---
>   drivers/iio/proximity/sx_common.c | 23 +++--------------------
>   drivers/iio/proximity/sx_common.h |  2 --
>   2 files changed, 3 insertions(+), 22 deletions(-)
> 

-- 
Matti Vaittinen
Linux kernel developer at ROHM Semiconductors
Oulu Finland

~~ When things go utterly wrong vim users can always type :help! ~~


[-- Attachment #1.1.2: OpenPGP public key --]
[-- Type: application/pgp-keys, Size: 5335 bytes --]

[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 495 bytes --]

^ permalink raw reply	[flat|nested] 39+ messages in thread

* Re: [PATCH 13/14] iio: pressure: ms5611: Use devm_regulator_get_enable()
  2022-10-16 16:34 ` [PATCH 13/14] iio: pressure: ms5611: Use devm_regulator_get_enable() Jonathan Cameron
  2022-10-17  6:26   ` Matti Vaittinen
@ 2022-10-17  6:26   ` Matti Vaittinen
  1 sibling, 0 replies; 39+ messages in thread
From: Matti Vaittinen @ 2022-10-17  6:26 UTC (permalink / raw)
  To: Jonathan Cameron, linux-iio
  Cc: Matti Vaittinen, Cosmin Tanislav, Jagath Jog J, Sean Nyekjaer,
	Dmitry Rokosov, Linus Walleij, Andy Shevchenko,
	Michael Hennerich, Lorenzo Bianconi, Martyn Welch,
	Gwendal Grignou, Stephen Boyd, Tomasz Duszynski,
	Jonathan Cameron

On 10/16/22 19:34, Jonathan Cameron wrote:
> From: Jonathan Cameron <Jonathan.Cameron@huawei.com>
> 
> This driver only turns the power on at probe and off via a custom
> devm_add_action_or_reset() callback.

I think this one did not use devm_add_action_or_reset()

> The new devm_regulator_get_enable()
> replaces this boilerplate code. Some additional refactoring to drop
> now unnecessary unwinding after this change.
> 
> Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
> Cc: Tomasz Duszynski <tduszyns@gmail.com>
> ---
>   drivers/iio/pressure/ms5611.h      |  3 ---
>   drivers/iio/pressure/ms5611_core.c | 32 +++++-------------------------
>   2 files changed, 5 insertions(+), 30 deletions(-)
> 

// snip

> @@ -477,7 +456,6 @@ void ms5611_remove(struct iio_dev *indio_dev)
>   {
>   	iio_device_unregister(indio_dev);
>   	iio_triggered_buffer_cleanup(indio_dev);
> -	ms5611_fini(indio_dev);
>   }
>   EXPORT_SYMBOL_NS(ms5611_remove, IIO_MS5611);

Just a thought but maybe the whole remove() could be done using devm()? 
(As far as I can say the current flow works. AFAICS the devm unwinding 
is done after the remove() has been ran. But perhaps it would be cleaner 
if the remove() would not need to be exported at all.)

With, or without the remove() removed, if commit description is fixed:
Reviewed-by: Matti Vaittinen <mazziesaccount@gmail.com>

-- 
Matti Vaittinen
Linux kernel developer at ROHM Semiconductors
Oulu Finland

~~ When things go utterly wrong vim users can always type :help! ~~


^ permalink raw reply	[flat|nested] 39+ messages in thread

* Re: [PATCH 13/14] iio: pressure: ms5611: Use devm_regulator_get_enable()
  2022-10-16 16:34 ` [PATCH 13/14] iio: pressure: ms5611: Use devm_regulator_get_enable() Jonathan Cameron
@ 2022-10-17  6:26   ` Matti Vaittinen
  2022-12-04 18:19     ` Jonathan Cameron
  2022-10-17  6:26   ` Matti Vaittinen
  1 sibling, 1 reply; 39+ messages in thread
From: Matti Vaittinen @ 2022-10-17  6:26 UTC (permalink / raw)
  To: Jonathan Cameron, linux-iio
  Cc: Matti Vaittinen, Cosmin Tanislav, Jagath Jog J, Sean Nyekjaer,
	Dmitry Rokosov, Linus Walleij, Andy Shevchenko,
	Michael Hennerich, Lorenzo Bianconi, Martyn Welch,
	Gwendal Grignou, Stephen Boyd, Tomasz Duszynski,
	Jonathan Cameron

On 10/16/22 19:34, Jonathan Cameron wrote:
> From: Jonathan Cameron <Jonathan.Cameron@huawei.com>
> 
> This driver only turns the power on at probe and off via a custom
> devm_add_action_or_reset() callback.

I think this one did not use devm_add_action_or_reset()

> The new devm_regulator_get_enable()
> replaces this boilerplate code. Some additional refactoring to drop
> now unnecessary unwinding after this change.
> 
> Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
> Cc: Tomasz Duszynski <tduszyns@gmail.com>
> ---
>   drivers/iio/pressure/ms5611.h      |  3 ---
>   drivers/iio/pressure/ms5611_core.c | 32 +++++-------------------------
>   2 files changed, 5 insertions(+), 30 deletions(-)
> 

// snip

> @@ -477,7 +456,6 @@ void ms5611_remove(struct iio_dev *indio_dev)
>   {
>   	iio_device_unregister(indio_dev);
>   	iio_triggered_buffer_cleanup(indio_dev);
> -	ms5611_fini(indio_dev);
>   }
>   EXPORT_SYMBOL_NS(ms5611_remove, IIO_MS5611);

Just a thought but maybe the whole remove() could be done using devm()? 
(As far as I can say the current flow works. AFAICS the devm unwinding 
is done after the remove() has been ran. But perhaps it would be cleaner 
if the remove() would not need to be exported at all.)

With, or without the remove() removed, if commit description is fixed:
Reviewed-by: Matti Vaittinen <mazziesaccount@gmail.com>

-- 
Matti Vaittinen
Linux kernel developer at ROHM Semiconductors
Oulu Finland

~~ When things go utterly wrong vim users can always type :help! ~~


^ permalink raw reply	[flat|nested] 39+ messages in thread

* Re: [PATCH 14/14] iio: pressure: ms5611: Switch to fully devm_ managed registration.
  2022-10-16 16:34 ` [PATCH 14/14] iio: pressure: ms5611: Switch to fully devm_ managed registration Jonathan Cameron
@ 2022-10-17  6:30   ` Matti Vaittinen
  2022-12-04 18:22     ` Jonathan Cameron
  0 siblings, 1 reply; 39+ messages in thread
From: Matti Vaittinen @ 2022-10-17  6:30 UTC (permalink / raw)
  To: Jonathan Cameron, linux-iio
  Cc: Matti Vaittinen, Cosmin Tanislav, Jagath Jog J, Sean Nyekjaer,
	Dmitry Rokosov, Linus Walleij, Andy Shevchenko,
	Michael Hennerich, Lorenzo Bianconi, Martyn Welch,
	Gwendal Grignou, Stephen Boyd, Tomasz Duszynski,
	Jonathan Cameron

On 10/16/22 19:34, Jonathan Cameron wrote:
> From: Jonathan Cameron <Jonathan.Cameron@huawei.com>
> 
> All the remaining calls in probe() have devm_ equivalents so
> switching to those allows the remove() callbacks to be deleted.
> No functional change.

Right :) So please ignore my last comment in the patch 13/14 :) The one 
concerning the commit message is still valid though :)

> 
> Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
> Cc: Tomasz Duszynski <tduszyns@gmail.com>

Reviewed-by: Matti Vaittinen <mazziesaccount@gmail.com>

> ---
>   drivers/iio/pressure/ms5611.h      |  1 -
>   drivers/iio/pressure/ms5611_core.c | 17 +++--------------
>   drivers/iio/pressure/ms5611_i2c.c  |  6 ------
>   drivers/iio/pressure/ms5611_spi.c  |  6 ------
>   4 files changed, 3 insertions(+), 27 deletions(-)
> 

-- 
Matti Vaittinen
Linux kernel developer at ROHM Semiconductors
Oulu Finland

~~ When things go utterly wrong vim users can always type :help! ~~


^ permalink raw reply	[flat|nested] 39+ messages in thread

* Re: [PATCH 09/14] iio: humidity: hts211: Use devm_regulator_get_enable()
  2022-10-16 16:34 ` [PATCH 09/14] iio: humidity: hts211: " Jonathan Cameron
  2022-10-17  5:53   ` Matti Vaittinen
@ 2022-10-17  7:11   ` Lorenzo Bianconi
  1 sibling, 0 replies; 39+ messages in thread
From: Lorenzo Bianconi @ 2022-10-17  7:11 UTC (permalink / raw)
  To: Jonathan Cameron
  Cc: linux-iio, Matti Vaittinen, Matti Vaittinen, Cosmin Tanislav,
	Jagath Jog J, Sean Nyekjaer, Dmitry Rokosov, Linus Walleij,
	Andy Shevchenko, Michael Hennerich, Martyn Welch,
	Gwendal Grignou, Stephen Boyd, Tomasz Duszynski,
	Jonathan Cameron

[-- Attachment #1: Type: text/plain, Size: 2948 bytes --]

> From: Jonathan Cameron <Jonathan.Cameron@huawei.com>
> 
> This driver only turns the power on at probe and off via a custom
> devm_add_action_or_reset() callback. The new devm_regulator_get_enable()
> replaces this boilerplate code.
> 
> Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
> Cc: Lorenzo Bianconi <lorenzo@kernel.org>

Acked-by: Lorenzo Bianconi <lorenzo@kernel.org>

> ---
>  drivers/iio/humidity/hts221.h      |  2 --
>  drivers/iio/humidity/hts221_core.c | 27 ++++-----------------------
>  2 files changed, 4 insertions(+), 25 deletions(-)
> 
> diff --git a/drivers/iio/humidity/hts221.h b/drivers/iio/humidity/hts221.h
> index cf3d8d2dccd6..721359e226cb 100644
> --- a/drivers/iio/humidity/hts221.h
> +++ b/drivers/iio/humidity/hts221.h
> @@ -13,7 +13,6 @@
>  #define HTS221_DEV_NAME		"hts221"
>  
>  #include <linux/iio/iio.h>
> -#include <linux/regulator/consumer.h>
>  
>  enum hts221_sensor_type {
>  	HTS221_SENSOR_H,
> @@ -30,7 +29,6 @@ struct hts221_hw {
>  	const char *name;
>  	struct device *dev;
>  	struct regmap *regmap;
> -	struct regulator *vdd;
>  
>  	struct iio_trigger *trig;
>  	int irq;
> diff --git a/drivers/iio/humidity/hts221_core.c b/drivers/iio/humidity/hts221_core.c
> index 517158307d8c..2a413da87b76 100644
> --- a/drivers/iio/humidity/hts221_core.c
> +++ b/drivers/iio/humidity/hts221_core.c
> @@ -14,6 +14,7 @@
>  #include <linux/delay.h>
>  #include <linux/pm.h>
>  #include <linux/regmap.h>
> +#include <linux/regulator/consumer.h>
>  #include <linux/bitfield.h>
>  
>  #include "hts221.h"
> @@ -549,33 +550,17 @@ static const unsigned long hts221_scan_masks[] = {0x3, 0x0};
>  
>  static int hts221_init_regulators(struct device *dev)
>  {
> -	struct iio_dev *iio_dev = dev_get_drvdata(dev);
> -	struct hts221_hw *hw = iio_priv(iio_dev);
>  	int err;
>  
> -	hw->vdd = devm_regulator_get(dev, "vdd");
> -	if (IS_ERR(hw->vdd))
> -		return dev_err_probe(dev, PTR_ERR(hw->vdd),
> -				     "failed to get vdd regulator\n");
> -
> -	err = regulator_enable(hw->vdd);
> -	if (err) {
> -		dev_err(dev, "failed to enable vdd regulator: %d\n", err);
> -		return err;
> -	}
> +	err = devm_regulator_get_enable(dev, "vdd");
> +	if (err)
> +		return dev_err_probe(dev, err, "failed to get vdd regulator\n");
>  
>  	msleep(50);
>  
>  	return 0;
>  }
>  
> -static void hts221_chip_uninit(void *data)
> -{
> -	struct hts221_hw *hw = data;
> -
> -	regulator_disable(hw->vdd);
> -}
> -
>  int hts221_probe(struct device *dev, int irq, const char *name,
>  		 struct regmap *regmap)
>  {
> @@ -600,10 +585,6 @@ int hts221_probe(struct device *dev, int irq, const char *name,
>  	if (err)
>  		return err;
>  
> -	err = devm_add_action_or_reset(dev, hts221_chip_uninit, hw);
> -	if (err)
> -		return err;
> -
>  	err = hts221_check_whoami(hw);
>  	if (err < 0)
>  		return err;
> -- 
> 2.37.2
> 

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 228 bytes --]

^ permalink raw reply	[flat|nested] 39+ messages in thread

* Re: [PATCH 03/14] iio: accel: fxls8962af: Use devm_regulator_get_enable()
  2022-10-16 16:33 ` [PATCH 03/14] iio: accel: fxls8962af: Use devm_regulator_get_enable() Jonathan Cameron
  2022-10-17  5:27   ` Matti Vaittinen
@ 2022-10-17  9:23   ` Sean Nyekjaer
  1 sibling, 0 replies; 39+ messages in thread
From: Sean Nyekjaer @ 2022-10-17  9:23 UTC (permalink / raw)
  To: Jonathan Cameron
  Cc: linux-iio, Matti Vaittinen, Matti Vaittinen, Cosmin Tanislav,
	Jagath Jog J, Dmitry Rokosov, Linus Walleij, Andy Shevchenko,
	Michael Hennerich, Lorenzo Bianconi, Martyn Welch,
	Gwendal Grignou, Stephen Boyd, Tomasz Duszynski,
	Jonathan Cameron

On Sun, Oct 16, 2022 at 05:33:58PM +0100, Jonathan Cameron wrote:
> From: Jonathan Cameron <Jonathan.Cameron@huawei.com>
> 
> This driver only turns the power on at probe and off via a custom
> devm_add_action_or_reset() callback. The new devm_regulator_get_enable()
> replaces this boilerplate code.
> 
> Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
> Cc: Sean Nyekjaer <sean@geanix.com>
Reviewed-by: Sean Nyekjaer <sean@geanix.com>
> ---
>  drivers/iio/accel/fxls8962af-core.c | 24 +++---------------------
>  1 file changed, 3 insertions(+), 21 deletions(-)
> 
> diff --git a/drivers/iio/accel/fxls8962af-core.c b/drivers/iio/accel/fxls8962af-core.c
> index bf259db281f5..0d672b1469e8 100644
> --- a/drivers/iio/accel/fxls8962af-core.c
> +++ b/drivers/iio/accel/fxls8962af-core.c
> @@ -159,7 +159,6 @@ struct fxls8962af_chip_info {
>  struct fxls8962af_data {
>  	struct regmap *regmap;
>  	const struct fxls8962af_chip_info *chip_info;
> -	struct regulator *vdd_reg;
>  	struct {
>  		__le16 channels[3];
>  		s64 ts __aligned(8);
> @@ -1051,13 +1050,6 @@ static irqreturn_t fxls8962af_interrupt(int irq, void *p)
>  	return IRQ_NONE;
>  }
>  
> -static void fxls8962af_regulator_disable(void *data_ptr)
> -{
> -	struct fxls8962af_data *data = data_ptr;
> -
> -	regulator_disable(data->vdd_reg);
> -}
> -
>  static void fxls8962af_pm_disable(void *dev_ptr)
>  {
>  	struct device *dev = dev_ptr;
> @@ -1171,20 +1163,10 @@ int fxls8962af_core_probe(struct device *dev, struct regmap *regmap, int irq)
>  	if (ret)
>  		return ret;
>  
> -	data->vdd_reg = devm_regulator_get(dev, "vdd");
> -	if (IS_ERR(data->vdd_reg))
> -		return dev_err_probe(dev, PTR_ERR(data->vdd_reg),
> -				     "Failed to get vdd regulator\n");
> -
> -	ret = regulator_enable(data->vdd_reg);
> -	if (ret) {
> -		dev_err(dev, "Failed to enable vdd regulator: %d\n", ret);
> -		return ret;
> -	}
> -
> -	ret = devm_add_action_or_reset(dev, fxls8962af_regulator_disable, data);
> +	ret = devm_regulator_get_enable(dev, "vdd");
>  	if (ret)
> -		return ret;
> +		return dev_err_probe(dev, ret,
> +				     "Failed to get vdd regulator\n");
>  
>  	ret = regmap_read(data->regmap, FXLS8962AF_WHO_AM_I, &reg);
>  	if (ret)
> -- 
> 2.37.2
> 


^ permalink raw reply	[flat|nested] 39+ messages in thread

* RE: [PATCH 00/14] IIO: More devm_regulator[_bulk]_get_enable() users
  2022-10-16 16:33 [PATCH 00/14] IIO: More devm_regulator[_bulk]_get_enable() users Jonathan Cameron
                   ` (13 preceding siblings ...)
  2022-10-16 16:34 ` [PATCH 14/14] iio: pressure: ms5611: Switch to fully devm_ managed registration Jonathan Cameron
@ 2022-10-17 11:27 ` Sa, Nuno
  2022-10-23 13:03   ` Jonathan Cameron
  14 siblings, 1 reply; 39+ messages in thread
From: Sa, Nuno @ 2022-10-17 11:27 UTC (permalink / raw)
  To: Jonathan Cameron, linux-iio
  Cc: Matti Vaittinen, Matti Vaittinen, Tanislav, Cosmin, Jagath Jog J,
	Sean Nyekjaer, Dmitry Rokosov, Linus Walleij, Andy Shevchenko,
	Hennerich, Michael, Lorenzo Bianconi, Martyn Welch,
	Gwendal Grignou, Stephen Boyd, Tomasz Duszynski,
	Jonathan Cameron



> -----Original Message-----
> From: Jonathan Cameron <jic23@kernel.org>
> Sent: Sunday, October 16, 2022 6:34 PM
> To: linux-iio@vger.kernel.org
> Cc: Matti Vaittinen <mazziesaccount@gmail.com>; Matti Vaittinen
> <matti.vaittinen@fi.rohmeurope.com>; Tanislav, Cosmin
> <Cosmin.Tanislav@analog.com>; Jagath Jog J <jagathjog1996@gmail.com>;
> Sean Nyekjaer <sean@geanix.com>; Dmitry Rokosov
> <DDRokosov@sberdevices.ru>; Linus Walleij <linus.walleij@linaro.org>;
> Andy Shevchenko <andriy.shevchenko@linux.intel.com>; Hennerich,
> Michael <Michael.Hennerich@analog.com>; Lorenzo Bianconi
> <lorenzo@kernel.org>; Martyn Welch <martyn.welch@collabora.com>;
> Gwendal Grignou <gwendal@chromium.org>; Stephen Boyd
> <swboyd@chromium.org>; Tomasz Duszynski <tduszyns@gmail.com>;
> Jonathan Cameron <Jonathan.Cameron@huawei.com>
> Subject: [PATCH 00/14] IIO: More devm_regulator[_bulk]_get_enable()
> users
> 
> [External]
> 
> From: Jonathan Cameron <Jonathan.Cameron@huawei.com>
> 
> Also one general devm conversion that was too easy to ignore after
> dealing with the regulators.
> 
> These new macros allow dropping of some boilerplate.  They are not
> useful in many cases in IIO because they do not expose the
> struct regulator, however for simple drivers that just turn the power
> on at probe() they ensure that it is turned off again at remove.
> 
> Jonathan Cameron (14):
>   iio: accel: adxl367: Use devm_regulator_bulk_get_enable()
>   iio: accel: bma400: Use devm_regulator_bulk_get_enable()
>   iio: accel: fxls8962af: Use devm_regulator_get_enable()
>   iio: accel: kxcjk-1013: Use devm_regulator_bulk_get_enable()
>   iio: accel: msa311: Use devm_regulator_get_enable()
>   iio: cdc: ad7150: Use devm_regulator_get_enable()
>   iio: st_sensors: core and lsm9ds0 switch to
>     devm_regulator_bulk_get_enable()
>   iio: frequency: ad9523: Use devm_regulator_get_enable()
>   iio: humidity: hts211: Use devm_regulator_get_enable()
>   iio: light: ltr501: Use devm_regulator_bulk_get_enable()
>   iio: light: noa1305: Use devm_regulator_get_enable()
>   iio: proximity: sx_common: Use devm_regulator_bulk_get_enable()
>   iio: pressure: ms5611: Use devm_regulator_get_enable()
>   iio: pressure: ms5611: Switch to fully devm_ managed registration.
> 
>  drivers/iio/accel/adxl367.c                   | 28 ++------
>  drivers/iio/accel/bma400.h                    |  4 --
>  drivers/iio/accel/bma400_core.c               | 29 ++-------
>  drivers/iio/accel/fxls8962af-core.c           | 24 +------
>  drivers/iio/accel/kxcjk-1013.c                | 25 ++-----
>  drivers/iio/accel/msa311.c                    | 21 +-----
>  drivers/iio/cdc/ad7150.c                      | 18 +----
>  .../iio/common/st_sensors/st_sensors_core.c   | 39 ++---------
>  drivers/iio/frequency/ad9523.c                | 22 +------
>  drivers/iio/humidity/hts221.h                 |  2 -
>  drivers/iio/humidity/hts221_core.c            | 27 ++------
>  drivers/iio/imu/st_lsm9ds0/st_lsm9ds0_core.c  | 65 ++-----------------
>  drivers/iio/light/ltr501.c                    | 27 ++------
>  drivers/iio/light/noa1305.c                   | 26 +-------
>  drivers/iio/pressure/ms5611.h                 |  4 --
>  drivers/iio/pressure/ms5611_core.c            | 49 +++-----------
>  drivers/iio/pressure/ms5611_i2c.c             |  6 --
>  drivers/iio/pressure/ms5611_spi.c             |  6 --
>  drivers/iio/proximity/sx_common.c             | 23 +------
>  drivers/iio/proximity/sx_common.h             |  2 -
>  include/linux/iio/common/st_sensors.h         |  4 --
>  21 files changed, 57 insertions(+), 394 deletions(-)
> 
> --
> 2.37.2

For all patches but patch 13/14,

Reviewed-by: Nuno Sá <nuno.sa@analog.com>

For that one, you can add my tag after addressing Matti's comment.

- Nuno Sá

^ permalink raw reply	[flat|nested] 39+ messages in thread

* Re: [PATCH 05/14] iio: accel: msa311: Use devm_regulator_get_enable()
  2022-10-16 16:34 ` [PATCH 05/14] iio: accel: msa311: Use devm_regulator_get_enable() Jonathan Cameron
@ 2022-10-18 15:14   ` Dmitry Rokosov
  0 siblings, 0 replies; 39+ messages in thread
From: Dmitry Rokosov @ 2022-10-18 15:14 UTC (permalink / raw)
  To: Jonathan Cameron
  Cc: linux-iio, Matti Vaittinen, Matti Vaittinen, Cosmin Tanislav,
	Jagath Jog J, Sean Nyekjaer, Linus Walleij, Andy Shevchenko,
	Michael Hennerich, Lorenzo Bianconi, Martyn Welch,
	Gwendal Grignou, Stephen Boyd, Tomasz Duszynski,
	Jonathan Cameron

Hello Jonathan,

Thank you for the patch! The current devm_regulator_get_enable() looks
much easier to read!

On Sun, Oct 16, 2022 at 05:34:00PM +0100, Jonathan Cameron wrote:
> From: Jonathan Cameron <Jonathan.Cameron@huawei.com>
> 
> This driver only turns the power on at probe and off via a custom
> devm_add_action_or_reset() callback. The new devm_regulator_get_enable()
> replaces this boilerplate code.
> 
> Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
> Cc: Dmitry Rokosov <DDRokosov@sberdevices.ru>
> ---
>  drivers/iio/accel/msa311.c | 21 ++-------------------
>  1 file changed, 2 insertions(+), 19 deletions(-)
> 
> diff --git a/drivers/iio/accel/msa311.c b/drivers/iio/accel/msa311.c
> index 2fded3759171..af94d3adf6d8 100644
> --- a/drivers/iio/accel/msa311.c
> +++ b/drivers/iio/accel/msa311.c
> @@ -351,7 +351,6 @@ static const struct regmap_config msa311_regmap_config = {
>   * @chip_name: Chip name in the format "msa311-%02x" % partid
>   * @new_data_trig: Optional NEW_DATA interrupt driven trigger used
>   *                 to notify external consumers a new sample is ready
> - * @vdd: Optional external voltage regulator for the device power supply
>   */
>  struct msa311_priv {
>  	struct regmap *regs;
> @@ -362,7 +361,6 @@ struct msa311_priv {
>  	char *chip_name;
>  
>  	struct iio_trigger *new_data_trig;
> -	struct regulator *vdd;
>  };
>  
>  enum msa311_si {
> @@ -1146,11 +1144,6 @@ static void msa311_powerdown(void *msa311)
>  	msa311_set_pwr_mode(msa311, MSA311_PWR_MODE_SUSPEND);
>  }
>  
> -static void msa311_vdd_disable(void *vdd)
> -{
> -	regulator_disable(vdd);
> -}
> -
>  static int msa311_probe(struct i2c_client *i2c)
>  {
>  	struct device *dev = &i2c->dev;
> @@ -1173,19 +1166,9 @@ static int msa311_probe(struct i2c_client *i2c)
>  
>  	mutex_init(&msa311->lock);
>  
> -	msa311->vdd = devm_regulator_get(dev, "vdd");
> -	if (IS_ERR(msa311->vdd))
> -		return dev_err_probe(dev, PTR_ERR(msa311->vdd),
> -				     "can't get vdd supply\n");
> -
> -	err = regulator_enable(msa311->vdd);
> +	err = devm_regulator_get_enable(dev, "vdd");
>  	if (err)
> -		return dev_err_probe(dev, err, "can't enable vdd supply\n");
> -
> -	err = devm_add_action_or_reset(dev, msa311_vdd_disable, msa311->vdd);
> -	if (err)
> -		return dev_err_probe(dev, err,
> -				     "can't add vdd disable action\n");
> +		return dev_err_probe(dev, err, "can't get vdd supply\n");
>  
>  	err = msa311_check_partid(msa311);
>  	if (err)
> -- 
> 2.37.2
> 

Reviewed-by: Dmitry Rokosov <ddrokosov@sberdevices.ru>

-- 
Thank you,
Dmitry

^ permalink raw reply	[flat|nested] 39+ messages in thread

* Re: [PATCH 12/14] iio: proximity: sx_common: Use devm_regulator_bulk_get_enable()
  2022-10-16 16:34 ` [PATCH 12/14] iio: proximity: sx_common: Use devm_regulator_bulk_get_enable() Jonathan Cameron
  2022-10-17  6:09   ` Matti Vaittinen
@ 2022-10-18 22:21   ` Stephen Boyd
  1 sibling, 0 replies; 39+ messages in thread
From: Stephen Boyd @ 2022-10-18 22:21 UTC (permalink / raw)
  To: Jonathan Cameron, linux-iio
  Cc: Matti Vaittinen, Matti Vaittinen, Cosmin Tanislav, Jagath Jog J,
	Sean Nyekjaer, Dmitry Rokosov, Linus Walleij, Andy Shevchenko,
	Michael Hennerich, Lorenzo Bianconi, Martyn Welch,
	Gwendal Grignou, Tomasz Duszynski, Jonathan Cameron

Quoting Jonathan Cameron (2022-10-16 09:34:07)
> From: Jonathan Cameron <Jonathan.Cameron@huawei.com>
>
> This driver only turns the power for some regulators on at probe and off
> via a custom devm_add_action_or_reset() callback. The new
> devm_regulator_bulk_get_enable() replaces all this boilerplate code.
>
> Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
> Cc: Gwendal Grignou <gwendal@chromium.org>
> Cc: Stephen Boyd <swboyd@chromium.org>
> ---

Reviewed-by: Stephen Boyd <swboyd@chromium.org>

^ permalink raw reply	[flat|nested] 39+ messages in thread

* Re: [PATCH 00/14] IIO: More devm_regulator[_bulk]_get_enable() users
  2022-10-17 11:27 ` [PATCH 00/14] IIO: More devm_regulator[_bulk]_get_enable() users Sa, Nuno
@ 2022-10-23 13:03   ` Jonathan Cameron
  0 siblings, 0 replies; 39+ messages in thread
From: Jonathan Cameron @ 2022-10-23 13:03 UTC (permalink / raw)
  To: Sa, Nuno
  Cc: linux-iio, Matti Vaittinen, Matti Vaittinen, Tanislav, Cosmin,
	Jagath Jog J, Sean Nyekjaer, Dmitry Rokosov, Linus Walleij,
	Andy Shevchenko, Hennerich, Michael, Lorenzo Bianconi,
	Martyn Welch, Gwendal Grignou, Stephen Boyd, Tomasz Duszynski,
	Jonathan Cameron

On Mon, 17 Oct 2022 11:27:18 +0000
"Sa, Nuno" <Nuno.Sa@analog.com> wrote:

> > -----Original Message-----
> > From: Jonathan Cameron <jic23@kernel.org>
> > Sent: Sunday, October 16, 2022 6:34 PM
> > To: linux-iio@vger.kernel.org
> > Cc: Matti Vaittinen <mazziesaccount@gmail.com>; Matti Vaittinen
> > <matti.vaittinen@fi.rohmeurope.com>; Tanislav, Cosmin
> > <Cosmin.Tanislav@analog.com>; Jagath Jog J <jagathjog1996@gmail.com>;
> > Sean Nyekjaer <sean@geanix.com>; Dmitry Rokosov
> > <DDRokosov@sberdevices.ru>; Linus Walleij <linus.walleij@linaro.org>;
> > Andy Shevchenko <andriy.shevchenko@linux.intel.com>; Hennerich,
> > Michael <Michael.Hennerich@analog.com>; Lorenzo Bianconi
> > <lorenzo@kernel.org>; Martyn Welch <martyn.welch@collabora.com>;
> > Gwendal Grignou <gwendal@chromium.org>; Stephen Boyd
> > <swboyd@chromium.org>; Tomasz Duszynski <tduszyns@gmail.com>;
> > Jonathan Cameron <Jonathan.Cameron@huawei.com>
> > Subject: [PATCH 00/14] IIO: More devm_regulator[_bulk]_get_enable()
> > users
> > 
> > [External]
> > 
> > From: Jonathan Cameron <Jonathan.Cameron@huawei.com>
> > 
> > Also one general devm conversion that was too easy to ignore after
> > dealing with the regulators.
> > 
> > These new macros allow dropping of some boilerplate.  They are not
> > useful in many cases in IIO because they do not expose the
> > struct regulator, however for simple drivers that just turn the power
> > on at probe() they ensure that it is turned off again at remove.
> > 
> > Jonathan Cameron (14):
> >   iio: accel: adxl367: Use devm_regulator_bulk_get_enable()
> >   iio: accel: bma400: Use devm_regulator_bulk_get_enable()
> >   iio: accel: fxls8962af: Use devm_regulator_get_enable()
> >   iio: accel: kxcjk-1013: Use devm_regulator_bulk_get_enable()
> >   iio: accel: msa311: Use devm_regulator_get_enable()
> >   iio: cdc: ad7150: Use devm_regulator_get_enable()
> >   iio: st_sensors: core and lsm9ds0 switch to
> >     devm_regulator_bulk_get_enable()
> >   iio: frequency: ad9523: Use devm_regulator_get_enable()
> >   iio: humidity: hts211: Use devm_regulator_get_enable()
> >   iio: light: ltr501: Use devm_regulator_bulk_get_enable()
> >   iio: light: noa1305: Use devm_regulator_get_enable()
> >   iio: proximity: sx_common: Use devm_regulator_bulk_get_enable()
> >   iio: pressure: ms5611: Use devm_regulator_get_enable()
> >   iio: pressure: ms5611: Switch to fully devm_ managed registration.
> > 
> >  drivers/iio/accel/adxl367.c                   | 28 ++------
> >  drivers/iio/accel/bma400.h                    |  4 --
> >  drivers/iio/accel/bma400_core.c               | 29 ++-------
> >  drivers/iio/accel/fxls8962af-core.c           | 24 +------
> >  drivers/iio/accel/kxcjk-1013.c                | 25 ++-----
> >  drivers/iio/accel/msa311.c                    | 21 +-----
> >  drivers/iio/cdc/ad7150.c                      | 18 +----
> >  .../iio/common/st_sensors/st_sensors_core.c   | 39 ++---------
> >  drivers/iio/frequency/ad9523.c                | 22 +------
> >  drivers/iio/humidity/hts221.h                 |  2 -
> >  drivers/iio/humidity/hts221_core.c            | 27 ++------
> >  drivers/iio/imu/st_lsm9ds0/st_lsm9ds0_core.c  | 65 ++-----------------
> >  drivers/iio/light/ltr501.c                    | 27 ++------
> >  drivers/iio/light/noa1305.c                   | 26 +-------
> >  drivers/iio/pressure/ms5611.h                 |  4 --
> >  drivers/iio/pressure/ms5611_core.c            | 49 +++-----------
> >  drivers/iio/pressure/ms5611_i2c.c             |  6 --
> >  drivers/iio/pressure/ms5611_spi.c             |  6 --
> >  drivers/iio/proximity/sx_common.c             | 23 +------
> >  drivers/iio/proximity/sx_common.h             |  2 -
> >  include/linux/iio/common/st_sensors.h         |  4 --
> >  21 files changed, 57 insertions(+), 394 deletions(-)
> > 
> > --
> > 2.37.2  
> 
> For all patches but patch 13/14,
> 
> Reviewed-by: Nuno Sá <nuno.sa@analog.com>
> 
> For that one, you can add my tag after addressing Matti's comment.
Tweaked the patch description on that one. The other comment is covered
in patch 14 as Matti observed in response to that one.

Applied to the togreg branch of iio.git and pushed out as testing.

Thanks,

Jonathan

> 
> - Nuno Sá


^ permalink raw reply	[flat|nested] 39+ messages in thread

* Re: [PATCH 02/14] iio: accel: bma400: Use devm_regulator_bulk_get_enable()
  2022-10-17  5:27   ` Matti Vaittinen
@ 2022-12-04 18:15     ` Jonathan Cameron
  0 siblings, 0 replies; 39+ messages in thread
From: Jonathan Cameron @ 2022-12-04 18:15 UTC (permalink / raw)
  To: Matti Vaittinen
  Cc: linux-iio, Matti Vaittinen, Cosmin Tanislav, Jagath Jog J,
	Sean Nyekjaer, Dmitry Rokosov, Linus Walleij, Andy Shevchenko,
	Michael Hennerich, Lorenzo Bianconi, Martyn Welch,
	Gwendal Grignou, Stephen Boyd, Tomasz Duszynski,
	Jonathan Cameron

On Mon, 17 Oct 2022 08:27:29 +0300
Matti Vaittinen <mazziesaccount@gmail.com> wrote:

> On 10/16/22 19:33, Jonathan Cameron wrote:
> > From: Jonathan Cameron <Jonathan.Cameron@huawei.com>
> > 
> > This driver only turns the power on at probe and off via a custom
> > devm_add_action_or_reset() callback. The new
> > devm_regulator_bulk_get_enable() replaces this boilerplate code.
> > 
> > Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
> > Cc: Jagath Jog J <jagathjog1996@gmail.com>  
> 
> Reviewed-by: Matti Vaittinen <mazziesaccount@gmail.com>
> 
Now applied this one with slight fuzz due to the fix on ordering that crossed
with this.

Jonathan

^ permalink raw reply	[flat|nested] 39+ messages in thread

* Re: [PATCH 13/14] iio: pressure: ms5611: Use devm_regulator_get_enable()
  2022-10-17  6:26   ` Matti Vaittinen
@ 2022-12-04 18:19     ` Jonathan Cameron
  0 siblings, 0 replies; 39+ messages in thread
From: Jonathan Cameron @ 2022-12-04 18:19 UTC (permalink / raw)
  To: Matti Vaittinen
  Cc: linux-iio, Matti Vaittinen, Cosmin Tanislav, Jagath Jog J,
	Sean Nyekjaer, Dmitry Rokosov, Linus Walleij, Andy Shevchenko,
	Michael Hennerich, Lorenzo Bianconi, Martyn Welch,
	Gwendal Grignou, Stephen Boyd, Tomasz Duszynski,
	Jonathan Cameron

On Mon, 17 Oct 2022 09:26:15 +0300
Matti Vaittinen <mazziesaccount@gmail.com> wrote:

> On 10/16/22 19:34, Jonathan Cameron wrote:
> > From: Jonathan Cameron <Jonathan.Cameron@huawei.com>
> > 
> > This driver only turns the power on at probe and off via a custom
> > devm_add_action_or_reset() callback.  
> 
> I think this one did not use devm_add_action_or_reset()
The other changes hitting this driver are now upstream so applied
to the togreg branch of iio.git with a bit of fuzz.

Thanks,

Jonathan

> 
> > The new devm_regulator_get_enable()
> > replaces this boilerplate code. Some additional refactoring to drop
> > now unnecessary unwinding after this change.
> > 
> > Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
> > Cc: Tomasz Duszynski <tduszyns@gmail.com>
> > ---
> >   drivers/iio/pressure/ms5611.h      |  3 ---
> >   drivers/iio/pressure/ms5611_core.c | 32 +++++-------------------------
> >   2 files changed, 5 insertions(+), 30 deletions(-)
> >   
> 
> // snip
> 
> > @@ -477,7 +456,6 @@ void ms5611_remove(struct iio_dev *indio_dev)
> >   {
> >   	iio_device_unregister(indio_dev);
> >   	iio_triggered_buffer_cleanup(indio_dev);
> > -	ms5611_fini(indio_dev);
> >   }
> >   EXPORT_SYMBOL_NS(ms5611_remove, IIO_MS5611);  
> 
> Just a thought but maybe the whole remove() could be done using devm()? 
> (As far as I can say the current flow works. AFAICS the devm unwinding 
> is done after the remove() has been ran. But perhaps it would be cleaner 
> if the remove() would not need to be exported at all.)
> 
> With, or without the remove() removed, if commit description is fixed:
> Reviewed-by: Matti Vaittinen <mazziesaccount@gmail.com>
> 


^ permalink raw reply	[flat|nested] 39+ messages in thread

* Re: [PATCH 14/14] iio: pressure: ms5611: Switch to fully devm_ managed registration.
  2022-10-17  6:30   ` Matti Vaittinen
@ 2022-12-04 18:22     ` Jonathan Cameron
  0 siblings, 0 replies; 39+ messages in thread
From: Jonathan Cameron @ 2022-12-04 18:22 UTC (permalink / raw)
  To: Matti Vaittinen
  Cc: linux-iio, Matti Vaittinen, Cosmin Tanislav, Jagath Jog J,
	Sean Nyekjaer, Dmitry Rokosov, Linus Walleij, Andy Shevchenko,
	Michael Hennerich, Lorenzo Bianconi, Martyn Welch,
	Gwendal Grignou, Stephen Boyd, Tomasz Duszynski,
	Jonathan Cameron

On Mon, 17 Oct 2022 09:30:01 +0300
Matti Vaittinen <mazziesaccount@gmail.com> wrote:

> On 10/16/22 19:34, Jonathan Cameron wrote:
> > From: Jonathan Cameron <Jonathan.Cameron@huawei.com>
> > 
> > All the remaining calls in probe() have devm_ equivalents so
> > switching to those allows the remove() callbacks to be deleted.
> > No functional change.  
> 
> Right :) So please ignore my last comment in the patch 13/14 :) The one 
> concerning the commit message is still valid though :)
> 
> > 
> > Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
> > Cc: Tomasz Duszynski <tduszyns@gmail.com>  
> 
> Reviewed-by: Matti Vaittinen <mazziesaccount@gmail.com>

Applied to the togreg branch of iio.git - some fuzz due to crossing
with i2c probe_new() mass conversion and the changes that affected
the previous patch.

If anyone wants to sanity check the result, see the testing branch of iio.git
in a few minutes.

Thanks,

Jonathan

> 
> > ---
> >   drivers/iio/pressure/ms5611.h      |  1 -
> >   drivers/iio/pressure/ms5611_core.c | 17 +++--------------
> >   drivers/iio/pressure/ms5611_i2c.c  |  6 ------
> >   drivers/iio/pressure/ms5611_spi.c  |  6 ------
> >   4 files changed, 3 insertions(+), 27 deletions(-)
> >   
> 


^ permalink raw reply	[flat|nested] 39+ messages in thread

end of thread, other threads:[~2022-12-04 18:09 UTC | newest]

Thread overview: 39+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-10-16 16:33 [PATCH 00/14] IIO: More devm_regulator[_bulk]_get_enable() users Jonathan Cameron
2022-10-16 16:33 ` [PATCH 01/14] iio: accel: adxl367: Use devm_regulator_bulk_get_enable() Jonathan Cameron
2022-10-17  5:26   ` Matti Vaittinen
2022-10-16 16:33 ` [PATCH 02/14] iio: accel: bma400: " Jonathan Cameron
2022-10-17  5:27   ` Matti Vaittinen
2022-12-04 18:15     ` Jonathan Cameron
2022-10-16 16:33 ` [PATCH 03/14] iio: accel: fxls8962af: Use devm_regulator_get_enable() Jonathan Cameron
2022-10-17  5:27   ` Matti Vaittinen
2022-10-17  9:23   ` Sean Nyekjaer
2022-10-16 16:33 ` [PATCH 04/14] iio: accel: kxcjk-1013: Use devm_regulator_bulk_get_enable() Jonathan Cameron
2022-10-17  5:28   ` Matti Vaittinen
2022-10-16 16:34 ` [PATCH 05/14] iio: accel: msa311: Use devm_regulator_get_enable() Jonathan Cameron
2022-10-18 15:14   ` Dmitry Rokosov
2022-10-16 16:34 ` [PATCH 06/14] iio: cdc: ad7150: " Jonathan Cameron
2022-10-17  5:27   ` Matti Vaittinen
2022-10-16 16:34 ` [PATCH 07/14] iio: st_sensors: core and lsm9ds0 switch to devm_regulator_bulk_get_enable() Jonathan Cameron
2022-10-17  5:44   ` Matti Vaittinen
2022-10-16 16:34 ` [PATCH 08/14] iio: frequency: ad9523: Use devm_regulator_get_enable() Jonathan Cameron
2022-10-17  5:48   ` Matti Vaittinen
2022-10-16 16:34 ` [PATCH 09/14] iio: humidity: hts211: " Jonathan Cameron
2022-10-17  5:53   ` Matti Vaittinen
2022-10-17  7:11   ` Lorenzo Bianconi
2022-10-16 16:34 ` [PATCH 10/14] iio: light: ltr501: Use devm_regulator_bulk_get_enable() Jonathan Cameron
2022-10-17  5:56   ` Matti Vaittinen
2022-10-17  6:03   ` Matti Vaittinen
2022-10-16 16:34 ` [PATCH 11/14] iio: light: noa1305: Use devm_regulator_get_enable() Jonathan Cameron
2022-10-17  6:06   ` Matti Vaittinen
2022-10-16 16:34 ` [PATCH 12/14] iio: proximity: sx_common: Use devm_regulator_bulk_get_enable() Jonathan Cameron
2022-10-17  6:09   ` Matti Vaittinen
2022-10-18 22:21   ` Stephen Boyd
2022-10-16 16:34 ` [PATCH 13/14] iio: pressure: ms5611: Use devm_regulator_get_enable() Jonathan Cameron
2022-10-17  6:26   ` Matti Vaittinen
2022-12-04 18:19     ` Jonathan Cameron
2022-10-17  6:26   ` Matti Vaittinen
2022-10-16 16:34 ` [PATCH 14/14] iio: pressure: ms5611: Switch to fully devm_ managed registration Jonathan Cameron
2022-10-17  6:30   ` Matti Vaittinen
2022-12-04 18:22     ` Jonathan Cameron
2022-10-17 11:27 ` [PATCH 00/14] IIO: More devm_regulator[_bulk]_get_enable() users Sa, Nuno
2022-10-23 13:03   ` Jonathan Cameron

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.