lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20250813225840.576305-5-afd@ti.com>
Date: Wed, 13 Aug 2025 17:58:39 -0500
From: Andrew Davis <afd@...com>
To: Jonathan Cameron <jic23@...nel.org>,
        David Lechner
	<dlechner@...libre.com>,
        Nuno Sá <nuno.sa@...log.com>,
        Andy Shevchenko <andy@...nel.org>
CC: <linux-iio@...r.kernel.org>, <linux-kernel@...r.kernel.org>,
        Andrew Davis
	<afd@...com>
Subject: [PATCH 5/6] iio: health: afe4404: Use devm_regulator_get_enable() helper

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@...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


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ