lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20241126184604.5a4c74d0@jic23-huawei>
Date: Tue, 26 Nov 2024 18:46:04 +0000
From: Jonathan Cameron <jic23@...nel.org>
To: Guillaume Stols <gstols@...libre.com>
Cc: Lars-Peter Clausen <lars@...afoo.de>, Michael Hennerich
 <Michael.Hennerich@...log.com>, Nuno Sa <nuno.sa@...log.com>, Rob Herring
 <robh@...nel.org>, Krzysztof Kozlowski <krzk+dt@...nel.org>, Conor Dooley
 <conor+dt@...nel.org>, Jonathan Cameron <Jonathan.Cameron@...wei.com>,
 linux-iio@...r.kernel.org, linux-kernel@...r.kernel.org,
 devicetree@...r.kernel.org, dlechner@...libre.com, jstephan@...libre.com,
 aardelean@...libre.com, adureghello@...libre.com
Subject: Re: [PATCH 8/9] iio: adc: ad7606: Simplify channel macros

On Thu, 21 Nov 2024 10:18:30 +0000
Guillaume Stols <gstols@...libre.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@...libre.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;
>  
> 


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ