[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <20250825153325.421d2a4d@jic23-huawei>
Date: Mon, 25 Aug 2025 15:33:25 +0100
From: Jonathan Cameron <jic23@...nel.org>
To: Jonathan Santos <Jonathan.Santos@...log.com>
Cc: <linux-kernel@...r.kernel.org>, <linux-iio@...r.kernel.org>,
<devicetree@...r.kernel.org>, <Michael.Hennerich@...log.com>,
<lars@...afoo.de>, <dlechner@...libre.com>, <nuno.sa@...log.com>,
<andy@...nel.org>, <robh@...nel.org>, <krzk+dt@...nel.org>,
<conor+dt@...nel.org>, <marcelo.schmitt1@...il.com>
Subject: Re: [PATCH v2 2/4] iio: adc: ad7768-1: introduce chip info for
future multidevice support
On Sun, 24 Aug 2025 01:09:53 -0300
Jonathan Santos <Jonathan.Santos@...log.com> wrote:
> Add Chip info struct in SPI device to store channel information for
> each supported part.
>
> Signed-off-by: Jonathan Santos <Jonathan.Santos@...log.com>
> ---
> v2 Changes:
> * removed AD7768_CHAN_INFO_NONE macro.
> * reordered fields in ad7768_chip_info struct.
> * removed trailing comma.
> ---
> drivers/iio/adc/ad7768-1.c | 75 ++++++++++++++++++++++++++------------
> 1 file changed, 52 insertions(+), 23 deletions(-)
>
> diff --git a/drivers/iio/adc/ad7768-1.c b/drivers/iio/adc/ad7768-1.c
> index a2e061f0cb08..83b0907b068d 100644
> --- a/drivers/iio/adc/ad7768-1.c
> +++ b/drivers/iio/adc/ad7768-1.c
> @@ -213,6 +213,13 @@ static const struct iio_scan_type ad7768_scan_type[] = {
> },
> };
>
> +struct ad7768_chip_info {
> + const char *name;
> + const unsigned long *available_masks;
> + const struct iio_chan_spec *channel_spec;
> + int num_channels;
> +};
> +
> struct ad7768_state {
> struct spi_device *spi;
> struct regmap *regmap;
> @@ -234,6 +241,7 @@ struct ad7768_state {
> struct gpio_desc *gpio_reset;
> const char *labels[AD7768_MAX_CHANNELS];
> struct gpio_chip gpiochip;
> + const struct ad7768_chip_info *chip;
> bool en_spi_sync;
> /*
> * DMA (thus cache coherency maintenance) may require the
> @@ -750,24 +758,27 @@ static const struct iio_chan_spec_ext_info ad7768_ext_info[] = {
> { }
> };
>
> +#define AD7768_CHAN(_idx, _msk_avail) { \
Check for consistency. looks like you were aiming for 1 space before \ but didn't
get it the same everywhere?
> + .type = IIO_VOLTAGE,\
> + .info_mask_separate_available = _msk_avail,\
> + .info_mask_separate = BIT(IIO_CHAN_INFO_RAW),\
> + .info_mask_shared_by_type = BIT(IIO_CHAN_INFO_SCALE) | \
> + BIT(IIO_CHAN_INFO_LOW_PASS_FILTER_3DB_FREQUENCY) | \
> + BIT(IIO_CHAN_INFO_OVERSAMPLING_RATIO),\
> + .info_mask_shared_by_type_available = BIT(IIO_CHAN_INFO_OVERSAMPLING_RATIO),\
> + .info_mask_shared_by_all = BIT(IIO_CHAN_INFO_SAMP_FREQ), \
> + .info_mask_shared_by_all_available = BIT(IIO_CHAN_INFO_SAMP_FREQ),\
> + .ext_info = ad7768_ext_info,\
> + .indexed = 1,\
> + .channel = _idx,\
> + .scan_index = _idx,\
> + .has_ext_scan_type = 1,\
> + .ext_scan_type = ad7768_scan_type,\
> + .num_ext_scan_type = ARRAY_SIZE(ad7768_scan_type),\
> +}
> +
> static const struct iio_chan_spec ad7768_channels[] = {
> - {
> - .type = IIO_VOLTAGE,
> - .info_mask_separate = BIT(IIO_CHAN_INFO_RAW),
> - .info_mask_shared_by_type = BIT(IIO_CHAN_INFO_SCALE) |
> - BIT(IIO_CHAN_INFO_LOW_PASS_FILTER_3DB_FREQUENCY) |
> - BIT(IIO_CHAN_INFO_OVERSAMPLING_RATIO),
> - .info_mask_shared_by_type_available = BIT(IIO_CHAN_INFO_OVERSAMPLING_RATIO),
> - .info_mask_shared_by_all = BIT(IIO_CHAN_INFO_SAMP_FREQ),
> - .info_mask_shared_by_all_available = BIT(IIO_CHAN_INFO_SAMP_FREQ),
> - .ext_info = ad7768_ext_info,
> - .indexed = 1,
> - .channel = 0,
> - .scan_index = 0,
> - .has_ext_scan_type = 1,
> - .ext_scan_type = ad7768_scan_type,
> - .num_ext_scan_type = ARRAY_SIZE(ad7768_scan_type),
> - },
> + AD7768_CHAN(0, 0),
> };
>
> static int ad7768_read_raw(struct iio_dev *indio_dev,
> @@ -1334,6 +1345,18 @@ static int ad7768_register_regulators(struct device *dev, struct ad7768_state *s
> return 0;
> }
>
> +static const unsigned long ad7768_channel_masks[] = {
> + BIT(0),
That doesn't make a lot of sense. Don't provide one for devices with
only one channel. Leave it set to NULL and everything should just work.
> + 0
> +};
Powered by blists - more mailing lists