Devicetree
 help / color / mirror / Atom feed
From: Jonathan Cameron <jic23@kernel.org>
To: Jonathan Santos <Jonathan.Santos@analog.com>
Cc: <linux-kernel@vger.kernel.org>, <linux-iio@vger.kernel.org>,
	<devicetree@vger.kernel.org>, <Michael.Hennerich@analog.com>,
	<lars@metafoo.de>, <dlechner@baylibre.com>, <nuno.sa@analog.com>,
	<andy@kernel.org>, <robh@kernel.org>, <krzk+dt@kernel.org>,
	<conor+dt@kernel.org>, <marcelo.schmitt1@gmail.com>
Subject: Re: [PATCH v2 2/4] iio: adc: ad7768-1: introduce chip info for future multidevice support
Date: Mon, 25 Aug 2025 15:33:25 +0100	[thread overview]
Message-ID: <20250825153325.421d2a4d@jic23-huawei> (raw)
In-Reply-To: <20250824040953.9547-1-Jonathan.Santos@analog.com>

On Sun, 24 Aug 2025 01:09:53 -0300
Jonathan Santos <Jonathan.Santos@analog.com> wrote:

> Add Chip info struct in SPI device to store channel information for
> each supported part.
> 
> Signed-off-by: Jonathan Santos <Jonathan.Santos@analog.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
> +};



      reply	other threads:[~2025-08-25 14:33 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-08-24  4:09 [PATCH v2 2/4] iio: adc: ad7768-1: introduce chip info for future multidevice support Jonathan Santos
2025-08-25 14:33 ` Jonathan Cameron [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20250825153325.421d2a4d@jic23-huawei \
    --to=jic23@kernel.org \
    --cc=Jonathan.Santos@analog.com \
    --cc=Michael.Hennerich@analog.com \
    --cc=andy@kernel.org \
    --cc=conor+dt@kernel.org \
    --cc=devicetree@vger.kernel.org \
    --cc=dlechner@baylibre.com \
    --cc=krzk+dt@kernel.org \
    --cc=lars@metafoo.de \
    --cc=linux-iio@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=marcelo.schmitt1@gmail.com \
    --cc=nuno.sa@analog.com \
    --cc=robh@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox