Re: [PATCH v4] staging: iio: adc: ad7816: use dev_err_probe() for GPIO lookups

From: Andy Shevchenko

Date: Tue Nov 24 2026 - 02:50:37 EST


On Mon, Nov 23, 2026 at 01:47:16PM -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)
> {
> struct ad7816_chip_info *chip;
> struct iio_dev *indio_dev;
> + struct device *dev = &spi_dev->dev;
> int i, ret;

Preserve reversed xmas tree order.

...

> - 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;
> - }
> - chip->convert_pin = devm_gpiod_get(&spi_dev->dev, "convert",
> + chip->rdwr_pin = devm_gpiod_get(dev, "rdwr", GPIOD_OUT_HIGH);
> + if (IS_ERR(chip->rdwr_pin))
> + return dev_err_probe(dev, PTR_ERR(chip->rdwr_pin),
> + "Failed to request rdwr GPIO\n");

> + chip->convert_pin = devm_gpiod_get(dev, "convert",
> GPIOD_OUT_HIGH);

It's perfectly a single line now. BUT... Do not touch lines that are not
modified after the main subject, id est moving to dev_err_probe().

> - 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(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",
> + chip->busy_pin = devm_gpiod_get(dev, "busy",
> GPIOD_IN);

Ditto. It's one line now, but it doesn't belong to this patch.

> - 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(dev, PTR_ERR(chip->busy_pin),
> + "Failed to request busy GPIO\n");
> }

--
With Best Regards,
Andy Shevchenko