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: <CAMknhBFso4RXhhLSN_x1JEDCi70y-2BDVHKAzuh=bp7dt7dgxA@mail.gmail.com>
Date: Mon, 23 Sep 2024 16:50:49 +0200
From: David Lechner <dlechner@...libre.com>
To: Alexandru Ardelean <aardelean@...libre.com>
Cc: linux-iio@...r.kernel.org, linux-kernel@...r.kernel.org, 
	devicetree@...r.kernel.org, jic23@...nel.org, krzk+dt@...nel.org, 
	robh@...nel.org, lars@...afoo.de, michael.hennerich@...log.com, 
	gstols@...libre.com
Subject: Re: [PATCH v7 1/8] iio: adc: ad7606: add 'bits' parameter to channels macros

On Thu, Sep 19, 2024 at 3:04 PM Alexandru Ardelean
<aardelean@...libre.com> wrote:
>
> There are some newer additions to the AD7606 family, which support 18 bit
> precision. Up until now, all chips were 16 bit.
>
> This change adds a 'bits' parameter to the AD760X_CHANNEL macro and renames
> 'ad7606_channels' -> 'ad7606_channels_16bit' for the current devices.
>
> The AD7606_SW_CHANNEL() macro is also introduced, as a short-hand for IIO
> channels in SW mode.
>
> Signed-off-by: Alexandru Ardelean <aardelean@...libre.com>
> ---

...

> diff --git a/drivers/iio/adc/ad7606.h b/drivers/iio/adc/ad7606.h
> index 6649e84d25de..204a343067e5 100644
> --- a/drivers/iio/adc/ad7606.h
> +++ b/drivers/iio/adc/ad7606.h
> @@ -8,7 +8,7 @@
>  #ifndef IIO_ADC_AD7606_H_
>  #define IIO_ADC_AD7606_H_
>
> -#define AD760X_CHANNEL(num, mask_sep, mask_type, mask_all) {   \
> +#define AD760X_CHANNEL(num, mask_sep, mask_type, mask_all, bits) {     \
>                 .type = IIO_VOLTAGE,                            \
>                 .indexed = 1,                                   \
>                 .channel = num,                                 \
> @@ -19,24 +19,26 @@
>                 .scan_index = num,                              \
>                 .scan_type = {                                  \
>                         .sign = 's',                            \
> -                       .realbits = 16,                         \
> -                       .storagebits = 16,                      \
> +                       .realbits = (bits),                     \
> +                       .storagebits = (bits) > 16 ? 32 : 16,   \
>                         .endianness = IIO_CPU,                  \
>                 },                                              \
>  }
>
>  #define AD7605_CHANNEL(num)                            \
>         AD760X_CHANNEL(num, BIT(IIO_CHAN_INFO_RAW),     \
> -               BIT(IIO_CHAN_INFO_SCALE), 0)
> +               BIT(IIO_CHAN_INFO_SCALE), 0, 16)
>
> -#define AD7606_CHANNEL(num)                            \
> +#define AD7606_CHANNEL(num, bits)                      \
>         AD760X_CHANNEL(num, BIT(IIO_CHAN_INFO_RAW),     \
>                 BIT(IIO_CHAN_INFO_SCALE),               \
> -               BIT(IIO_CHAN_INFO_OVERSAMPLING_RATIO))
> +               BIT(IIO_CHAN_INFO_OVERSAMPLING_RATIO), bits)
>
> -#define AD7616_CHANNEL(num)    \
> +#define AD7606_SW_CHANNEL(num, bits)   \
>         AD760X_CHANNEL(num, BIT(IIO_CHAN_INFO_RAW) | BIT(IIO_CHAN_INFO_SCALE),\
> -               0, BIT(IIO_CHAN_INFO_OVERSAMPLING_RATIO))
> +               0, BIT(IIO_CHAN_INFO_OVERSAMPLING_RATIO), bits)
> +
> +#define AD7616_CHANNEL(num)    AD7606_SW_CHANNEL(num, 16)

It looks like the AD7616_CHANNEL macro is no longer used, so can be
dropped. Or alternately, don't change the lines below to use
AD7606_SW_CHANNEL.

With either of those changes:

Reviewed-by: David Lechner <dlechner@...libre.com>

>
>  /**
>   * struct ad7606_chip_info - chip specific information
> diff --git a/drivers/iio/adc/ad7606_spi.c b/drivers/iio/adc/ad7606_spi.c
> index 62ec12195307..e00f58a6a0e9 100644
> --- a/drivers/iio/adc/ad7606_spi.c
> +++ b/drivers/iio/adc/ad7606_spi.c
> @@ -67,14 +67,14 @@ static const struct iio_chan_spec ad7616_sw_channels[] = {
>
>  static const struct iio_chan_spec ad7606b_sw_channels[] = {
>         IIO_CHAN_SOFT_TIMESTAMP(8),
> -       AD7616_CHANNEL(0),
> -       AD7616_CHANNEL(1),
> -       AD7616_CHANNEL(2),
> -       AD7616_CHANNEL(3),
> -       AD7616_CHANNEL(4),
> -       AD7616_CHANNEL(5),
> -       AD7616_CHANNEL(6),
> -       AD7616_CHANNEL(7),
> +       AD7606_SW_CHANNEL(0, 16),
> +       AD7606_SW_CHANNEL(1, 16),
> +       AD7606_SW_CHANNEL(2, 16),
> +       AD7606_SW_CHANNEL(3, 16),
> +       AD7606_SW_CHANNEL(4, 16),
> +       AD7606_SW_CHANNEL(5, 16),
> +       AD7606_SW_CHANNEL(6, 16),
> +       AD7606_SW_CHANNEL(7, 16),
>  };
>
>  static const unsigned int ad7606B_oversampling_avail[9] = {
> --
> 2.46.0
>

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ