Linux kernel staging patches
 help / color / mirror / Atom feed
From: Jonathan Cameron <jic23@kernel.org>
To: Michael Harris <michaelharriscode@gmail.com>
Cc: "Lars-Peter Clausen" <lars@metafoo.de>,
	"Michael Hennerich" <Michael.Hennerich@analog.com>,
	"Greg Kroah-Hartman" <gregkh@linuxfoundation.org>,
	"David Lechner" <dlechner@baylibre.com>,
	"Nuno Sá" <nuno.sa@analog.com>,
	"Andy Shevchenko" <andy@kernel.org>,
	linux-iio@vger.kernel.org, linux-staging@lists.linux.dev,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH v2 2/4] staging: iio: adt7316: remove shift/offset macros
Date: Sat, 7 Mar 2026 11:30:11 +0000	[thread overview]
Message-ID: <20260307113011.16da6098@jic23-huawei> (raw)
In-Reply-To: <20260305-adt7316-correct-macros-v2-2-3702e3841c42@gmail.com>

On Thu, 05 Mar 2026 23:16:59 -0800
Michael Harris <michaelharriscode@gmail.com> wrote:

> Remove shift/offset macros and instead use the corresponding mask with
> FIELD_GET(), FIELD_PREP(), or FIELD_FIT().
> 
> In cases where an appropriate mask didn't exist, it was created.
> 
> One of the shift/offset macros was used for a convoluted dynamic
> bitfield extraction. In its place, a helper function,
> adt7316_extract_ad_lsb(), was created so the shift/offset could be
> removed.
> 
> Signed-off-by: Michael Harris <michaelharriscode@gmail.com>

> ---
>  drivers/staging/iio/addac/adt7316.c | 59 ++++++++++++++++++++++---------------
>  1 file changed, 36 insertions(+), 23 deletions(-)
> 
> diff --git a/drivers/staging/iio/addac/adt7316.c b/drivers/staging/iio/addac/adt7316.c
> index 1412808c50c76a68b5771a25c46dd3308c5cbcdb..b8b66f4dd14bb59c3d29fdd569d84f0dd786db9e 100644
> --- a/drivers/staging/iio/addac/adt7316.c
> +++ b/drivers/staging/iio/addac/adt7316.c
> @@ -17,6 +17,7 @@
>  #include <linux/i2c.h>
>  #include <linux/rtc.h>
>  #include <linux/module.h>
> +#include <linux/bitfield.h>
>  
>  #include <linux/iio/iio.h>
>  #include <linux/iio/events.h>
> @@ -31,10 +32,11 @@
>  #define ADT7316_LSB_IN_TEMP_VDD		0x3
>  #define ADT7316_LSB_IN_TEMP_MASK	0x3
>  #define ADT7316_LSB_VDD_MASK		0xC

Convert all masks to GENMASK_U32() rather than just the ones where you
are removing a shift.  That will give us more consistent code and
makes sense as part of this patch.


> -#define ADT7316_LSB_VDD_OFFSET		2
>  #define ADT7316_LSB_EX_TEMP_AIN		0x4
> -#define ADT7316_LSB_EX_TEMP_MASK	0x3
> -#define ADT7516_LSB_AIN_SHIFT		2
> +#define ADT7316_LSB_EX_TEMP_AIN1_MASK	GENMASK_U32(1, 0)
Why GENMASK_U32()?  The registers seem to be 8 bit.
I'm not sure we care that much about the extra checks the sized
variant brings but if we do want to use it use the U8() variant.

Jonathan



  parent reply	other threads:[~2026-03-07 11:30 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-03-06  7:16 [PATCH v2 0/4] correct macro issues Michael Harris
2026-03-06  7:16 ` [PATCH v2 1/4] staging: iio: adt7316: refactor temperature calculation logic Michael Harris
2026-03-06 14:51   ` Andy Shevchenko
2026-03-07 11:33   ` Jonathan Cameron
2026-03-06  7:16 ` [PATCH v2 2/4] staging: iio: adt7316: remove shift/offset macros Michael Harris
2026-03-06 14:53   ` Andy Shevchenko
2026-03-10  1:32     ` Michael Harris
2026-03-10 11:29       ` Andy Shevchenko
2026-03-07 11:30   ` Jonathan Cameron [this message]
2026-03-06  7:17 ` [PATCH v2 3/4] staging: iio: adt7316: add config names to registers and reorder Michael Harris
2026-03-06 15:04   ` Andy Shevchenko
2026-03-06  7:17 ` [PATCH v2 4/4] staging: iio: adt7316: convert magic numbers to BIT_U32() or GENMASK_U32() Michael Harris
2026-03-06 15:05   ` Andy Shevchenko
2026-03-07 11:33   ` 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=20260307113011.16da6098@jic23-huawei \
    --to=jic23@kernel.org \
    --cc=Michael.Hennerich@analog.com \
    --cc=andy@kernel.org \
    --cc=dlechner@baylibre.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=lars@metafoo.de \
    --cc=linux-iio@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-staging@lists.linux.dev \
    --cc=michaelharriscode@gmail.com \
    --cc=nuno.sa@analog.com \
    /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