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-2-afd@ti.com>
Date: Wed, 13 Aug 2025 17:58:36 -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 2/6] iio: health: afe4403: 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/afe4403.c | 33 +--------------------------------
 1 file changed, 1 insertion(+), 32 deletions(-)

diff --git a/drivers/iio/health/afe4403.c b/drivers/iio/health/afe4403.c
index 99bf1bcbea40d..f9759f855c534 100644
--- a/drivers/iio/health/afe4403.c
+++ b/drivers/iio/health/afe4403.c
@@ -61,7 +61,6 @@ static const struct reg_field afe4403_reg_fields[] = {
  * @spi: SPI device handle
  * @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 data layout to push into IIO buffer.
@@ -70,7 +69,6 @@ struct afe4403_data {
 	struct spi_device *spi;
 	struct regmap *regmap;
 	struct regmap_field *fields[F_MAX_FIELDS];
-	struct regulator *regulator;
 	struct iio_trigger *trig;
 	int irq;
 	/* Ensure suitable alignment for timestamp */
@@ -343,13 +341,6 @@ static irqreturn_t afe4403_trigger_handler(int irq, void *private)
 	return IRQ_HANDLED;
 }
 
-static void afe4403_regulator_disable(void *data)
-{
-	struct regulator *regulator = data;
-
-	regulator_disable(regulator);
-}
-
 #define AFE4403_TIMING_PAIRS			\
 	{ AFE440X_LED2STC,	0x000050 },	\
 	{ AFE440X_LED2ENDC,	0x0003e7 },	\
@@ -424,12 +415,6 @@ static int afe4403_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;
 }
 
@@ -439,12 +424,6 @@ static int afe4403_resume(struct device *dev)
 	struct afe4403_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)
@@ -488,21 +467,11 @@ static int afe4403_probe(struct spi_device *spi)
 		}
 	}
 
-	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);
+	ret = devm_regulator_get_enable(dev, "tx_sup");
 	if (ret) {
 		dev_err(dev, "Unable to enable regulator\n");
 		return ret;
 	}
-	ret = devm_add_action_or_reset(dev, afe4403_regulator_disable, afe->regulator);
-	if (ret) {
-		dev_err(dev, "Unable to add regulator disable action\n");
-		return ret;
-	}
 
 	ret = regmap_write(afe->regmap, AFE440X_CONTROL0,
 			   AFE440X_CONTROL0_SW_RESET);
-- 
2.39.2


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ