mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH v3] staging: iio: adc: ad7816: use dev_err_probe() for GPIO lookups
@ 2026-11-18 18:22 Maximo Manriquez Lizarraga via B4 Relay
  2026-11-19  9:22 ` Andy Shevchenko
  0 siblings, 1 reply; 2+ messages in thread
From: Maximo Manriquez Lizarraga via B4 Relay @ 2026-11-18 18:22 UTC (permalink / raw)
  To: nuno.sa, andy, gregkh, jic23, dlechner, Michael.Hennerich
  Cc: linux-staging, linux-iio, linux, krzk, linux-kernel, crofts,
	Maximo Manriquez Lizarraga

From: Maximo Manriquez Lizarraga <DelaySystem@tubot.lat>

GPIO lookups can return -EPROBE_DEFER.  Convert the rdwr, convert,
and busy GPIO lookup failures in ad7816_probe() to dev_err_probe(),
which suppresses the error message on deferral and records the deferral
reason.

No functional change other than defer handling.

Signed-off-by: Maximo Manriquez Lizarraga <DelaySystem@tubot.lat>
---
Changes in v3:
- Convert the missed busy-GPIO failure path to dev_err_probe() as well (Joshua Crofts).
- Link to v2: https://patch.msgid.link/20261117-batch1-s3-warn-v2-1-17f4e541123b@tubot.lat

Changes in v2:
- Resend under my real name (From/Signed-off-by: Maximo Manriquez Lizarraga).
- Apologies for the improper sign-off on v1; no code change.
- Link to v1: https://patch.msgid.link/20261107-batch1-s3-warn-v1-1-4fc38341ca38@tubot.lat
---
 drivers/staging/iio/adc/ad7816.c | 27 +++++++++------------------
 1 file changed, 9 insertions(+), 18 deletions(-)

diff --git a/drivers/staging/iio/adc/ad7816.c b/drivers/staging/iio/adc/ad7816.c
index 2a15d7598abb..dc9d89ca04ab 100644
--- a/drivers/staging/iio/adc/ad7816.c
+++ b/drivers/staging/iio/adc/ad7816.c
@@ -381,29 +381,20 @@ static int ad7816_probe(struct spi_device *spi_dev)
 
 	chip->id = spi_get_device_id(spi_dev)->driver_data;
 	chip->rdwr_pin = devm_gpiod_get(&spi_dev->dev, "rdwr", GPIOD_OUT_HIGH);
-	if (IS_ERR(chip->rdwr_pin)) {
-		ret = PTR_ERR(chip->rdwr_pin);
-		dev_err(&spi_dev->dev, "Failed to request rdwr GPIO: %d\n",
-			ret);
-		return ret;
-	}
+	if (IS_ERR(chip->rdwr_pin))
+		return dev_err_probe(&spi_dev->dev, PTR_ERR(chip->rdwr_pin),
+				     "Failed to request rdwr GPIO\n");
 	chip->convert_pin = devm_gpiod_get(&spi_dev->dev, "convert",
 					   GPIOD_OUT_HIGH);
-	if (IS_ERR(chip->convert_pin)) {
-		ret = PTR_ERR(chip->convert_pin);
-		dev_err(&spi_dev->dev, "Failed to request convert GPIO: %d\n",
-			ret);
-		return ret;
-	}
+	if (IS_ERR(chip->convert_pin))
+		return dev_err_probe(&spi_dev->dev, PTR_ERR(chip->convert_pin),
+				     "Failed to request convert GPIO\n");
 	if (chip->id == ID_AD7816 || chip->id == ID_AD7817) {
 		chip->busy_pin = devm_gpiod_get(&spi_dev->dev, "busy",
 						GPIOD_IN);
-		if (IS_ERR(chip->busy_pin)) {
-			ret = PTR_ERR(chip->busy_pin);
-			dev_err(&spi_dev->dev, "Failed to request busy GPIO: %d\n",
-				ret);
-			return ret;
-		}
+		if (IS_ERR(chip->busy_pin))
+			return dev_err_probe(&spi_dev->dev, PTR_ERR(chip->busy_pin),
+					     "Failed to request busy GPIO\n");
 	}
 
 	indio_dev->name = spi_get_device_id(spi_dev)->name;

---
base-commit: fa4ad798f6f681031775266044ba1b0cf3c670bd
change-id: 20261107-batch1-s3-warn-289c98c7b118

Best regards,
--  
Maximo Manriquez Lizarraga <DelaySystem@tubot.lat>



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

* Re: [PATCH v3] staging: iio: adc: ad7816: use dev_err_probe() for GPIO lookups
  2026-11-18 18:22 [PATCH v3] staging: iio: adc: ad7816: use dev_err_probe() for GPIO lookups Maximo Manriquez Lizarraga via B4 Relay
@ 2026-11-19  9:22 ` Andy Shevchenko
  0 siblings, 0 replies; 2+ messages in thread
From: Andy Shevchenko @ 2026-11-19  9:22 UTC (permalink / raw)
  To: DelaySystem
  Cc: nuno.sa, andy, gregkh, jic23, dlechner, Michael.Hennerich,
	linux-staging, linux-iio, linux, krzk, linux-kernel, crofts

On Wed, Nov 18, 2026 at 10:22:17AM -0800, Maximo Manriquez Lizarraga via B4 Relay wrote:
> 
> GPIO lookups can return -EPROBE_DEFER.  Convert the rdwr, convert,
> and busy GPIO lookup failures in ad7816_probe() to dev_err_probe(),
> which suppresses the error message on deferral and records the deferral
> reason.
> 
> No functional change other than defer handling.

...

> static int ad7816_probe(struct spi_device *spi_dev)

While at it, add

	struct device *dev = &spi_dev->dev;

at the top of the function and use in the code you have touched.

>  	chip->id = spi_get_device_id(spi_dev)->driver_data;
>  	chip->rdwr_pin = devm_gpiod_get(&spi_dev->dev, "rdwr", GPIOD_OUT_HIGH);
> -	if (IS_ERR(chip->rdwr_pin)) {
> -		ret = PTR_ERR(chip->rdwr_pin);
> -		dev_err(&spi_dev->dev, "Failed to request rdwr GPIO: %d\n",
> -			ret);
> -		return ret;
> -	}
> +	if (IS_ERR(chip->rdwr_pin))
> +		return dev_err_probe(&spi_dev->dev, PTR_ERR(chip->rdwr_pin),
> +				     "Failed to request rdwr GPIO\n");
>  	chip->convert_pin = devm_gpiod_get(&spi_dev->dev, "convert",
>  					   GPIOD_OUT_HIGH);
> -	if (IS_ERR(chip->convert_pin)) {
> -		ret = PTR_ERR(chip->convert_pin);
> -		dev_err(&spi_dev->dev, "Failed to request convert GPIO: %d\n",
> -			ret);
> -		return ret;
> -	}
> +	if (IS_ERR(chip->convert_pin))
> +		return dev_err_probe(&spi_dev->dev, PTR_ERR(chip->convert_pin),
> +				     "Failed to request convert GPIO\n");
>  	if (chip->id == ID_AD7816 || chip->id == ID_AD7817) {
>  		chip->busy_pin = devm_gpiod_get(&spi_dev->dev, "busy",
>  						GPIOD_IN);
> -		if (IS_ERR(chip->busy_pin)) {
> -			ret = PTR_ERR(chip->busy_pin);
> -			dev_err(&spi_dev->dev, "Failed to request busy GPIO: %d\n",
> -				ret);
> -			return ret;
> -		}
> +		if (IS_ERR(chip->busy_pin))
> +			return dev_err_probe(&spi_dev->dev, PTR_ERR(chip->busy_pin),
> +					     "Failed to request busy GPIO\n");
>  	}

-- 
With Best Regards,
Andy Shevchenko



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

end of thread, other threads:[~2026-11-19  9:22 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-11-18 18:22 [PATCH v3] staging: iio: adc: ad7816: use dev_err_probe() for GPIO lookups Maximo Manriquez Lizarraga via B4 Relay
2026-11-19  9:22 ` Andy Shevchenko

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

all inboxes | Powered by JetHome®