mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Sean Nyekjaer <sean@geanix.com>
To: "Jean-Baptiste Maneyrol" <jean-baptiste.maneyrol@tdk.com>,
	"Jonathan Cameron" <jic23@kernel.org>,
	"David Lechner" <dlechner@baylibre.com>,
	"Nuno Sá" <nuno.sa@analog.com>,
	"Andy Shevchenko" <andy@kernel.org>
Cc: linux-iio@vger.kernel.org, linux-kernel@vger.kernel.org,
	 Sean Nyekjaer <sean@geanix.com>
Subject: [PATCH 2/6] iio: imu: inv_icm42600: Use devm_regulator_get_enable() for vdd regulator
Date: Wed, 09 Jul 2025 14:35:10 +0200	[thread overview]
Message-ID: <20250709-icm42pmreg-v1-2-3d0e793c99b2@geanix.com> (raw)
In-Reply-To: <20250709-icm42pmreg-v1-0-3d0e793c99b2@geanix.com>

The vdd regulator is not used for runtime power management, so it does
not need explicit enable/disable handling.
Use devm_regulator_get_enable() to let the regulator be managed
automatically by devm.

This simplifies the code by removing the manual enable and cleanup
logic.

Signed-off-by: Sean Nyekjaer <sean@geanix.com>
---
 drivers/iio/imu/inv_icm42600/inv_icm42600.h      |  1 -
 drivers/iio/imu/inv_icm42600/inv_icm42600_core.c | 25 ++++--------------------
 2 files changed, 4 insertions(+), 22 deletions(-)

diff --git a/drivers/iio/imu/inv_icm42600/inv_icm42600.h b/drivers/iio/imu/inv_icm42600/inv_icm42600.h
index 1430ab4f1dea5d5ba6277d74275fc44a6cd30eb8..c8b48a5c5ed0677bb35201d32934936faaf7a1a6 100644
--- a/drivers/iio/imu/inv_icm42600/inv_icm42600.h
+++ b/drivers/iio/imu/inv_icm42600/inv_icm42600.h
@@ -167,7 +167,6 @@ struct inv_icm42600_state {
 	enum inv_icm42600_chip chip;
 	const char *name;
 	struct regmap *map;
-	struct regulator *vdd_supply;
 	struct regulator *vddio_supply;
 	int irq;
 	struct iio_mount_matrix orientation;
diff --git a/drivers/iio/imu/inv_icm42600/inv_icm42600_core.c b/drivers/iio/imu/inv_icm42600/inv_icm42600_core.c
index 69496d1c1ff73132f5e7bd076d18a62c293285a2..35f7c66d77790829a739d2c54ba77e53903a9297 100644
--- a/drivers/iio/imu/inv_icm42600/inv_icm42600_core.c
+++ b/drivers/iio/imu/inv_icm42600/inv_icm42600_core.c
@@ -697,17 +697,6 @@ static int inv_icm42600_enable_regulator_vddio(struct inv_icm42600_state *st)
 	return 0;
 }
 
-static void inv_icm42600_disable_vdd_reg(void *_data)
-{
-	struct inv_icm42600_state *st = _data;
-	const struct device *dev = regmap_get_device(st->map);
-	int ret;
-
-	ret = regulator_disable(st->vdd_supply);
-	if (ret)
-		dev_err(dev, "failed to disable vdd error %d\n", ret);
-}
-
 static void inv_icm42600_disable_vddio_reg(void *_data)
 {
 	struct inv_icm42600_state *st = _data;
@@ -773,23 +762,17 @@ int inv_icm42600_core_probe(struct regmap *regmap, int chip,
 		return ret;
 	}
 
-	st->vdd_supply = devm_regulator_get(dev, "vdd");
-	if (IS_ERR(st->vdd_supply))
-		return PTR_ERR(st->vdd_supply);
+	ret = devm_regulator_get_enable(dev, "vdd");
+	if (ret)
+		return dev_err_probe(dev, ret,
+				     "Failed to get vdd regulator\n");
 
 	st->vddio_supply = devm_regulator_get(dev, "vddio");
 	if (IS_ERR(st->vddio_supply))
 		return PTR_ERR(st->vddio_supply);
 
-	ret = regulator_enable(st->vdd_supply);
-	if (ret)
-		return ret;
 	msleep(INV_ICM42600_POWER_UP_TIME_MS);
 
-	ret = devm_add_action_or_reset(dev, inv_icm42600_disable_vdd_reg, st);
-	if (ret)
-		return ret;
-
 	ret = inv_icm42600_enable_regulator_vddio(st);
 	if (ret)
 		return ret;

-- 
2.50.0


  parent reply	other threads:[~2025-07-09 12:35 UTC|newest]

Thread overview: 29+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-07-09 12:35 [PATCH 0/6] iio: imu: inv_icm42600: pm_runtime fixes + various changes Sean Nyekjaer
2025-07-09 12:35 ` [PATCH 1/6] iio: imu: inv_icm42600: Use inv_icm42600_disable_vddio_reg() Sean Nyekjaer
2025-07-13 14:17   ` Jonathan Cameron
2025-07-09 12:35 ` Sean Nyekjaer [this message]
2025-07-13 14:19   ` [PATCH 2/6] iio: imu: inv_icm42600: Use devm_regulator_get_enable() for vdd regulator Jonathan Cameron
2025-07-09 12:35 ` [PATCH 3/6] iio: imu: inv_icm42600: Remove redundant error msg on regulator_disable() Sean Nyekjaer
2025-07-10  9:03   ` Andy Shevchenko
2025-07-10 10:47     ` Sean Nyekjaer
2025-07-10 13:07       ` Andy Shevchenko
2025-07-13 14:22   ` Jonathan Cameron
2025-07-09 12:35 ` [PATCH 4/6] iio: imu: inv_icm42600: Simplify pm_runtime setup Sean Nyekjaer
2025-07-10  9:08   ` Andy Shevchenko
2025-07-10 10:45     ` Sean Nyekjaer
2025-07-10 12:23       ` Andy Shevchenko
2025-07-13 14:28   ` Jonathan Cameron
2025-07-14  7:24     ` Sean Nyekjaer
2025-07-14  7:42       ` Sean Nyekjaer
2025-07-16  8:00         ` Jonathan Cameron
2025-07-18  6:40           ` Sean Nyekjaer
2025-07-19 11:47             ` Jonathan Cameron
2025-07-19 13:32               ` Jonathan Cameron
2025-08-08 13:42                 ` Sean Nyekjaer
2025-07-09 12:35 ` [PATCH 5/6] iio: imu: inv_icm42600: Drop redundant pm_runtime reinitialization in resume Sean Nyekjaer
2025-07-09 12:35 ` [PATCH 6/6] iio: imu: inv_icm42600: Avoid configuring if already pm_runtime suspended Sean Nyekjaer
2025-07-10  9:11   ` Andy Shevchenko
2025-07-13 14:32   ` Jonathan Cameron
2025-07-14 10:15     ` Sean Nyekjaer
2025-07-16  8:06       ` Jonathan Cameron
2025-07-10  9:12 ` [PATCH 0/6] iio: imu: inv_icm42600: pm_runtime fixes + various changes Andy Shevchenko

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=20250709-icm42pmreg-v1-2-3d0e793c99b2@geanix.com \
    --to=sean@geanix.com \
    --cc=andy@kernel.org \
    --cc=dlechner@baylibre.com \
    --cc=jean-baptiste.maneyrol@tdk.com \
    --cc=jic23@kernel.org \
    --cc=linux-iio@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=nuno.sa@analog.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®