Skip to contentSkip to conversation

ti-ads7950: fix gpio handling and facelift

PATCH Applied Dmitry Torokhov 4 participants 23 messages Mar 5 – Mar 9

Subsystems (2)

v3 of 5 Applied Latest is v5 →

lore
Share & tools
lore
#0 lore raw

v3 cover ti-ads7950: fix gpio handling and facelift

The original reason for this series is to make sure ti_ads7950_get() returns result in range [0, 1] or a negative error code to comply with gpiolib requirement.

During review David noticed the fact that the function also clobbers gpio state. Fixing that lead to adding cleanups using guard() and devm.

v3:

- Added "Fixes" tags
- Picked up reviewed-by tags for #1 and #2
- Dropped the conversion to "error" variables
- Avoid using scoped_guard (per David)
- directly return results of function calls at the end of function (David)
- Split spi_sync() error handling into a new patxch (Andy)
- Switch to using devm_regulator_get_enable_read_voltage() (David)

v2:

- style fixes in #1 (per David)
- fix to not clobber state (#2, new)
- #3 and #4 (new)

---
Dmitry Torokhov (6):
iio: adc: ti-ads7950: normalize return value of gpio_get
iio: adc: ti-ads7950: do not clobber gpio state in ti_ads7950_get()
iio: adc: ti-ads7950: switch to using guard() notation
iio: adc: ti-ads7950: simplify check for spi_setup() failures
iio: adc: ti-ads7950: switch to using devm_regulator_get_enable_read_voltage()
iio: adc: ti-ads7950: complete conversion to using managed resources

 drivers/iio/adc/ti-ads7950.c | 188 ++++++++++++++-----------------------------
 1 file changed, 59 insertions(+), 129 deletions(-)

---
base-commit: c025f6cf4209e1542ec2afebe49f42bbaf1a5c7b
change-id: 20260220-ti-ads7950-facelift-ad8b5390a654

Thanks.

Signature · 1 line
Dmitry
#1 lore raw

PATCH v3 1/6 iio: adc: ti-ads7950: normalize return value of gpio_get

The GPIO get callback is expected to return 0 or 1 (or a negative error code). Ensure that the value returned by ti_ads7950_get() for output pins is normalized to the [0, 1] range.

Fixes 86ef402d805d ("gpiolib: sanitize the return value of gpio_chip::get()")
---
 drivers/iio/adc/ti-ads7950.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/iio/adc/ti-ads7950.c +1 -1
index bbe1ce577789..b8cc39fc39fb 100644
@@ -433,7 +433,7 @@ static int ti_ads7950_get(struct gpio_chip *chip, unsigned int offset)
 
 	/* If set as output, return the output */
 	if (st->gpio_cmd_settings_bitmask & BIT(offset)) {
-		ret = st->cmd_settings_bitmask & BIT(offset);
+		ret = (st->cmd_settings_bitmask & BIT(offset)) ? 1 : 0;
 		goto out;
 	}
 
Signature · 1 line
2.53.0.473.g4a7958ca14-goog
#2 lore raw

PATCH v3 2/6 iio: adc: ti-ads7950: do not clobber gpio state in ti_ads7950_get()

In reply to Dmitry Torokhov

GPIO state was inadvertently overwritten by the result of spi_sync(), resulting in ti_ads7950_get() only returning 0 as GPIO state (or error).

Fix this by introducing a separate variable to hold the state.

Fixes c97dce792dc8 ("iio: adc: ti-ads7950: add GPIO support")
---
 drivers/iio/adc/ti-ads7950.c | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)
drivers/iio/adc/ti-ads7950.c +5 -3
index b8cc39fc39fb..cdc624889559 100644
@@ -427,13 +427,15 @@ static int ti_ads7950_set(struct gpio_chip *chip, unsigned int offset,
 static int ti_ads7950_get(struct gpio_chip *chip, unsigned int offset)
 {
 	struct ti_ads7950_state *st = gpiochip_get_data(chip);
+	bool state;
 	int ret;
 
 	mutex_lock(&st->slock);
 
 	/* If set as output, return the output */
 	if (st->gpio_cmd_settings_bitmask & BIT(offset)) {
-		ret = (st->cmd_settings_bitmask & BIT(offset)) ? 1 : 0;
+		state = st->cmd_settings_bitmask & BIT(offset);
+		ret = 0;
 		goto out;
 	}
 
@@ -444,7 +446,7 @@ static int ti_ads7950_get(struct gpio_chip *chip, unsigned int offset)
 	if (ret)
 		goto out;
 
-	ret = ((st->single_rx >> 12) & BIT(offset)) ? 1 : 0;
+	state = (st->single_rx >> 12) & BIT(offset);
 
 	/* Revert back to original settings */
 	st->cmd_settings_bitmask &= ~TI_ADS7950_CR_GPIO_DATA;
@@ -456,7 +458,7 @@ static int ti_ads7950_get(struct gpio_chip *chip, unsigned int offset)
 out:
 	mutex_unlock(&st->slock);
 
-	return ret;
+	return ret ?: state;
 }
 
 static int ti_ads7950_get_direction(struct gpio_chip *chip,
Signature · 1 line
2.53.0.473.g4a7958ca14-goog
#3 lore raw

PATCH v3 3/6 iio: adc: ti-ads7950: switch to using guard() notation

In reply to Dmitry Torokhov

guard() notation allows early returns when encountering errors, making control flow more obvious. Use it.

---
 drivers/iio/adc/ti-ads7950.c | 75 ++++++++++++++++----------------------------
 1 file changed, 27 insertions(+), 48 deletions(-)
drivers/iio/adc/ti-ads7950.c +27 -48
index cdc624889559..1515089dd759 100644
@@ -308,16 +308,17 @@ static irqreturn_t ti_ads7950_trigger_handler(int irq, void *p)
 	struct ti_ads7950_state *st = iio_priv(indio_dev);
 	int ret;
 
-	mutex_lock(&st->slock);
-	ret = spi_sync(st->spi, &st->ring_msg);
-	if (ret < 0)
-		goto out;
+	do {
+		guard(mutex)(&st->slock);
 
-	iio_push_to_buffers_with_timestamp(indio_dev, &st->rx_buf[2],
-					   iio_get_time_ns(indio_dev));
+		ret = spi_sync(st->spi, &st->ring_msg);
+		if (ret)
+			break;
+
+		iio_push_to_buffers_with_timestamp(indio_dev, &st->rx_buf[2],
+						   iio_get_time_ns(indio_dev));
+	} while (0);
 
-out:
-	mutex_unlock(&st->slock);
 	iio_trigger_notify_done(indio_dev->trig);
 
 	return IRQ_HANDLED;
@@ -328,20 +329,16 @@ static int ti_ads7950_scan_direct(struct iio_dev *indio_dev, unsigned int ch)
 	struct ti_ads7950_state *st = iio_priv(indio_dev);
 	int ret, cmd;
 
-	mutex_lock(&st->slock);
+	guard(mutex)(&st->slock);
+
 	cmd = TI_ADS7950_MAN_CMD(TI_ADS7950_CR_CHAN(ch));
 	st->single_tx = cmd;
 
 	ret = spi_sync(st->spi, &st->scan_single_msg);
 	if (ret)
-		goto out;
-
-	ret = st->single_rx;
-
-out:
-	mutex_unlock(&st->slock);
+		return ret;
 
-	return ret;
+	return st->single_rx;
 }
 
 static int ti_ads7950_get_range(struct ti_ads7950_state *st)
@@ -407,9 +404,8 @@ static int ti_ads7950_set(struct gpio_chip *chip, unsigned int offset,
 			  int value)
 {
 	struct ti_ads7950_state *st = gpiochip_get_data(chip);
-	int ret;
 
-	mutex_lock(&st->slock);
+	guard(mutex)(&st->slock);
 
 	if (value)
 		st->cmd_settings_bitmask |= BIT(offset);
@@ -417,11 +413,8 @@ static int ti_ads7950_set(struct gpio_chip *chip, unsigned int offset,
 		st->cmd_settings_bitmask &= ~BIT(offset);
 
 	st->single_tx = TI_ADS7950_MAN_CMD_SETTINGS(st);
-	ret = spi_sync(st->spi, &st->scan_single_msg);
-
-	mutex_unlock(&st->slock);
 
-	return ret;
+	return spi_sync(st->spi, &st->scan_single_msg);
 }
 
 static int ti_ads7950_get(struct gpio_chip *chip, unsigned int offset)
@@ -430,13 +423,12 @@ static int ti_ads7950_get(struct gpio_chip *chip, unsigned int offset)
 	bool state;
 	int ret;
 
-	mutex_lock(&st->slock);
+	guard(mutex)(&st->slock);
 
 	/* If set as output, return the output */
 	if (st->gpio_cmd_settings_bitmask & BIT(offset)) {
 		state = st->cmd_settings_bitmask & BIT(offset);
-		ret = 0;
-		goto out;
+		return state;
 	}
 
 	/* GPIO data bit sets SDO bits 12-15 to GPIO input */
@@ -444,7 +436,7 @@ static int ti_ads7950_get(struct gpio_chip *chip, unsigned int offset)
 	st->single_tx = TI_ADS7950_MAN_CMD_SETTINGS(st);
 	ret = spi_sync(st->spi, &st->scan_single_msg);
 	if (ret)
-		goto out;
+		return ret;
 
 	state = (st->single_rx >> 12) & BIT(offset);
 
@@ -453,12 +445,9 @@ static int ti_ads7950_get(struct gpio_chip *chip, unsigned int offset)
 	st->single_tx = TI_ADS7950_MAN_CMD_SETTINGS(st);
 	ret = spi_sync(st->spi, &st->scan_single_msg);
 	if (ret)
-		goto out;
-
-out:
-	mutex_unlock(&st->slock);
+		return ret;
 
-	return ret ?: state;
+	return state;
 }
 
 static int ti_ads7950_get_direction(struct gpio_chip *chip,
@@ -474,9 +463,8 @@ static int _ti_ads7950_set_direction(struct gpio_chip *chip, int offset,
 				     int input)
 {
 	struct ti_ads7950_state *st = gpiochip_get_data(chip);
-	int ret = 0;
 
-	mutex_lock(&st->slock);
+	guard(mutex)(&st->slock);
 
 	/* Only change direction if needed */
 	if (input && (st->gpio_cmd_settings_bitmask & BIT(offset)))
@@ -484,15 +472,11 @@ static int _ti_ads7950_set_direction(struct gpio_chip *chip, int offset,
 	else if (!input && !(st->gpio_cmd_settings_bitmask & BIT(offset)))
 		st->gpio_cmd_settings_bitmask |= BIT(offset);
 	else
-		goto out;
+		return 0;
 
 	st->single_tx = TI_ADS7950_GPIO_CMD_SETTINGS(st);
-	ret = spi_sync(st->spi, &st->scan_single_msg);
 
-out:
-	mutex_unlock(&st->slock);
-
-	return ret;
+	return spi_sync(st->spi, &st->scan_single_msg);
 }
 
 static int ti_ads7950_direction_input(struct gpio_chip *chip,
@@ -515,9 +499,9 @@ static int ti_ads7950_direction_output(struct gpio_chip *chip,
 
 static int ti_ads7950_init_hw(struct ti_ads7950_state *st)
 {
-	int ret = 0;
+	int ret;
 
-	mutex_lock(&st->slock);
+	guard(mutex)(&st->slock);
 
 	/* Settings for Manual/Auto1/Auto2 commands */
 	/* Default to 5v ref */
@@ -525,17 +509,12 @@ static int ti_ads7950_init_hw(struct ti_ads7950_state *st)
 	st->single_tx = TI_ADS7950_MAN_CMD_SETTINGS(st);
 	ret = spi_sync(st->spi, &st->scan_single_msg);
 	if (ret)
-		goto out;
+		return ret;
 
 	/* Settings for GPIO command */
 	st->gpio_cmd_settings_bitmask = 0x0;
 	st->single_tx = TI_ADS7950_GPIO_CMD_SETTINGS(st);
-	ret = spi_sync(st->spi, &st->scan_single_msg);
-
-out:
-	mutex_unlock(&st->slock);
-
-	return ret;
+	return spi_sync(st->spi, &st->scan_single_msg);
 }
 
 static int ti_ads7950_probe(struct spi_device *spi)
Signature · 1 line
2.53.0.473.g4a7958ca14-goog
#5 lore raw

PATCH v3 4/6 iio: adc: ti-ads7950: simplify check for spi_setup() failures

In reply to Dmitry Torokhov

spi_setup() specifies that it returns 0 on success or negative error on failure. Therefore we can simply check for the return code being 0 or not.

---
 drivers/iio/adc/ti-ads7950.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/iio/adc/ti-ads7950.c +1 -1
index 1515089dd759..273c35e03185 100644
@@ -527,7 +527,7 @@ static int ti_ads7950_probe(struct spi_device *spi)
 	spi->bits_per_word = 16;
 	spi->mode |= SPI_CS_WORD;
 	ret = spi_setup(spi);
-	if (ret < 0) {
+	if (ret) {
 		dev_err(&spi->dev, "Error in spi setup\n");
 		return ret;
 	}
Signature · 1 line
2.53.0.473.g4a7958ca14-goog
maintainer
#6 lore raw

Re: [PATCH v3 4/6] iio: adc: ti-ads7950: simplify check for spi_setup() failures

Quoted 14 lines · On Thu, 05 Mar 2026 11:21:55 -0800 Dmitry Torokhov <[email protected]>…

spi_setup() specifies that it returns 0 on success or negative error on failure. Therefore we can simply check for the return code being 0 or not.

---
 drivers/iio/adc/ti-ads7950.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/iio/adc/ti-ads7950.c +0 -0
index 1515089dd759..273c35e03185 100644

drivers/iio/adc/ti-ads7950.c static int ti_ads7950_probe(struct spi_device *spi) · line 530

Quoted 4 lines
drivers/iio/adc/ti-ads7950.c +0 -1
@@ -527,7 +527,7 @@ static int ti_ads7950_probe(struct spi_device *spi)
 	spi->bits_per_word = 16;
 	spi->mode |= SPI_CS_WORD;
 	ret = spi_setup(spi);
-	if (ret < 0) {

Given it doesn't really fit better in patch 6 than it does here maybe drag the

	if (ret)
		return dev_err_probe();

here instead just to avoid tiny it of churn around brackets.

Not important though.

Quoted 5 lines
drivers/iio/adc/ti-ads7950.c +1 -0
+	if (ret) {
 		dev_err(&spi->dev, "Error in spi setup\n");
 		return ret;
 	}
#8 lore raw

PATCH v3 5/6 iio: adc: ti-ads7950: switch to using devm_regulator_get_enable_read_voltage()

In reply to Dmitry Torokhov

The regulator is enabled for the entire time the driver is bound to the device, and we only need to access it to fetch voltage, which can be done at probe time.

Switch to using devm_regulator_get_enable_read_voltage() which simplifies probing and unbinding code.

---
 drivers/iio/adc/ti-ads7950.c | 45 +++++++++++---------------------------------
 1 file changed, 11 insertions(+), 34 deletions(-)
drivers/iio/adc/ti-ads7950.c +11 -34
index 273c35e03185..847e83baa876 100644
@@ -341,19 +341,9 @@ static int ti_ads7950_scan_direct(struct iio_dev *indio_dev, unsigned int ch)
 	return st->single_rx;
 }
 
-static int ti_ads7950_get_range(struct ti_ads7950_state *st)
+static unsigned int ti_ads7950_get_range(struct ti_ads7950_state *st)
 {
-	int vref;
-
-	if (st->vref_mv) {
-		vref = st->vref_mv;
-	} else {
-		vref = regulator_get_voltage(st->reg);
-		if (vref < 0)
-			return vref;
-
-		vref /= 1000;
-	}
+	unsigned int vref = st->vref_mv;
 
 	if (st->cmd_settings_bitmask & TI_ADS7950_CR_RANGE_5V)
 		vref *= 2;
@@ -382,11 +372,7 @@ static int ti_ads7950_read_raw(struct iio_dev *indio_dev,
 
 		return IIO_VAL_INT;
 	case IIO_CHAN_INFO_SCALE:
-		ret = ti_ads7950_get_range(st);
-		if (ret < 0)
-			return ret;
-
-		*val = ret;
+		*val = ti_ads7950_get_range(st);
 		*val2 = (1 << chan->scan_type.realbits) - 1;
 
 		return IIO_VAL_FRACTIONAL;
@@ -580,30 +566,24 @@ static int ti_ads7950_probe(struct spi_device *spi)
 	spi_message_init_with_transfers(&st->scan_single_msg,
 					st->scan_single_xfer, 3);
 
+	ret = devm_regulator_get_enable_read_voltage(&spi->dev, "vref");
+	if (ret < 0)
+		return dev_err_probe(&spi->dev, ret,
+				     "Failed to get regulator \"vref\"\n");
+
 	/* Use hard coded value for reference voltage in ACPI case */
 	if (ACPI_COMPANION(&spi->dev))
 		st->vref_mv = TI_ADS7950_VA_MV_ACPI_DEFAULT;
+	else
+		st->vref_mv = ret / 1000;
 
 	mutex_init(&st->slock);
 
-	st->reg = devm_regulator_get(&spi->dev, "vref");
-	if (IS_ERR(st->reg)) {
-		ret = dev_err_probe(&spi->dev, PTR_ERR(st->reg),
-				     "Failed to get regulator \"vref\"\n");
-		goto error_destroy_mutex;
-	}
-
-	ret = regulator_enable(st->reg);
-	if (ret) {
-		dev_err(&spi->dev, "Failed to enable regulator \"vref\"\n");
-		goto error_destroy_mutex;
-	}
-
 	ret = iio_triggered_buffer_setup(indio_dev, NULL,
 					 &ti_ads7950_trigger_handler, NULL);
 	if (ret) {
 		dev_err(&spi->dev, "Failed to setup triggered buffer\n");
-		goto error_disable_reg;
+		goto error_destroy_mutex;
 	}
 
 	ret = ti_ads7950_init_hw(st);
@@ -643,8 +623,6 @@ static int ti_ads7950_probe(struct spi_device *spi)
 	iio_device_unregister(indio_dev);
 error_cleanup_ring:
 	iio_triggered_buffer_cleanup(indio_dev);
-error_disable_reg:
-	regulator_disable(st->reg);
 error_destroy_mutex:
 	mutex_destroy(&st->slock);
 
@@ -659,7 +637,6 @@ static void ti_ads7950_remove(struct spi_device *spi)
 	gpiochip_remove(&st->chip);
 	iio_device_unregister(indio_dev);
 	iio_triggered_buffer_cleanup(indio_dev);
-	regulator_disable(st->reg);
 	mutex_destroy(&st->slock);
 }
 
Signature · 1 line
2.53.0.473.g4a7958ca14-goog
maintainer
#9 lore raw

Re: [PATCH v3 5/6] iio: adc: ti-ads7950: switch to using devm_regulator_get_enable_read_voltage()

Quoted 9 lines · On Thu, 05 Mar 2026 11:21:56 -0800 Dmitry Torokhov <[email protected]>…

The regulator is enabled for the entire time the driver is bound to the device, and we only need to access it to fetch voltage, which can be done at probe time.

Switch to using devm_regulator_get_enable_read_voltage() which simplifies probing and unbinding code.

Hi.

I think this broke the ACPI case (where regulator isn't available).

Jonathan

Quoted 44 lines
---
 drivers/iio/adc/ti-ads7950.c | 45 +++++++++++---------------------------------
 1 file changed, 11 insertions(+), 34 deletions(-)
drivers/iio/adc/ti-ads7950.c +3 -17
index 273c35e03185..847e83baa876 100644
@@ -341,19 +341,9 @@ static int ti_ads7950_scan_direct(struct iio_dev *indio_dev, unsigned int ch)
 	return st->single_rx;
 }
 
-static int ti_ads7950_get_range(struct ti_ads7950_state *st)
+static unsigned int ti_ads7950_get_range(struct ti_ads7950_state *st)
 {
-	int vref;
-
-	if (st->vref_mv) {
-		vref = st->vref_mv;
-	} else {
-		vref = regulator_get_voltage(st->reg);
-		if (vref < 0)
-			return vref;
-
-		vref /= 1000;
-	}
+	unsigned int vref = st->vref_mv;
 
 	if (st->cmd_settings_bitmask & TI_ADS7950_CR_RANGE_5V)
 		vref *= 2;
@@ -382,11 +372,7 @@ static int ti_ads7950_read_raw(struct iio_dev *indio_dev,
 
 		return IIO_VAL_INT;
 	case IIO_CHAN_INFO_SCALE:
-		ret = ti_ads7950_get_range(st);
-		if (ret < 0)
-			return ret;
-
-		*val = ret;
+		*val = ti_ads7950_get_range(st);
 		*val2 = (1 << chan->scan_type.realbits) - 1;
 
 		return IIO_VAL_FRACTIONAL;

drivers/iio/adc/ti-ads7950.c static int ti_ads7950_probe(struct spi_device *spi) · line 570

Quoted 5 lines
drivers/iio/adc/ti-ads7950.c +2 -0
@@ -580,30 +566,24 @@ static int ti_ads7950_probe(struct spi_device *spi)
 	spi_message_init_with_transfers(&st->scan_single_msg,
 					st->scan_single_xfer, 3);
 
+	ret = devm_regulator_get_enable_read_voltage(&spi->dev, "vref");
+	if (ret < 0)

I think you need to check for -ENODEV and if you see than then see if the acpi route below applies. Otherwise on ACPI this will fail and we'll fail the probe.

Quoted 8 lines
drivers/iio/adc/ti-ads7950.c +5 -0
+		return dev_err_probe(&spi->dev, ret,
+				     "Failed to get regulator \"vref\"\n");
+
 	/* Use hard coded value for reference voltage in ACPI case */
 	if (ACPI_COMPANION(&spi->dev))
 		st->vref_mv = TI_ADS7950_VA_MV_ACPI_DEFAULT;
+	else
+		st->vref_mv = ret / 1000;
reviewer
#10 lore raw

Re: [PATCH v3 5/6] iio: adc: ti-ads7950: switch to using devm_regulator_get_enable_read_voltage()

Quoted 65 lines · Jonathan Cameron
Quoted 9 lines · On Thu, 05 Mar 2026 11:21:56 -0800 Dmitry Torokhov <[email protected]>…

The regulator is enabled for the entire time the driver is bound to the device, and we only need to access it to fetch voltage, which can be done at probe time.

Switch to using devm_regulator_get_enable_read_voltage() which simplifies probing and unbinding code.

Hi.

I think this broke the ACPI case (where regulator isn't available).

Jonathan

Quoted 47 lines
---
 drivers/iio/adc/ti-ads7950.c | 45 +++++++++++---------------------------------
 1 file changed, 11 insertions(+), 34 deletions(-)
drivers/iio/adc/ti-ads7950.c +3 -17
index 273c35e03185..847e83baa876 100644
@@ -341,19 +341,9 @@ static int ti_ads7950_scan_direct(struct iio_dev *indio_dev, unsigned int ch)
 	return st->single_rx;
 }
 
-static int ti_ads7950_get_range(struct ti_ads7950_state *st)
+static unsigned int ti_ads7950_get_range(struct ti_ads7950_state *st)
 {
-	int vref;
-
-	if (st->vref_mv) {
-		vref = st->vref_mv;
-	} else {
-		vref = regulator_get_voltage(st->reg);
-		if (vref < 0)
-			return vref;
-
-		vref /= 1000;
-	}
+	unsigned int vref = st->vref_mv;
 
 	if (st->cmd_settings_bitmask & TI_ADS7950_CR_RANGE_5V)
 		vref *= 2;
@@ -382,11 +372,7 @@ static int ti_ads7950_read_raw(struct iio_dev *indio_dev,
 
 		return IIO_VAL_INT;
 	case IIO_CHAN_INFO_SCALE:
-		ret = ti_ads7950_get_range(st);
-		if (ret < 0)
-			return ret;
-
-		*val = ret;
+		*val = ti_ads7950_get_range(st);
 		*val2 = (1 << chan->scan_type.realbits) - 1;
 
 		return IIO_VAL_FRACTIONAL;
@@ -580,30 +566,24 @@ static int ti_ads7950_probe(struct spi_device *spi)
 	spi_message_init_with_transfers(&st->scan_single_msg,
 					st->scan_single_xfer, 3);
 
Quoted 7 lines

drivers/iio/adc/ti-ads7950.c static int ti_ads7950_probe(struct spi_device *spi) · line 570

Quoted 2 lines
drivers/iio/adc/ti-ads7950.c +2 -0
+	ret = devm_regulator_get_enable_read_voltage(&spi->dev, "vref");
+	if (ret < 0)

I think you need to check for -ENODEV and if you see than then see if the acpi route below applies. Otherwise on ACPI this will fail and we'll fail the probe.

Or do something like:

	if (ACPI_COMPANION(&spi->dev)) {
		ret = devm_regulator_get_enable(&spi->dev, "vref");
		if (ret)
			return dev_err_probe(&spi->dev, ret,
					     "Failed to get regulator \"vref\"\n");
 		st->vref_mv = TI_ADS7950_VA_MV_ACPI_DEFAULT;
	} else {

		ret = devm_regulator_get_enable_read_voltage(&spi->dev, "vref");
		if (ret < 0)
			return dev_err_probe(&spi->dev, ret,
					     "Failed to get regulator \"vref\"\n");

		st->vref_mv = ret / 1000;
	}
Quoted 11 lines
Quoted 9 lines
drivers/iio/adc/ti-ads7950.c +5 -0
+		return dev_err_probe(&spi->dev, ret,
+				     "Failed to get regulator \"vref\"\n");
+
 	/* Use hard coded value for reference voltage in ACPI case */
 	if (ACPI_COMPANION(&spi->dev))
 		st->vref_mv = TI_ADS7950_VA_MV_ACPI_DEFAULT;
+	else
+		st->vref_mv = ret / 1000;
#11 lore raw

Re: [PATCH v3 5/6] iio: adc: ti-ads7950: switch to using devm_regulator_get_enable_read_voltage()

Quoted 8 lines · David Lechner
Quoted 7 lines · Jonathan Cameron
Quoted 4 lines · On Thu, 05 Mar 2026 11:21:56 -0800 Dmitry Torokhov <[email protected]>…

The regulator is enabled for the entire time the driver is bound to the device, and we only need to access it to fetch voltage, which can be done at probe time.

Quoted 8 lines
Quoted 8 lines
Quoted 5 lines

Switch to using devm_regulator_get_enable_read_voltage() which simplifies probing and unbinding code.

Hi.

I think this broke the ACPI case (where regulator isn't available).

Oh, you're right.

Quoted 60 lines
Quoted 50 lines

Jonathan

Quoted 47 lines
---
 drivers/iio/adc/ti-ads7950.c | 45 +++++++++++---------------------------------
 1 file changed, 11 insertions(+), 34 deletions(-)
drivers/iio/adc/ti-ads7950.c +3 -17
index 273c35e03185..847e83baa876 100644
@@ -341,19 +341,9 @@ static int ti_ads7950_scan_direct(struct iio_dev *indio_dev, unsigned int ch)
 	return st->single_rx;
 }
 
-static int ti_ads7950_get_range(struct ti_ads7950_state *st)
+static unsigned int ti_ads7950_get_range(struct ti_ads7950_state *st)
 {
-	int vref;
-
-	if (st->vref_mv) {
-		vref = st->vref_mv;
-	} else {
-		vref = regulator_get_voltage(st->reg);
-		if (vref < 0)
-			return vref;
-
-		vref /= 1000;
-	}
+	unsigned int vref = st->vref_mv;
 
 	if (st->cmd_settings_bitmask & TI_ADS7950_CR_RANGE_5V)
 		vref *= 2;
@@ -382,11 +372,7 @@ static int ti_ads7950_read_raw(struct iio_dev *indio_dev,
 
 		return IIO_VAL_INT;
 	case IIO_CHAN_INFO_SCALE:
-		ret = ti_ads7950_get_range(st);
-		if (ret < 0)
-			return ret;
-
-		*val = ret;
+		*val = ti_ads7950_get_range(st);
 		*val2 = (1 << chan->scan_type.realbits) - 1;
 
 		return IIO_VAL_FRACTIONAL;
@@ -580,30 +566,24 @@ static int ti_ads7950_probe(struct spi_device *spi)
 	spi_message_init_with_transfers(&st->scan_single_msg,
 					st->scan_single_xfer, 3);
 
Quoted 7 lines

drivers/iio/adc/ti-ads7950.c static int ti_ads7950_probe(struct spi_device *spi) · line 570

Quoted 2 lines
drivers/iio/adc/ti-ads7950.c +2 -0
+	ret = devm_regulator_get_enable_read_voltage(&spi->dev, "vref");
+	if (ret < 0)

I think you need to check for -ENODEV and if you see than then see if the acpi route below applies. Otherwise on ACPI this will fail and we'll fail the probe.

Or do something like:

Quoted 7 lines
	if (ACPI_COMPANION(&spi->dev)) {
		ret = devm_regulator_get_enable(&spi->dev, "vref");
		if (ret)
			return dev_err_probe(&spi->dev, ret,
					     "Failed to get regulator \"vref\"\n");

st->vref_mv = TI_ADS7950_VA_MV_ACPI_DEFAULT;

We know that concept of regulators is not exposed on ACPI systems, and we'd get a dummy here, so maybe just store st->vref_mv and not bother with acquiring and enabling the dummy regulator?

Thanks.

Signature · 1 line
Dmitry
reviewer
#12 lore raw

Re: [PATCH v3 5/6] iio: adc: ti-ads7950: switch to using devm_regulator_get_enable_read_voltage()

Quoted 86 lines · Dmitry Torokhov
Quoted 8 lines · David Lechner
Quoted 7 lines · Jonathan Cameron
Quoted 4 lines · On Thu, 05 Mar 2026 11:21:56 -0800 Dmitry Torokhov <[email protected]>…

The regulator is enabled for the entire time the driver is bound to the device, and we only need to access it to fetch voltage, which can be done at probe time.

Quoted 8 lines
Quoted 8 lines
Quoted 5 lines

Switch to using devm_regulator_get_enable_read_voltage() which simplifies probing and unbinding code.

Hi.

I think this broke the ACPI case (where regulator isn't available).

Oh, you're right.

Quoted 66 lines
Quoted 50 lines

Jonathan

Quoted 47 lines
---
 drivers/iio/adc/ti-ads7950.c | 45 +++++++++++---------------------------------
 1 file changed, 11 insertions(+), 34 deletions(-)
drivers/iio/adc/ti-ads7950.c +3 -17
index 273c35e03185..847e83baa876 100644
@@ -341,19 +341,9 @@ static int ti_ads7950_scan_direct(struct iio_dev *indio_dev, unsigned int ch)
 	return st->single_rx;
 }
 
-static int ti_ads7950_get_range(struct ti_ads7950_state *st)
+static unsigned int ti_ads7950_get_range(struct ti_ads7950_state *st)
 {
-	int vref;
-
-	if (st->vref_mv) {
-		vref = st->vref_mv;
-	} else {
-		vref = regulator_get_voltage(st->reg);
-		if (vref < 0)
-			return vref;
-
-		vref /= 1000;
-	}
+	unsigned int vref = st->vref_mv;
 
 	if (st->cmd_settings_bitmask & TI_ADS7950_CR_RANGE_5V)
 		vref *= 2;
@@ -382,11 +372,7 @@ static int ti_ads7950_read_raw(struct iio_dev *indio_dev,
 
 		return IIO_VAL_INT;
 	case IIO_CHAN_INFO_SCALE:
-		ret = ti_ads7950_get_range(st);
-		if (ret < 0)
-			return ret;
-
-		*val = ret;
+		*val = ti_ads7950_get_range(st);
 		*val2 = (1 << chan->scan_type.realbits) - 1;
 
 		return IIO_VAL_FRACTIONAL;
@@ -580,30 +566,24 @@ static int ti_ads7950_probe(struct spi_device *spi)
 	spi_message_init_with_transfers(&st->scan_single_msg,
 					st->scan_single_xfer, 3);
 
Quoted 7 lines

drivers/iio/adc/ti-ads7950.c static int ti_ads7950_probe(struct spi_device *spi) · line 570

Quoted 2 lines
drivers/iio/adc/ti-ads7950.c +2 -0
+	ret = devm_regulator_get_enable_read_voltage(&spi->dev, "vref");
+	if (ret < 0)

I think you need to check for -ENODEV and if you see than then see if the acpi route below applies. Otherwise on ACPI this will fail and we'll fail the probe.

Or do something like:

	if (ACPI_COMPANION(&spi->dev)) {
		ret = devm_regulator_get_enable(&spi->dev, "vref");
		if (ret)
			return dev_err_probe(&spi->dev, ret,
					     "Failed to get regulator \"vref\"\n");
Quoted 8 lines
Quoted 1 line

st->vref_mv = TI_ADS7950_VA_MV_ACPI_DEFAULT;

We know that concept of regulators is not exposed on ACPI systems, and we'd get a dummy here, so maybe just store st->vref_mv and not bother with acquiring and enabling the dummy regulator?

Thanks.

Sounds OK to me.

maintainer
#13 lore raw

Re: [PATCH v3 5/6] iio: adc: ti-ads7950: switch to using devm_regulator_get_enable_read_voltage()

Quoted 89 lines · On Sat, 7 Mar 2026 12:07:40 -0600 David Lechner <[email protected]> wrote:
Quoted 88 lines · Dmitry Torokhov
Quoted 8 lines · David Lechner
Quoted 7 lines · Jonathan Cameron
Quoted 4 lines · On Thu, 05 Mar 2026 11:21:56 -0800 Dmitry Torokhov <[email protected]>…

The regulator is enabled for the entire time the driver is bound to the device, and we only need to access it to fetch voltage, which can be done at probe time.

Quoted 8 lines
Quoted 8 lines
Quoted 5 lines

Switch to using devm_regulator_get_enable_read_voltage() which simplifies probing and unbinding code.

Hi.

I think this broke the ACPI case (where regulator isn't available).

Oh, you're right.

Quoted 67 lines
Quoted 50 lines

Jonathan

Quoted 47 lines
---
 drivers/iio/adc/ti-ads7950.c | 45 +++++++++++---------------------------------
 1 file changed, 11 insertions(+), 34 deletions(-)
drivers/iio/adc/ti-ads7950.c +3 -17
index 273c35e03185..847e83baa876 100644
@@ -341,19 +341,9 @@ static int ti_ads7950_scan_direct(struct iio_dev *indio_dev, unsigned int ch)
 	return st->single_rx;
 }
 
-static int ti_ads7950_get_range(struct ti_ads7950_state *st)
+static unsigned int ti_ads7950_get_range(struct ti_ads7950_state *st)
 {
-	int vref;
-
-	if (st->vref_mv) {
-		vref = st->vref_mv;
-	} else {
-		vref = regulator_get_voltage(st->reg);
-		if (vref < 0)
-			return vref;
-
-		vref /= 1000;
-	}
+	unsigned int vref = st->vref_mv;
 
 	if (st->cmd_settings_bitmask & TI_ADS7950_CR_RANGE_5V)
 		vref *= 2;
@@ -382,11 +372,7 @@ static int ti_ads7950_read_raw(struct iio_dev *indio_dev,
 
 		return IIO_VAL_INT;
 	case IIO_CHAN_INFO_SCALE:
-		ret = ti_ads7950_get_range(st);
-		if (ret < 0)
-			return ret;
-
-		*val = ret;
+		*val = ti_ads7950_get_range(st);
 		*val2 = (1 << chan->scan_type.realbits) - 1;
 
 		return IIO_VAL_FRACTIONAL;
@@ -580,30 +566,24 @@ static int ti_ads7950_probe(struct spi_device *spi)
 	spi_message_init_with_transfers(&st->scan_single_msg,
 					st->scan_single_xfer, 3);
 
Quoted 7 lines

drivers/iio/adc/ti-ads7950.c static int ti_ads7950_probe(struct spi_device *spi) · line 570

Quoted 2 lines
drivers/iio/adc/ti-ads7950.c +2 -0
+	ret = devm_regulator_get_enable_read_voltage(&spi->dev, "vref");
+	if (ret < 0)  

I think you need to check for -ENODEV and if you see than then see if the acpi route below applies. Otherwise on ACPI this will fail and we'll fail the probe.

Or do something like:

	if (ACPI_COMPANION(&spi->dev)) {
		ret = devm_regulator_get_enable(&spi->dev, "vref");
		if (ret)
			return dev_err_probe(&spi->dev, ret,
					     "Failed to get regulator \"vref\"\n");

st->vref_mv = TI_ADS7950_VA_MV_ACPI_DEFAULT;

Quoted 8 lines
Quoted 6 lines

We know that concept of regulators is not exposed on ACPI systems, and we'd get a dummy here, so maybe just store st->vref_mv and not bother with acquiring and enabling the dummy regulator?

Thanks.

Sounds OK to me.

Likewise.

J

#14 lore raw

Re: [PATCH v3 5/6] iio: adc: ti-ads7950: switch to using devm_regulator_get_enable_read_voltage()

In reply to Jonathan Cameron
Quoted 2 lines · Jonathan Cameron

On Thu, 05 Mar 2026 11:21:56 -0800
Dmitry Torokhov <[email protected]> wrote:

...

Quoted 1 line

I think this broke the ACPI case (where regulator isn't available).

Right, and I even have an HW to test (if required).

...

Quoted 6 lines

drivers/iio/adc/ti-ads7950.c static int ti_ads7950_probe(struct spi_device *spi) · line 570

Quoted 2 lines
drivers/iio/adc/ti-ads7950.c +2 -0
+	ret = devm_regulator_get_enable_read_voltage(&spi->dev, "vref");
+	if (ret < 0)

I think you need to check for -ENODEV and if you see than then see if the acpi route below applies. Otherwise on ACPI this will fail and we'll fail the probe.

Yep, just make it default without even checking the fwnode type. No need to bring the whole acpi.h into the mix.

Signature · 2 lines
With Best Regards,
Andy Shevchenko
#15 lore raw

Re: [PATCH v3 5/6] iio: adc: ti-ads7950: switch to using devm_regulator_get_enable_read_voltage()

Quoted 19 lines · Andy Shevchenko
Quoted 2 lines · Jonathan Cameron

On Thu, 05 Mar 2026 11:21:56 -0800
Dmitry Torokhov <[email protected]> wrote:

...

Quoted 1 line

I think this broke the ACPI case (where regulator isn't available).

Right, and I even have an HW to test (if required).

...

Quoted 6 lines

drivers/iio/adc/ti-ads7950.c static int ti_ads7950_probe(struct spi_device *spi) · line 570

Quoted 2 lines
drivers/iio/adc/ti-ads7950.c +2 -0
+	ret = devm_regulator_get_enable_read_voltage(&spi->dev, "vref");
+	if (ret < 0)

I think you need to check for -ENODEV and if you see than then see if the acpi route below applies. Otherwise on ACPI this will fail and we'll fail the probe.

Quoted 2 lines

Yep, just make it default without even checking the fwnode type. No need to bring the whole acpi.h into the mix.

I do not think this would be correct behavior. On non-ACPI systems the regulator is mandatory, and the driver should not blindly apply scale from ACPI systems just because regulator is missing in the DTS.

Thanks.

Signature · 1 line
Dmitry
#16 lore raw

Re: [PATCH v3 5/6] iio: adc: ti-ads7950: switch to using devm_regulator_get_enable_read_voltage()

Quoted 4 lines · Dmitry Torokhov
Quoted 3 lines · Andy Shevchenko
Quoted 2 lines · Jonathan Cameron

On Thu, 05 Mar 2026 11:21:56 -0800
Dmitry Torokhov <[email protected]> wrote:

...

Quoted 7 lines
Quoted 7 lines
Quoted 6 lines

drivers/iio/adc/ti-ads7950.c static int ti_ads7950_probe(struct spi_device *spi) · line 570

Quoted 2 lines
drivers/iio/adc/ti-ads7950.c +2 -0
+	ret = devm_regulator_get_enable_read_voltage(&spi->dev, "vref");
+	if (ret < 0)

I think you need to check for -ENODEV and if you see than then see if the acpi route below applies. Otherwise on ACPI this will fail and we'll fail the probe.

Quoted 6 lines
Quoted 2 lines

Yep, just make it default without even checking the fwnode type. No need to bring the whole acpi.h into the mix.

I do not think this would be correct behavior. On non-ACPI systems the regulator is mandatory, and the driver should not blindly apply scale from ACPI systems just because regulator is missing in the DTS.

I mistakenly thought that original code doesn't have that cneck. Yes, the ACPI_COMPANION() should be preserved.

Signature · 2 lines
With Best Regards,
Andy Shevchenko
#17 lore raw

PATCH v3 6/6 iio: adc: ti-ads7950: complete conversion to using managed resources

In reply to Dmitry Torokhov

All resources that the driver needs have managed API now. Switch to using them to make code clearer and drop ti_ads7950_remove().

---
 drivers/iio/adc/ti-ads7950.c | 66 +++++++++++++-------------------------------
 1 file changed, 19 insertions(+), 47 deletions(-)
drivers/iio/adc/ti-ads7950.c +19 -47
index 847e83baa876..a1197e9cff93 100644
@@ -513,10 +513,8 @@ static int ti_ads7950_probe(struct spi_device *spi)
 	spi->bits_per_word = 16;
 	spi->mode |= SPI_CS_WORD;
 	ret = spi_setup(spi);
-	if (ret) {
-		dev_err(&spi->dev, "Error in spi setup\n");
-		return ret;
-	}
+	if (ret)
+		return dev_err_probe(&spi->dev, ret, "Error in spi setup\n");
 
 	indio_dev = devm_iio_device_alloc(&spi->dev, sizeof(*st));
 	if (!indio_dev)
@@ -577,26 +575,22 @@ static int ti_ads7950_probe(struct spi_device *spi)
 	else
 		st->vref_mv = ret / 1000;
 
-	mutex_init(&st->slock);
-
-	ret = iio_triggered_buffer_setup(indio_dev, NULL,
-					 &ti_ads7950_trigger_handler, NULL);
-	if (ret) {
-		dev_err(&spi->dev, "Failed to setup triggered buffer\n");
-		goto error_destroy_mutex;
-	}
+	ret = devm_iio_triggered_buffer_setup(&spi->dev, indio_dev, NULL,
+					      &ti_ads7950_trigger_handler,
+					      NULL);
+	if (ret)
+		return dev_err_probe(&spi->dev, ret,
+				     "Failed to setup triggered buffer\n");
 
 	ret = ti_ads7950_init_hw(st);
-	if (ret) {
-		dev_err(&spi->dev, "Failed to init adc chip\n");
-		goto error_cleanup_ring;
-	}
+	if (ret)
+		return dev_err_probe(&spi->dev, ret,
+				     "Failed to init adc chip\n");
 
-	ret = iio_device_register(indio_dev);
-	if (ret) {
-		dev_err(&spi->dev, "Failed to register iio device\n");
-		goto error_cleanup_ring;
-	}
+	ret = devm_iio_device_register(&spi->dev, indio_dev);
+	if (ret)
+		return dev_err_probe(&spi->dev, ret,
+				     "Failed to register iio device\n");
 
 	/* Add GPIO chip */
 	st->chip.label = dev_name(&st->spi->dev);
@@ -611,33 +605,12 @@ static int ti_ads7950_probe(struct spi_device *spi)
 	st->chip.get = ti_ads7950_get;
 	st->chip.set = ti_ads7950_set;
 
-	ret = gpiochip_add_data(&st->chip, st);
-	if (ret) {
-		dev_err(&spi->dev, "Failed to init GPIOs\n");
-		goto error_iio_device;
-	}
+	ret = devm_gpiochip_add_data(&spi->dev, &st->chip, st);
+	if (ret)
+		return dev_err_probe(&spi->dev, ret,
+				     "Failed to init GPIOs\n");
 
 	return 0;
-
-error_iio_device:
-	iio_device_unregister(indio_dev);
-error_cleanup_ring:
-	iio_triggered_buffer_cleanup(indio_dev);
-error_destroy_mutex:
-	mutex_destroy(&st->slock);
-
-	return ret;
-}
-
-static void ti_ads7950_remove(struct spi_device *spi)
-{
-	struct iio_dev *indio_dev = spi_get_drvdata(spi);
-	struct ti_ads7950_state *st = iio_priv(indio_dev);
-
-	gpiochip_remove(&st->chip);
-	iio_device_unregister(indio_dev);
-	iio_triggered_buffer_cleanup(indio_dev);
-	mutex_destroy(&st->slock);
 }
 
 static const struct spi_device_id ti_ads7950_id[] = {
@@ -680,7 +653,6 @@ static struct spi_driver ti_ads7950_driver = {
 		.of_match_table = ads7950_of_table,
 	},
 	.probe		= ti_ads7950_probe,
-	.remove		= ti_ads7950_remove,
 	.id_table	= ti_ads7950_id,
 };
 module_spi_driver(ti_ads7950_driver);
Signature · 1 line
2.53.0.473.g4a7958ca14-goog
#18 lore raw

Re: [PATCH v3 6/6] iio: adc: ti-ads7950: complete conversion to using managed resources

Quoted 2 lines · Dmitry Torokhov

All resources that the driver needs have managed API now. Switch to using them to make code clearer and drop ti_ads7950_remove().

...

drivers/iio/adc/ti-ads7950.c static int ti_ads7950_probe(struct spi_device *spi) · line 580

Quoted 1 line
drivers/iio/adc/ti-ads7950.c +0 -1
-	mutex_init(&st->slock);

I missed seeing the + lines WRT the above removal.

Signature · 2 lines
With Best Regards,
Andy Shevchenko
#19 lore raw

Re: [PATCH v3 6/6] iio: adc: ti-ads7950: complete conversion to using managed resources

Quoted 10 lines · Andy Shevchenko
Quoted 2 lines · Dmitry Torokhov

All resources that the driver needs have managed API now. Switch to using them to make code clearer and drop ti_ads7950_remove().

...

drivers/iio/adc/ti-ads7950.c static int ti_ads7950_probe(struct spi_device *spi) · line 580

Quoted 1 line
drivers/iio/adc/ti-ads7950.c +0 -1
-	mutex_init(&st->slock);

I missed seeing the + lines WRT the above removal.

Oops, will fix it up.

Signature · 1 line
Dmitry
reviewer Reviewed-by on v3 6/6
#20 lore raw

Re: [PATCH v3 6/6] iio: adc: ti-ads7950: complete conversion to using managed resources

In reply to Dmitry Torokhov
Quoted 5 lines · Dmitry Torokhov

All resources that the driver needs have managed API now. Switch to using them to make code clearer and drop ti_ads7950_remove().

---

...

drivers/iio/adc/ti-ads7950.c static int ti_ads7950_probe(struct spi_device *spi) · line 580

Quoted 5 lines
drivers/iio/adc/ti-ads7950.c +0 -1
@@ -577,26 +575,22 @@ static int ti_ads7950_probe(struct spi_device *spi)
 	else
 		st->vref_mv = ret / 1000;
 
-	mutex_init(&st->slock);

With this accidental removal fixed:

reviewer
#21 lore raw

Re: [PATCH v3 6/6] iio: adc: ti-ads7950: complete conversion to using managed resources

In reply to Dmitry Torokhov
Quoted 5 lines · Dmitry Torokhov

All resources that the driver needs have managed API now. Switch to using them to make code clearer and drop ti_ads7950_remove().

---

One more small detail...

drivers/iio/adc/ti-ads7950.c static int ti_ads7950_probe(struct spi_device *spi) · line 634

Quoted 3 lines
drivers/iio/adc/ti-ads7950.c +0 -3
-static void ti_ads7950_remove(struct spi_device *spi)
-{
-	struct iio_dev *indio_dev = spi_get_drvdata(spi);

Since we are removing the only instance of spi_get_drvdata(), we can also remove spi_set_drvdata() in the probe function

Quoted 8 lines
drivers/iio/adc/ti-ads7950.c +0 -6
-	struct ti_ads7950_state *st = iio_priv(indio_dev);
-
-	gpiochip_remove(&st->chip);
-	iio_device_unregister(indio_dev);
-	iio_triggered_buffer_cleanup(indio_dev);
-	mutex_destroy(&st->slock);
 }
maintainer Applied
#22 lore raw
In reply to Dmitry Torokhov
Quoted 7 lines · On Thu, 05 Mar 2026 11:21:51 -0800 Dmitry Torokhov <[email protected]>…

The original reason for this series is to make sure ti_ads7950_get() returns result in range [0, 1] or a negative error code to comply with gpiolib requirement.

During review David noticed the fact that the function also clobbers gpio state. Fixing that lead to adding cleanups using guard() and devm.

Applied patches 1 and 2 to the fixes-togreg branch of iio.git and marked them for stable.

The rest will need to wait for those to be upstream. Given I have the memory of a goldfish and there will it seems be a v4, please mention that in the cover letter.

Thanks,

Jonathan

Quoted 33 lines

v3:

- Added "Fixes" tags
- Picked up reviewed-by tags for #1 and #2
- Dropped the conversion to "error" variables
- Avoid using scoped_guard (per David)
- directly return results of function calls at the end of function (David)
- Split spi_sync() error handling into a new patxch (Andy)
- Switch to using devm_regulator_get_enable_read_voltage() (David)

v2:

- style fixes in #1 (per David)
- fix to not clobber state (#2, new)
- #3 and #4 (new)

---
Dmitry Torokhov (6):
iio: adc: ti-ads7950: normalize return value of gpio_get
iio: adc: ti-ads7950: do not clobber gpio state in ti_ads7950_get()
iio: adc: ti-ads7950: switch to using guard() notation
iio: adc: ti-ads7950: simplify check for spi_setup() failures
iio: adc: ti-ads7950: switch to using devm_regulator_get_enable_read_voltage()
iio: adc: ti-ads7950: complete conversion to using managed resources

 drivers/iio/adc/ti-ads7950.c | 188 ++++++++++++++-----------------------------
 1 file changed, 59 insertions(+), 129 deletions(-)

---
base-commit: c025f6cf4209e1542ec2afebe49f42bbaf1a5c7b
change-id: 20260220-ti-ads7950-facelift-ad8b5390a654

Thanks.