Linux IIO development
 help / color / mirror / Atom feed
* [PATCH] iio: adc: ti-ads124s08: Return reset failures
@ 2026-06-24  5:53 Pengpeng Hou
  2026-06-24  6:57 ` Joshua Crofts
                   ` (2 more replies)
  0 siblings, 3 replies; 6+ 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] 6+ 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
  2026-06-24 11:10 ` Andy Shevchenko
  2026-06-25  5:44 ` [PATCH v2] iio: adc: ti-ads124s08: Return reset GPIO lookup errors Pengpeng Hou
  2 siblings, 0 replies; 6+ 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] 6+ 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
@ 2026-06-24 11:10 ` Andy Shevchenko
  2026-06-25  5:44 ` [PATCH v2] iio: adc: ti-ads124s08: Return reset GPIO lookup errors Pengpeng Hou
  2 siblings, 0 replies; 6+ messages in thread
From: Andy Shevchenko @ 2026-06-24 11:10 UTC (permalink / raw)
  To: Pengpeng Hou
  Cc: Jonathan Cameron, David Lechner, Nuno Sá, Andy Shevchenko,
	linux-iio, linux-kernel

On Wed, Jun 24, 2026 at 01:53:25PM +0800, Pengpeng Hou 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.

Not sure about the latter, but the GPIO case should mention deferral probe and
hence it needs a Fixes tag.

-- 
With Best Regards,
Andy Shevchenko



^ permalink raw reply	[flat|nested] 6+ messages in thread

* [PATCH v2] iio: adc: ti-ads124s08: Return reset GPIO lookup errors
  2026-06-24  5:53 [PATCH] iio: adc: ti-ads124s08: Return reset failures Pengpeng Hou
  2026-06-24  6:57 ` Joshua Crofts
  2026-06-24 11:10 ` Andy Shevchenko
@ 2026-06-25  5:44 ` Pengpeng Hou
  2026-06-25  6:47   ` Andy Shevchenko
  2 siblings, 1 reply; 6+ messages in thread
From: Pengpeng Hou @ 2026-06-25  5:44 UTC (permalink / raw)
  To: Jonathan Cameron, David Lechner, Nuno Sa, Andy Shevchenko
  Cc: Pengpeng Hou, Dan Murphy, linux-iio, linux-kernel, stable,
	Joshua Crofts

devm_gpiod_get_optional() returns NULL when the optional GPIO is absent,
but returns an ERR_PTR when the GPIO provider lookup fails, including
probe deferral.

Probe currently logs the ERR_PTR case as if the reset GPIO were simply
absent and keeps the error pointer in reset_gpio. Later ads124s_reset()
treats any non-NULL reset_gpio as a valid descriptor and passes it to
gpiod_set_value_cansleep().

Return the lookup error instead of retaining the ERR_PTR.

Fixes: e717f8c6dfec ("iio: adc: Add the TI ads124s08 ADC code")
Cc: stable@vger.kernel.org
Reviewed-by: Joshua Crofts <joshua.crofts1@gmail.com>
Signed-off-by: Pengpeng Hou <pengpeng@iscas.ac.cn>
---
Changes in v2:
- Split from the v1 combined reset-failure patch.
- Keep only the GPIO ERR_PTR/probe-deferral fix.
- Add the Fixes tag requested by Andy.
- Carry Joshua's Reviewed-by, as allowed for a split version.

 drivers/iio/adc/ti-ads124s08.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/iio/adc/ti-ads124s08.c b/drivers/iio/adc/ti-ads124s08.c
index 8ea1269f74db..73ad6ea9ef5d 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];
 
-- 
2.50.1


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* Re: [PATCH v2] iio: adc: ti-ads124s08: Return reset GPIO lookup errors
  2026-06-25  5:44 ` [PATCH v2] iio: adc: ti-ads124s08: Return reset GPIO lookup errors Pengpeng Hou
@ 2026-06-25  6:47   ` Andy Shevchenko
  2026-07-01 21:36     ` Jonathan Cameron
  0 siblings, 1 reply; 6+ messages in thread
From: Andy Shevchenko @ 2026-06-25  6:47 UTC (permalink / raw)
  To: Pengpeng Hou
  Cc: Jonathan Cameron, David Lechner, Nuno Sa, Andy Shevchenko,
	Dan Murphy, linux-iio, linux-kernel, stable, Joshua Crofts

On Thu, Jun 25, 2026 at 01:44:07PM +0800, Pengpeng Hou wrote:
> devm_gpiod_get_optional() returns NULL when the optional GPIO is absent,
> but returns an ERR_PTR when the GPIO provider lookup fails, including
> probe deferral.
> 
> Probe currently logs the ERR_PTR case as if the reset GPIO were simply
> absent and keeps the error pointer in reset_gpio. Later ads124s_reset()
> treats any non-NULL reset_gpio as a valid descriptor and passes it to
> gpiod_set_value_cansleep().

The GPIOLIB code will print an error message each time that's called.
This might flood the logs with a noise.

> Return the lookup error instead of retaining the ERR_PTR.

Reviewed-by: Andy Shevchenko <andriy.shevchenko@intel.com>

It's good as a fix for backport, but can you consider switching to use reset
framework and reset-gpio driver instead? (As a separate change on top of this
one.)

-- 
With Best Regards,
Andy Shevchenko



^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH v2] iio: adc: ti-ads124s08: Return reset GPIO lookup errors
  2026-06-25  6:47   ` Andy Shevchenko
@ 2026-07-01 21:36     ` Jonathan Cameron
  0 siblings, 0 replies; 6+ messages in thread
From: Jonathan Cameron @ 2026-07-01 21:36 UTC (permalink / raw)
  To: Andy Shevchenko
  Cc: Pengpeng Hou, David Lechner, Nuno Sa, Andy Shevchenko, Dan Murphy,
	linux-iio, linux-kernel, stable, Joshua Crofts

On Thu, 25 Jun 2026 09:47:33 +0300
Andy Shevchenko <andriy.shevchenko@intel.com> wrote:

> On Thu, Jun 25, 2026 at 01:44:07PM +0800, Pengpeng Hou wrote:
> > devm_gpiod_get_optional() returns NULL when the optional GPIO is absent,
> > but returns an ERR_PTR when the GPIO provider lookup fails, including
> > probe deferral.
> > 
> > Probe currently logs the ERR_PTR case as if the reset GPIO were simply
> > absent and keeps the error pointer in reset_gpio. Later ads124s_reset()
> > treats any non-NULL reset_gpio as a valid descriptor and passes it to
> > gpiod_set_value_cansleep().  
> 
> The GPIOLIB code will print an error message each time that's called.
> This might flood the logs with a noise.
> 
> > Return the lookup error instead of retaining the ERR_PTR.  
> 
> Reviewed-by: Andy Shevchenko <andriy.shevchenko@intel.com>
> 
> It's good as a fix for backport, but can you consider switching to use reset
> framework and reset-gpio driver instead? (As a separate change on top of this
> one.)
> 

Applied to the fixes-togreg branch of iio.git.

One small process thing.  Please don't send new versions in reply to older
ones - just send a new thread.  Doing it as replies makes for confusing threads
and ensures they are many pages up in the maintainers inbox!

Jonathan


^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2026-07-01 21:36 UTC | newest]

Thread overview: 6+ 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
2026-06-24 11:10 ` Andy Shevchenko
2026-06-25  5:44 ` [PATCH v2] iio: adc: ti-ads124s08: Return reset GPIO lookup errors Pengpeng Hou
2026-06-25  6:47   ` Andy Shevchenko
2026-07-01 21:36     ` Jonathan Cameron

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox