[PATCH] iio: adc: ti-ads124s08: Return reset failures

From: Pengpeng Hou

Date: Wed Jun 24 2026 - 01:57:39 EST


devm_gpiod_get_optional() returns NULL when the optional GPIO is absent,
but returns an ERR_PTR when the provider lookup fails. Probe currently
logs the ERR_PTR case and keeps the error pointer in reset_gpio.

Later ads124s_reset() treats any non-NULL reset_gpio as valid and passes
it to gpiod_set_value_cansleep(). Return the lookup error instead of
retaining the ERR_PTR.

Also return ads124s_reset() failures so probe does not register the IIO
device after either the GPIO reset path or the software reset command
failed.

Signed-off-by: Pengpeng Hou <pengpeng@xxxxxxxxxxx>
---
drivers/iio/adc/ti-ads124s08.c | 7 +++++--
1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/drivers/iio/adc/ti-ads124s08.c b/drivers/iio/adc/ti-ads124s08.c
index 8ea1269f74db..57eed8554bd9 100644
--- a/drivers/iio/adc/ti-ads124s08.c
+++ b/drivers/iio/adc/ti-ads124s08.c
@@ -321,7 +321,8 @@ static int ads124s_probe(struct spi_device *spi)
ads124s_priv->reset_gpio = devm_gpiod_get_optional(&spi->dev,
"reset", GPIOD_OUT_LOW);
if (IS_ERR(ads124s_priv->reset_gpio))
- dev_info(&spi->dev, "Reset GPIO not defined\n");
+ return dev_err_probe(&spi->dev, PTR_ERR(ads124s_priv->reset_gpio),
+ "Failed to get reset GPIO\n");

ads124s_priv->chip_info = &ads124s_chip_info_tbl[spi_id->driver_data];

@@ -342,7 +343,9 @@ static int ads124s_probe(struct spi_device *spi)
return ret;
}

- ads124s_reset(indio_dev);
+ ret = ads124s_reset(indio_dev);
+ if (ret)
+ return ret;

return devm_iio_device_register(&spi->dev, indio_dev);
}
--
2.50.1 (Apple Git-155)