public inbox for devicetree@vger.kernel.org
 help / color / mirror / Atom feed
From: Jonathan Cameron <jic23@kernel.org>
To: Guillaume Stols <gstols@baylibre.com>
Cc: Lars-Peter Clausen <lars@metafoo.de>,
	Michael Hennerich <Michael.Hennerich@analog.com>,
	Nuno Sa <nuno.sa@analog.com>, Rob Herring <robh@kernel.org>,
	Krzysztof Kozlowski <krzk+dt@kernel.org>,
	Conor Dooley <conor+dt@kernel.org>,
	Jonathan Cameron <Jonathan.Cameron@huawei.com>,
	linux-iio@vger.kernel.org, linux-kernel@vger.kernel.org,
	devicetree@vger.kernel.org, dlechner@baylibre.com,
	jstephan@baylibre.com, aardelean@baylibre.com,
	adureghello@baylibre.com
Subject: Re: [PATCH 8/9] iio: adc: ad7606: Simplify channel macros
Date: Tue, 26 Nov 2024 18:46:04 +0000	[thread overview]
Message-ID: <20241126184604.5a4c74d0@jic23-huawei> (raw)
In-Reply-To: <20241121-ad7606_add_iio_backend_software_mode-v1-8-8a693a5e3fa9@baylibre.com>

On Thu, 21 Nov 2024 10:18:30 +0000
Guillaume Stols <gstols@baylibre.com> wrote:

> This is a preparation to add the new channels for software mode and
> hardware mode in iio backend mod more easily.

I'm not sure this 'simplifies' anything!  Maybe change title.

> 
> Signed-off-by: Guillaume Stols <gstols@baylibre.com>
> ---
>  drivers/iio/adc/ad7606.h | 51 ++++++++++++++++++++++++------------------------
>  1 file changed, 25 insertions(+), 26 deletions(-)
> 
> diff --git a/drivers/iio/adc/ad7606.h b/drivers/iio/adc/ad7606.h
> index eca7ea99e24d..74896d9f1929 100644
> --- a/drivers/iio/adc/ad7606.h
> +++ b/drivers/iio/adc/ad7606.h
> @@ -40,37 +40,19 @@
>  #define AD7606_RANGE_CH_ADDR(ch)	(0x03 + ((ch) >> 1))
>  #define AD7606_OS_MODE			0x08
>  
> -#define AD760X_CHANNEL(num, mask_sep, mask_type, mask_all, bits) {	\
> +#define AD760X_CHANNEL(num, mask_sep, mask_type, mask_all,	\
> +		mask_sep_avail, mask_all_avail, bits) {		\
>  		.type = IIO_VOLTAGE,				\
>  		.indexed = 1,					\
>  		.channel = num,					\
>  		.address = num,					\
>  		.info_mask_separate = mask_sep,			\
> +		.info_mask_separate_available =			\
> +			mask_sep_avail,				\
>  		.info_mask_shared_by_type = mask_type,		\
>  		.info_mask_shared_by_all = mask_all,		\
> -		.scan_index = num,				\
> -		.scan_type = {					\
> -			.sign = 's',				\
> -			.realbits = (bits),			\
> -			.storagebits = (bits) > 16 ? 32 : 16,	\
> -			.endianness = IIO_CPU,			\
> -		},						\
> -}
> -
> -#define AD7606_SW_CHANNEL(num, bits) {				\
> -		.type = IIO_VOLTAGE,				\
> -		.indexed = 1,					\
> -		.channel = num,					\
> -		.address = num,					\
> -		.info_mask_separate =				\
> -			BIT(IIO_CHAN_INFO_RAW) |		\
> -			BIT(IIO_CHAN_INFO_SCALE),		\
> -		.info_mask_separate_available =			\
> -			BIT(IIO_CHAN_INFO_SCALE),		\
> -		.info_mask_shared_by_all =			\
> -			BIT(IIO_CHAN_INFO_OVERSAMPLING_RATIO),	\
>  		.info_mask_shared_by_all_available =		\
> -			BIT(IIO_CHAN_INFO_OVERSAMPLING_RATIO),	\
> +			mask_all_avail,				\
>  		.scan_index = num,				\
>  		.scan_type = {					\
>  			.sign = 's',				\
> @@ -82,12 +64,28 @@
>  
>  #define AD7605_CHANNEL(num)				\
>  	AD760X_CHANNEL(num, BIT(IIO_CHAN_INFO_RAW),	\
> -		BIT(IIO_CHAN_INFO_SCALE), 0, 16)
> +		BIT(IIO_CHAN_INFO_SCALE), 0, 0, 0, 16)
>  
>  #define AD7606_CHANNEL(num, bits)			\
>  	AD760X_CHANNEL(num, BIT(IIO_CHAN_INFO_RAW),	\
>  		BIT(IIO_CHAN_INFO_SCALE),		\
> -		BIT(IIO_CHAN_INFO_OVERSAMPLING_RATIO), bits)
> +		BIT(IIO_CHAN_INFO_OVERSAMPLING_RATIO),	\
> +		0, 0, bits)
> +
> +#define AD7606_SW_CHANNEL(num, bits)			\
> +	AD760X_CHANNEL(num,				\
> +		/* mask separate */			\
> +		BIT(IIO_CHAN_INFO_RAW) |		\
> +		BIT(IIO_CHAN_INFO_SCALE),		\

Maybe use some longer lines to avoid so much wrapping.

> +		/* mask type */				\
> +		BIT(IIO_CHAN_INFO_OVERSAMPLING_RATIO),	\
> +		/* mask all */				\
> +		0,					\
> +		/* mask separate available */		\
> +		BIT(IIO_CHAN_INFO_SCALE),		\
> +		/* mask all available */		\
> +		BIT(IIO_CHAN_INFO_OVERSAMPLING_RATIO),	\
> +		bits)
>  
>  #define AD7616_CHANNEL(num)	AD7606_SW_CHANNEL(num, 16)
>  
> @@ -95,7 +93,8 @@
>  	AD760X_CHANNEL(num, 0,				\
>  		BIT(IIO_CHAN_INFO_SCALE),		\
>  		BIT(IIO_CHAN_INFO_SAMP_FREQ) |		\
> -		BIT(IIO_CHAN_INFO_OVERSAMPLING_RATIO), 16)
> +		BIT(IIO_CHAN_INFO_OVERSAMPLING_RATIO),  \
> +		0, 0, 16)
>  
>  struct ad7606_state;
>  
> 


  reply	other threads:[~2024-11-26 18:46 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-11-21 10:18 [PATCH 0/9] Add support for Software mode on AD7606's iio backend driver Guillaume Stols
2024-11-21 10:18 ` [PATCH 1/9] iio: adc: ad7606: Fix hardcoded offset in the ADC channels Guillaume Stols
2024-11-26 18:15   ` Jonathan Cameron
2024-11-21 10:18 ` [PATCH 2/9] dt-bindings: iio: dac: adi-axi-adc: Add ad7606 variant Guillaume Stols
2024-11-21 16:57   ` David Lechner
2024-11-21 19:53     ` Conor Dooley
2024-11-26 17:59       ` Jonathan Cameron
2024-11-26 18:12         ` Conor Dooley
2024-11-21 10:18 ` [PATCH 3/9] iio:adc: ad7606: Move the software mode configuration Guillaume Stols
2024-11-26 18:21   ` Jonathan Cameron
2024-11-21 10:18 ` [PATCH 4/9] iio: adc: ad7606: Move software functions into common file Guillaume Stols
2024-11-26 18:29   ` Jonathan Cameron
2024-11-21 10:18 ` [PATCH 5/9] iio: adc: adi-axi-adc: Add platform children support Guillaume Stols
2024-11-26 18:41   ` Jonathan Cameron
2024-11-21 10:18 ` [PATCH 6/9] iio: adc: adi-axi-adc: Add support for AD7606 register writing Guillaume Stols
2024-11-26 18:43   ` Jonathan Cameron
2024-11-21 10:18 ` [PATCH 7/9] iio: adc: ad7606: change r/w_register signature Guillaume Stols
2024-11-21 10:18 ` [PATCH 8/9] iio: adc: ad7606: Simplify channel macros Guillaume Stols
2024-11-26 18:46   ` Jonathan Cameron [this message]
2024-11-21 10:18 ` [PATCH 9/9] iio: adc: ad7606: Add support for writing registers when using backend Guillaume Stols
2024-11-26 18:48   ` Jonathan Cameron
2024-11-26 19:13     ` David Lechner
2024-11-26 18:00 ` [PATCH 0/9] Add support for Software mode on AD7606's iio backend driver Jonathan Cameron

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=20241126184604.5a4c74d0@jic23-huawei \
    --to=jic23@kernel.org \
    --cc=Jonathan.Cameron@huawei.com \
    --cc=Michael.Hennerich@analog.com \
    --cc=aardelean@baylibre.com \
    --cc=adureghello@baylibre.com \
    --cc=conor+dt@kernel.org \
    --cc=devicetree@vger.kernel.org \
    --cc=dlechner@baylibre.com \
    --cc=gstols@baylibre.com \
    --cc=jstephan@baylibre.com \
    --cc=krzk+dt@kernel.org \
    --cc=lars@metafoo.de \
    --cc=linux-iio@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --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