All of lore.kernel.org
 help / color / mirror / Atom feed
From: Andrew Davis <afd@ti.com>
To: "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>,
	Andrew Davis <afd@ti.com>
Subject: [PATCH 5/6] iio: health: afe4404: Use devm_regulator_get_enable() helper
Date: Wed, 13 Aug 2025 17:58:39 -0500	[thread overview]
Message-ID: <20250813225840.576305-5-afd@ti.com> (raw)
In-Reply-To: <20250813225840.576305-1-afd@ti.com>

This takes care of both getting and enabling the regulator in one
function, it also handles the devm action, so remove that. Also
do not disable the regulator on suspend, this will be handled for
us. We now do not need to track the regulator at all, so drop it
from the device struct.

Signed-off-by: Andrew Davis <afd@ti.com>
---
 drivers/iio/health/afe4404.c | 33 +--------------------------------
 1 file changed, 1 insertion(+), 32 deletions(-)

diff --git a/drivers/iio/health/afe4404.c b/drivers/iio/health/afe4404.c
index 29e030943f599..19dd821155dd4 100644
--- a/drivers/iio/health/afe4404.c
+++ b/drivers/iio/health/afe4404.c
@@ -79,7 +79,6 @@ static const struct reg_field afe4404_reg_fields[] = {
  * struct afe4404_data - AFE4404 device instance data
  * @regmap: Register map of the device
  * @fields: Register fields of the device
- * @regulator: Pointer to the regulator for the IC
  * @trig: IIO trigger for this device
  * @irq: ADC_RDY line interrupt number
  * @buffer: Used to construct a scan to push to the iio buffer.
@@ -87,7 +86,6 @@ static const struct reg_field afe4404_reg_fields[] = {
 struct afe4404_data {
 	struct regmap *regmap;
 	struct regmap_field *fields[F_MAX_FIELDS];
-	struct regulator *regulator;
 	struct iio_trigger *trig;
 	int irq;
 	s32 buffer[10] __aligned(8);
@@ -346,13 +344,6 @@ static irqreturn_t afe4404_trigger_handler(int irq, void *private)
 	return IRQ_HANDLED;
 }
 
-static void afe4404_regulator_disable(void *data)
-{
-	struct regulator *regulator = data;
-
-	regulator_disable(regulator);
-}
-
 /* Default timings from data-sheet */
 #define AFE4404_TIMING_PAIRS			\
 	{ AFE440X_PRPCOUNT,	39999	},	\
@@ -432,12 +423,6 @@ static int afe4404_suspend(struct device *dev)
 	if (ret)
 		return ret;
 
-	ret = regulator_disable(afe->regulator);
-	if (ret) {
-		dev_err(dev, "Unable to disable regulator\n");
-		return ret;
-	}
-
 	return 0;
 }
 
@@ -447,12 +432,6 @@ static int afe4404_resume(struct device *dev)
 	struct afe4404_data *afe = iio_priv(indio_dev);
 	int ret;
 
-	ret = regulator_enable(afe->regulator);
-	if (ret) {
-		dev_err(dev, "Unable to enable regulator\n");
-		return ret;
-	}
-
 	ret = regmap_clear_bits(afe->regmap, AFE440X_CONTROL2,
 				AFE440X_CONTROL2_PDN_AFE);
 	if (ret)
@@ -495,17 +474,7 @@ static int afe4404_probe(struct i2c_client *client)
 		}
 	}
 
-	afe->regulator = devm_regulator_get(dev, "tx_sup");
-	if (IS_ERR(afe->regulator))
-		return dev_err_probe(dev, PTR_ERR(afe->regulator),
-				     "Unable to get regulator\n");
-
-	ret = regulator_enable(afe->regulator);
-	if (ret) {
-		dev_err(dev, "Unable to enable regulator\n");
-		return ret;
-	}
-	ret = devm_add_action_or_reset(dev, afe4404_regulator_disable, afe->regulator);
+	ret = devm_regulator_get_enable(dev, "tx_sup");
 	if (ret) {
 		dev_err(dev, "Unable to enable regulator\n");
 		return ret;
-- 
2.39.2


  parent reply	other threads:[~2025-08-13 22:58 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-08-13 22:58 [PATCH 1/6] iio: health: afe4403: Do not store dev pointer in device struct Andrew Davis
2025-08-13 22:58 ` [PATCH 2/6] iio: health: afe4403: Use devm_regulator_get_enable() helper Andrew Davis
2025-08-13 23:12   ` David Lechner
2025-09-13 14:20     ` Jonathan Cameron
2025-09-15 12:13       ` Andrew Davis
2025-08-13 22:58 ` [PATCH 3/6] iio: health: afe4403: Use dev_err_probe() helper Andrew Davis
2025-08-13 22:58 ` [PATCH 4/6] iio: health: afe4404: Do not store dev pointer in device struct Andrew Davis
2025-08-16 12:55   ` Jonathan Cameron
2025-08-13 22:58 ` Andrew Davis [this message]
2025-08-13 22:58 ` [PATCH 6/6] iio: health: afe4404: Use dev_err_probe() helper Andrew Davis
2025-08-16 12:53 ` [PATCH 1/6] iio: health: afe4403: Do not store dev pointer in device struct Jonathan Cameron
2025-08-20 14:45 ` 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=20250813225840.576305-5-afd@ti.com \
    --to=afd@ti.com \
    --cc=andy@kernel.org \
    --cc=dlechner@baylibre.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 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.