Linux IIO development
 help / color / mirror / Atom feed
* [PATCH v2] iio: accel: adxl372: replace manual bitfield ops with FIELD_GET()
@ 2026-07-08  3:06 Caio Groff
  2026-07-08  3:24 ` Maxwell Doose
  2026-07-08  6:52 ` Andy Shevchenko
  0 siblings, 2 replies; 3+ messages in thread
From: Caio Groff @ 2026-07-08  3:06 UTC (permalink / raw)
  To: nuno.sa, Michael.Hennerich, marcelo.schmitt, antoniu.miclaus,
	jic23, dlechner, andy
  Cc: Caio Groff, linux, linux-iio

From: Caio Groff <caio.groff@usp.br>

v2: add missing blank line after reg_val_l assignment

Replace manual bit shifting and masking with FIELD_GET()
macros for clarity and consistency with kernel coding style.

Signed-off-by: Caio Groff <caio.groff@usp.br>
---
 drivers/iio/accel/adxl372.c | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)

diff --git a/drivers/iio/accel/adxl372.c b/drivers/iio/accel/adxl372.c
index e375d068a3f5..daf5813ff50e 100644
--- a/drivers/iio/accel/adxl372.c
+++ b/drivers/iio/accel/adxl372.c
@@ -150,6 +150,11 @@
 #define ADXL372_Y_AXIS_EN(x)			((x) & BIT(1))
 #define ADXL372_Z_AXIS_EN(x)			((x) & BIT(2))
 
+/* ADXL372_TIME_INACT */
+#define ADXL372_TIME_INACT_MASK_H  GENMASK(15, 8)
+#define ADXL372_TIME_INACT_MASK_L  GENMASK(7, 0)
+
+
 /*
  * At +/- 200g with 12-bit resolution, scale is computed as:
  * (200 + 200) * 9.81 / (2^12 - 1) = 0.958241
@@ -577,8 +582,8 @@ static int adxl372_set_inactivity_time_ms(struct adxl372_state *st,
 		scale_factor = st->chip_info->inact_time_scale_low_ms;
 
 	res = DIV_ROUND_CLOSEST(inact_time_ms, scale_factor);
-	reg_val_h = (res >> 8) & 0xFF;
-	reg_val_l = res & 0xFF;
+	reg_val_h = FIELD_GET(ADXL372_TIME_INACT_MASK_H, res);
+	reg_val_l = FIELD_GET(ADXL372_TIME_INACT_MASK_L, res);
 
 	ret = regmap_write(st->regmap, ADXL372_TIME_INACT_H, reg_val_h);
 	if (ret < 0)
-- 
2.53.0


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH v2] iio: accel: adxl372: replace manual bitfield ops with FIELD_GET()
  2026-07-08  3:06 [PATCH v2] iio: accel: adxl372: replace manual bitfield ops with FIELD_GET() Caio Groff
@ 2026-07-08  3:24 ` Maxwell Doose
  2026-07-08  6:52 ` Andy Shevchenko
  1 sibling, 0 replies; 3+ messages in thread
From: Maxwell Doose @ 2026-07-08  3:24 UTC (permalink / raw)
  To: Caio Groff, nuno.sa, Michael.Hennerich, marcelo.schmitt,
	antoniu.miclaus, jic23, dlechner, andy
  Cc: linux, linux-iio

[-- Attachment #1: Type: text/plain, Size: 2111 bytes --]

Hi Caio,

On Tue Jul 7, 2026 at 10:06 PM CDT
Caio Groff <caio.groff@usp.br> wrote:

> From: Caio Groff <caio.groff@usp.br>
>
> v2: add missing blank line after reg_val_l assignment
>
> Replace manual bit shifting and masking with FIELD_GET()
> macros for clarity and consistency with kernel coding style.
>
> Signed-off-by: Caio Groff <caio.groff@usp.br>
> ---
>  drivers/iio/accel/adxl372.c | 9 +++++++--
>  1 file changed, 7 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/iio/accel/adxl372.c b/drivers/iio/accel/adxl372.c
> index e375d068a3f5..daf5813ff50e 100644
> --- a/drivers/iio/accel/adxl372.c
> +++ b/drivers/iio/accel/adxl372.c
> @@ -150,6 +150,11 @@
>  #define ADXL372_Y_AXIS_EN(x)			((x) & BIT(1))
>  #define ADXL372_Z_AXIS_EN(x)			((x) & BIT(2))
>  
> +/* ADXL372_TIME_INACT */
> +#define ADXL372_TIME_INACT_MASK_H  GENMASK(15, 8)
> +#define ADXL372_TIME_INACT_MASK_L  GENMASK(7, 0)
> +
> +
>  /*
>   * At +/- 200g with 12-bit resolution, scale is computed as:
>   * (200 + 200) * 9.81 / (2^12 - 1) = 0.958241
> @@ -577,8 +582,8 @@ static int adxl372_set_inactivity_time_ms(struct adxl372_state *st,
>  		scale_factor = st->chip_info->inact_time_scale_low_ms;
>  
>  	res = DIV_ROUND_CLOSEST(inact_time_ms, scale_factor);
> -	reg_val_h = (res >> 8) & 0xFF;
> -	reg_val_l = res & 0xFF;
> +	reg_val_h = FIELD_GET(ADXL372_TIME_INACT_MASK_H, res);
> +	reg_val_l = FIELD_GET(ADXL372_TIME_INACT_MASK_L, res);
>  
>  	ret = regmap_write(st->regmap, ADXL372_TIME_INACT_H, reg_val_h);
>  	if (ret < 0)

First things first, don't resubmit for minor style issues. Most of the
time these are fixed while applying. Secondly, don't submit a new
version until at least 24 hours have passed, this gives enough time for
more people to review.

Also, put the changelog for new versions underneath the --- so it isn't
included in the commit.

Last thing, don't forget to carry through any tags for new versions
where there was very little or no change from the previous version
(though some people may do it differently).


-- 
best regards,
max


[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 273 bytes --]

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH v2] iio: accel: adxl372: replace manual bitfield ops with FIELD_GET()
  2026-07-08  3:06 [PATCH v2] iio: accel: adxl372: replace manual bitfield ops with FIELD_GET() Caio Groff
  2026-07-08  3:24 ` Maxwell Doose
@ 2026-07-08  6:52 ` Andy Shevchenko
  1 sibling, 0 replies; 3+ messages in thread
From: Andy Shevchenko @ 2026-07-08  6:52 UTC (permalink / raw)
  To: Caio Groff
  Cc: nuno.sa, Michael.Hennerich, marcelo.schmitt, antoniu.miclaus,
	jic23, dlechner, andy, linux, linux-iio

On Wed, Jul 08, 2026 at 12:06:11AM -0300, Caio Groff wrote:

> v2: add missing blank line after reg_val_l assignment
> 
> Replace manual bit shifting and masking with FIELD_GET()
> macros for clarity and consistency with kernel coding style.

All what Maxwell said plus the same comments as per v1 by me.

-- 
With Best Regards,
Andy Shevchenko



^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2026-07-08  6:52 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-07-08  3:06 [PATCH v2] iio: accel: adxl372: replace manual bitfield ops with FIELD_GET() Caio Groff
2026-07-08  3:24 ` Maxwell Doose
2026-07-08  6:52 ` Andy Shevchenko

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox