public inbox for linux-iio@vger.kernel.org
 help / color / mirror / Atom feed
From: Jonathan Cameron <jic23@kernel.org>
To: Marcelo Machado Lage <marcelomlage@usp.br>
Cc: andy@kernel.org, dlechner@baylibre.com, nuno.sa@analog.com,
	Vinicius Lira <vinilira@usp.br>,
	linux-iio@vger.kernel.org
Subject: Re: [PATCH v2 1/2] iio: adc: mcp3422: rewrite mask macros using bitfield macros
Date: Sun, 19 Apr 2026 14:24:07 +0100	[thread overview]
Message-ID: <20260419142407.4a8b7dec@jic23-huawei> (raw)
In-Reply-To: <20260417165747.507487-2-marcelomlage@usp.br>

On Fri, 17 Apr 2026 13:57:46 -0300
Marcelo Machado Lage <marcelomlage@usp.br> wrote:

> Rewrite MCP3422_CHANNEL_MASK, MCP3422_PGA_MASK, MCP3422_PGA_MASK
> and MCP3422_CONT_SAMPLING using GENMASK() and BIT() macros from
> bitfield.h.
> 
> The other macros MCP3422_SRATE_{240, 60, 15, 3} were not changed
> because they are also used as array indices.
> 
> Signed-off-by: Marcelo Machado Lage <marcelomlage@usp.br>
> Co-developed-by: Vinicius Lira <vinilira@usp.br>
> Signed-off-by: Vinicius Lira <vinilira@usp.br>
> ---
>  drivers/iio/adc/mcp3422.c | 9 +++++----
>  1 file changed, 5 insertions(+), 4 deletions(-)
> 
> diff --git a/drivers/iio/adc/mcp3422.c b/drivers/iio/adc/mcp3422.c
> index 50834fdcf738..59bf73304588 100644
> --- a/drivers/iio/adc/mcp3422.c
> +++ b/drivers/iio/adc/mcp3422.c
> @@ -13,6 +13,7 @@
>   * voltage unit is nV.
>   */
>  
> +#include <linux/bits.h>
>  #include <linux/err.h>
>  #include <linux/i2c.h>
>  #include <linux/module.h>
> @@ -25,9 +26,9 @@
>  #include <linux/iio/sysfs.h>
>  
>  /* Masks */

This comment covers the first few defines, but not the reset.
Delete it whilst you are here to avoid future confusion.

> -#define MCP3422_CHANNEL_MASK	0x60
> -#define MCP3422_PGA_MASK	0x03
> -#define MCP3422_SRATE_MASK	0x0C
> +#define MCP3422_CHANNEL_MASK	GENMASK(6, 5)
> +#define MCP3422_PGA_MASK	GENMASK(1, 0)
> +#define MCP3422_SRATE_MASK	GENMASK(3, 2)
>  #define MCP3422_SRATE_240	0x0
>  #define MCP3422_SRATE_60	0x1
>  #define MCP3422_SRATE_15	0x2
> @@ -36,7 +37,7 @@
>  #define MCP3422_PGA_2	1
>  #define MCP3422_PGA_4	2
>  #define MCP3422_PGA_8	3
> -#define MCP3422_CONT_SAMPLING	0x10
> +#define MCP3422_CONT_SAMPLING	BIT(4)
>  
>  #define MCP3422_CHANNEL(config)	(((config) & MCP3422_CHANNEL_MASK) >> 5)
>  #define MCP3422_PGA(config)	((config) & MCP3422_PGA_MASK)


  parent reply	other threads:[~2026-04-19 13:24 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-04-17 16:57 [PATCH v2 0/2] iio: adc: mcp3422: apply bit manipulation macros Marcelo Machado Lage
2026-04-17 16:57 ` [PATCH v2 1/2] iio: adc: mcp3422: rewrite mask macros using bitfield macros Marcelo Machado Lage
2026-04-18 16:26   ` David Lechner
2026-04-19 13:24   ` Jonathan Cameron [this message]
2026-04-17 16:57 ` [PATCH v2 2/2] iio: adc: mcp3422: write bit operations with " Marcelo Machado Lage
2026-04-18  0:34   ` Andy Shevchenko

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=20260419142407.4a8b7dec@jic23-huawei \
    --to=jic23@kernel.org \
    --cc=andy@kernel.org \
    --cc=dlechner@baylibre.com \
    --cc=linux-iio@vger.kernel.org \
    --cc=marcelomlage@usp.br \
    --cc=nuno.sa@analog.com \
    --cc=vinilira@usp.br \
    /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