* [PATCH] iio: adc: ti-ads124s08: Return reset failures
@ 2026-06-24 5:53 Pengpeng Hou
2026-06-24 6:57 ` Joshua Crofts
0 siblings, 1 reply; 2+ messages in thread
From: Pengpeng Hou @ 2026-06-24 5:53 UTC (permalink / raw)
To: Jonathan Cameron, David Lechner, Nuno Sá, Andy Shevchenko,
Pengpeng Hou
Cc: linux-iio, linux-kernel
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@iscas.ac.cn>
---
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)
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] iio: adc: ti-ads124s08: Return reset failures
2026-06-24 5:53 [PATCH] iio: adc: ti-ads124s08: Return reset failures Pengpeng Hou
@ 2026-06-24 6:57 ` Joshua Crofts
0 siblings, 0 replies; 2+ messages in thread
From: Joshua Crofts @ 2026-06-24 6:57 UTC (permalink / raw)
To: Pengpeng Hou
Cc: Jonathan Cameron, David Lechner, Nuno Sá, Andy Shevchenko,
linux-iio, linux-kernel
On Wed, 24 Jun 2026 13:53:25 +0800
Pengpeng Hou <pengpeng@iscas.ac.cn> wrote:
> 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@iscas.ac.cn>
> ---
Hmm, perhaps it's trivial, but not sure if these changes should be separated
into two patches. If so, feel free to carry over my tag.
Reviewed-by: Joshua Crofts <joshua.crofts1@gmail.com>
--
Kind regards
CJD
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2026-06-24 6:57 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-06-24 5:53 [PATCH] iio: adc: ti-ads124s08: Return reset failures Pengpeng Hou
2026-06-24 6:57 ` Joshua Crofts
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox