Messages in this thread | | | Date | Mon, 6 Nov 2023 12:27:29 +0200 | From | Andy Shevchenko <> | Subject | Re: [PATCH 3/3] iio: adc: ad7192: Add AD7194 support |
| |
On Sun, Nov 05, 2023 at 09:31:31PM +0200, alisadariana@gmail.com wrote: > From: Alisa-Dariana Roman <alisa.roman@analog.com> > > Unlike the other AD719Xs, AD7194 has configurable differential > channels. The default configuration for these channels can be changed > from the devicetree. > > The default configuration is hardcoded in order to have a stable number > of channels.
...
> config AD7192 > - tristate "Analog Devices AD7190 AD7192 AD7193 AD7195 ADC driver" > + tristate "Analog Devices AD7190 AD7192 AD7193 AD7194 AD7195 ADC driver"
This doesn't scale. Please change this and below like:
tristate "Analog Devices AD719x ADC driver"
> depends on SPI > select AD_SIGMA_DELTA > help > Say yes here to build support for Analog Devices AD7190, > - AD7192, AD7193 or AD7195 SPI analog to digital converters (ADC). > + AD7192, AD7193, AD7194 or AD7195 SPI analog to digital converters (ADC).
Say yes here to build support for Analog Devices SPI analog to digital converters (ADC): - AD7190 - AD7192 - AD7193 - AD7194 - AD7195
> If unsure, say N (but it's safe to say "Y").
With above change adding a new one will be just a mater of adding a single line.
...
> +static int ad7192_parse_channel(struct iio_dev *indio_dev, > + struct fwnode_handle *child) > +{ > + u32 reg, ain[2]; > + int ret; > + > + ret = fwnode_property_read_u32(child, "reg", ®); > + if (ret) > + return ret;
> + if (reg < AD7194_CH_DIFF_NR_MIN || reg > AD7194_CH_DIFF_NR_MAX) > + return -EINVAL;
in_range()
> + ret = fwnode_property_read_u32_array(child, "diff-channels", ain, > + ARRAY_SIZE(ain)); > + if (ret) > + return ret; > + > + if (ain[0] < AD7194_CH_AIN_MIN || ain[0] > AD7194_CH_AIN_MAX || > + ain[1] < AD7194_CH_AIN_MIN || ain[1] > AD7194_CH_AIN_MAX)
Ditto.
> + return -EINVAL; > + > + ad7194_channels[reg].channel = ain[0]; > + ad7194_channels[reg].channel2 = ain[1]; > + ad7194_channels[reg].address = AD7194_CH_DIFF(ain[0], ain[1]); > + > + return 0; > +}
-- With Best Regards, Andy Shevchenko
| |