All of lore.kernel.org
 help / color / mirror / Atom feed
From: Jonathan Cameron <jic23@kernel.org>
To: linux-iio@vger.kernel.org
Cc: Matti Vaittinen <mazziesaccount@gmail.com>,
	Matti Vaittinen <matti.vaittinen@fi.rohmeurope.com>,
	Cosmin Tanislav <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>,
	Michael Hennerich <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 02/14] iio: accel: bma400: Use devm_regulator_bulk_get_enable()
Date: Sun, 16 Oct 2022 17:33:57 +0100	[thread overview]
Message-ID: <20221016163409.320197-3-jic23@kernel.org> (raw)
In-Reply-To: <20221016163409.320197-1-jic23@kernel.org>

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


  parent reply	other threads:[~2022-10-16 16:34 UTC|newest]

Thread overview: 39+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
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 ` Jonathan Cameron [this message]
2022-10-17  5:27   ` [PATCH 02/14] iio: accel: bma400: " 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

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20221016163409.320197-3-jic23@kernel.org \
    --to=jic23@kernel.org \
    --cc=DDRokosov@sberdevices.ru \
    --cc=Jonathan.Cameron@huawei.com \
    --cc=andriy.shevchenko@linux.intel.com \
    --cc=cosmin.tanislav@analog.com \
    --cc=gwendal@chromium.org \
    --cc=jagathjog1996@gmail.com \
    --cc=linus.walleij@linaro.org \
    --cc=linux-iio@vger.kernel.org \
    --cc=lorenzo@kernel.org \
    --cc=martyn.welch@collabora.com \
    --cc=matti.vaittinen@fi.rohmeurope.com \
    --cc=mazziesaccount@gmail.com \
    --cc=michael.hennerich@analog.com \
    --cc=sean@geanix.com \
    --cc=swboyd@chromium.org \
    --cc=tduszyns@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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.