Re: [PATCH 18/18] iio: adc: ad4170-4: Add support for AD4171-8, AD4190-8 and AD4195-8
From: Andy Shevchenko
Date: Thu Dec 03 2026 - 12:23:17 EST
On Thu, Dec 03, 2026 at 04:19:58PM +0100, Janani Sunil wrote:
> The AD4171-8, AD4190-8, and AD4195-8 are eight differential input members
> of the AD4170 family. They expose analog inputs AIN0 to AIN15 plus a
> dedicated AINCOM pin. The AD4190-8 and AD4195-8 have no integrated DAC and
> share the AD4190-4 sinc5 FS range and clock divider, while the AD4171-8
> keeps the AD4170-4 feature set, so its maximum output data rate is
> 500 kSPS.
>
> Move the remaining per-device difference, the analog pin count, into
> chip_info so input validation adapts at runtime. That also lifts the
> adi,vbias-pins count limit to the nine analog input pins the four input
> devices actually have.
>
> AINCOM (input number 16) can be the positive or negative input of a
> channel on these parts. Accept it during channel input validation, and
> track its use separately from pins_fn[], which only tracks the regular
> analog input pins, so that AINCOM follows the same rules as those pins
> when shared between channel inputs and excitation current outputs.
>
> CURRENT_SOURCEn I_OUT_PIN accepts the same set of inputs, so excitation
> pin validation follows the analog pin count as well and accepts AINCOM
> where it exists.
...
> help
> - Say yes here to build support for Analog Devices AD4170-4 SPI analog
> - to digital converters (ADC).
> + Say yes here to build support for Analog Devices AD4170-4, AD4171-8,
> + AD4190-4, AD4190-8, AD4195-4, and AD4195-8 SPI analog to digital
> + converters (ADC).
No. I'm tired to repeat how it should be done in scalable way. Read mailing
list archives and act accordingly.
...
> static int ad4170_validate_channel_input(struct ad4170_state *st, int pin, bool com)
> {
> + if (st->chip->has_aincom && pin == AD4170_CHAN_MAP_AINCOM) {
> + if (st->aincom_fn & AD4170_PIN_CURRENT_OUT)
> + return dev_err_probe(&st->spi->dev, -EINVAL,
Add a temporary variable at the same time (and in previous patch(es) as well)
struct device *dev = &st->spi->dev;
> + "AINCOM already used with fn %u.\n",
> + st->aincom_fn);
> +
> + st->aincom_fn |= AD4170_PIN_ANALOG_IN;
> + return 0;
> + }
--
With Best Regards,
Andy Shevchenko