Re: [PATCH v5 16/20] iio: adc: ad7768: Register GPIO auxiliary device
From: Andy Shevchenko
Date: Mon Aug 31 2026 - 04:46:07 EST
On Fri, Aug 28, 2026 at 05:30:39PM +0200, Janani Sunil wrote:
> Register an auxiliary device when the AD7768 is described as a GPIO
> controller. This allows the GPIO driver to share the parent regmap and
> runtime power-management state.
...
> +static int ad7768_gpio_adev_init(struct ad7768_state *st)
> +{
> + struct device *dev = regmap_get_device(st->regmap);
> + struct spi_device *spi = to_spi_device(dev);
> + struct auxiliary_device *adev;
> + int id;
> +
> + if (!device_property_read_bool(dev, "gpio-controller"))
> + return 0;
> +
> + st->gpio_valid_mask = GENMASK(AD7768_NUM_GPIOS - 1, 0);
Can we use the one that is in the GPIOLIB (associated with struct gpio_chip)
instead?
> + if (st->clock_source != AD7768_CLOCK_SOURCE_MCLK)
> + st->gpio_valid_mask &= ~BIT(4);
> +
> + /*
> + * Use the SPI bus number and chip select to derive a stable per-device
> + * ID.
> + */
> + id = (spi->controller->bus_num << 8) | spi_get_chipselect(spi, 0);
> + adev = __devm_auxiliary_device_create(dev, KBUILD_MODNAME, "gpio",
> + &st->gpio_valid_mask, id);
> + if (!adev)
> + return dev_err_probe(dev, -ENODEV,
> + "Failed to create GPIO auxiliary device\n");
> +
> + return 0;
> +}
--
With Best Regards,
Andy Shevchenko