From: Andrey Skvortsov <andrej.skvortzov@gmail.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>,
linux-iio@vger.kernel.org, linux-kernel@vger.kernel.org,
"Jonathan Marek" <jonathan@marek.ca>,
"Brian Masney" <masneyb@onstation.org>,
"Rob Herring" <robh@kernel.org>
Cc: Andrey Skvortsov <andrej.skvortzov@gmail.com>
Subject: [PATCH v4 3/3] iio: imu: inv_mpu6050: control vdd supply using devm-helpers
Date: Fri, 5 Jun 2026 12:09:40 +0300 [thread overview]
Message-ID: <20260605090940.1103750-4-andrej.skvortzov@gmail.com> (raw)
In-Reply-To: <20260605090940.1103750-1-andrej.skvortzov@gmail.com>
vdd supply will be automatically disabled on error condition during a
probe and on driver cleanup.
Signed-off-by: Andrey Skvortsov <andrej.skvortzov@gmail.com>
---
Changes in v4:
- no actual changes
Changes in v3:
- no dead code in inv_mpu_core_disable_regulator_action anymore since st variable
is used to get 'struct device' now
drivers/iio/imu/inv_mpu6050/inv_mpu_core.c | 23 ++++------------------
drivers/iio/imu/inv_mpu6050/inv_mpu_iio.h | 1 -
2 files changed, 4 insertions(+), 20 deletions(-)
diff --git a/drivers/iio/imu/inv_mpu6050/inv_mpu_core.c b/drivers/iio/imu/inv_mpu6050/inv_mpu_core.c
index 6fd35ea5daabb..c170efce7d31c 100644
--- a/drivers/iio/imu/inv_mpu6050/inv_mpu_core.c
+++ b/drivers/iio/imu/inv_mpu6050/inv_mpu_core.c
@@ -1863,12 +1863,6 @@ static void inv_mpu_core_disable_regulator_action(void *_data)
{
struct inv_mpu6050_state *st = _data;
struct device *dev = regmap_get_device(st->map);
- int result;
-
- result = regulator_disable(st->vdd_supply);
- if (result)
- dev_err(regmap_get_device(st->map),
- "Failed to disable vdd regulator: %d\n", result);
if (!pm_runtime_status_suspended(dev))
inv_mpu_core_disable_regulator_vddio(st);
@@ -1948,21 +1942,14 @@ int inv_mpu_core_probe(struct regmap *regmap, int irq, const char *name,
device_set_wakeup_capable(dev, true);
- st->vdd_supply = devm_regulator_get(dev, "vdd");
- if (IS_ERR(st->vdd_supply))
- return dev_err_probe(dev, PTR_ERR(st->vdd_supply),
- "Failed to get vdd regulator\n");
-
st->vddio_supply = devm_regulator_get(dev, "vddio");
if (IS_ERR(st->vddio_supply))
return dev_err_probe(dev, PTR_ERR(st->vddio_supply),
"Failed to get vddio regulator\n");
- result = regulator_enable(st->vdd_supply);
- if (result) {
- dev_err(dev, "Failed to enable vdd regulator: %d\n", result);
- return result;
- }
+ result = devm_regulator_get_enable(dev, "vdd");
+ if (result)
+ return dev_err_probe(dev, result, "Failed to enable vdd regulator\n");
msleep(INV_MPU6050_POWER_UP_TIME);
/* set pm_runtime active early for disable vddio resource cleanup */
@@ -1971,10 +1958,8 @@ int inv_mpu_core_probe(struct regmap *regmap, int irq, const char *name,
return result;
result = inv_mpu_core_enable_regulator_vddio(st);
- if (result) {
- regulator_disable(st->vdd_supply);
+ if (result)
return result;
- }
result = devm_add_action_or_reset(dev, inv_mpu_core_disable_regulator_action,
st);
diff --git a/drivers/iio/imu/inv_mpu6050/inv_mpu_iio.h b/drivers/iio/imu/inv_mpu6050/inv_mpu_iio.h
index 6239b1a803f77..2c0cf53c9a627 100644
--- a/drivers/iio/imu/inv_mpu6050/inv_mpu_iio.h
+++ b/drivers/iio/imu/inv_mpu6050/inv_mpu_iio.h
@@ -206,7 +206,6 @@ struct inv_mpu6050_state {
u8 irq_mask;
unsigned skip_samples;
struct inv_sensors_timestamp timestamp;
- struct regulator *vdd_supply;
struct regulator *vddio_supply;
bool magn_disabled;
s32 magn_raw_to_gauss[3];
--
2.53.0
next prev parent reply other threads:[~2026-06-05 9:10 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-06-05 9:09 [PATCH v4 0/3] iio: imu: inv_mpu6050: runtime pm fixes Andrey Skvortsov
2026-06-05 9:09 ` [PATCH v4 1/3] iio: imu: inv_mpu6050: fix unbalanced regulator_disable() calls, when probe fails Andrey Skvortsov
2026-06-05 9:09 ` [PATCH v4 2/3] iio: imu: inv_mpu6050: use devres-enabled version of pm_runtime_enable() Andrey Skvortsov
2026-06-05 9:09 ` Andrey Skvortsov [this message]
2026-06-14 18:57 ` [PATCH v4 0/3] iio: imu: inv_mpu6050: runtime pm fixes 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=20260605090940.1103750-4-andrej.skvortzov@gmail.com \
--to=andrej.skvortzov@gmail.com \
--cc=andy@kernel.org \
--cc=dlechner@baylibre.com \
--cc=jean-baptiste.maneyrol@tdk.com \
--cc=jic23@kernel.org \
--cc=jonathan@marek.ca \
--cc=linux-iio@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=masneyb@onstation.org \
--cc=nuno.sa@analog.com \
--cc=robh@kernel.org \
/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®