The Linux Kernel Mailing List
 help / color / mirror / Atom feed
* [PATCH v7] iio: imu: smi330: Convert to common field_{get,prep}() helpers
@ 2026-01-15 14:24 Geert Uytterhoeven
  2026-01-16 19:45 ` Jonathan Cameron
  2026-01-17  9:56 ` AW: " Shen Jianping (ME-SE/EAD2)
  0 siblings, 2 replies; 3+ messages in thread
From: Geert Uytterhoeven @ 2026-01-15 14:24 UTC (permalink / raw)
  To: Jianping Shen, Jonathan Cameron, David Lechner, Nuno Sá,
	Andy Shevchenko
  Cc: linux-iio, linux-kernel, Geert Uytterhoeven

Drop the driver-specific smi330_field_get() and smi330_field_prep()
macros, in favor of the globally available variants from
<linux/bitfield.h>.

Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be>
---
v7:
  - Update for the renamed smi330_field_{get,prep}() helpers,

v6:
  - No changes,

v5:
  - New.
---
 drivers/iio/imu/smi330/smi330_core.c | 8 ++------
 1 file changed, 2 insertions(+), 6 deletions(-)

diff --git a/drivers/iio/imu/smi330/smi330_core.c b/drivers/iio/imu/smi330/smi330_core.c
index 7564f12543e0ca04..83e0dff5d973d046 100644
--- a/drivers/iio/imu/smi330/smi330_core.c
+++ b/drivers/iio/imu/smi330/smi330_core.c
@@ -67,10 +67,6 @@
 #define SMI330_CHIP_ID 0x42
 #define SMI330_SOFT_RESET_DELAY 2000
 
-/* Non-constant mask variant of FIELD_GET() and FIELD_PREP() */
-#define smi330_field_get(_mask, _reg) (((_reg) & (_mask)) >> (ffs(_mask) - 1))
-#define smi330_field_prep(_mask, _val) (((_val) << (ffs(_mask) - 1)) & (_mask))
-
 #define SMI330_ACCEL_CHANNEL(_axis) {					\
 	.type = IIO_ACCEL,						\
 	.modified = 1,							\
@@ -361,7 +357,7 @@ static int smi330_get_sensor_config(struct smi330_data *data,
 	if (ret)
 		return ret;
 
-	reg_val = smi330_field_get(attr->mask, reg_val);
+	reg_val = field_get(attr->mask, reg_val);
 
 	if (attr->type == IIO_VAL_INT) {
 		for (i = 0; i < attr->len; i++) {
@@ -410,7 +406,7 @@ static int smi330_set_sensor_config(struct smi330_data *data,
 	if (ret)
 		return ret;
 
-	reg_val = smi330_field_prep(attr->mask, reg_val);
+	reg_val = field_prep(attr->mask, reg_val);
 	ret = regmap_update_bits(data->regmap, reg, attr->mask, reg_val);
 	if (ret)
 		return ret;
-- 
2.43.0


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

* Re: [PATCH v7] iio: imu: smi330: Convert to common field_{get,prep}() helpers
  2026-01-15 14:24 [PATCH v7] iio: imu: smi330: Convert to common field_{get,prep}() helpers Geert Uytterhoeven
@ 2026-01-16 19:45 ` Jonathan Cameron
  2026-01-17  9:56 ` AW: " Shen Jianping (ME-SE/EAD2)
  1 sibling, 0 replies; 3+ messages in thread
From: Jonathan Cameron @ 2026-01-16 19:45 UTC (permalink / raw)
  To: Geert Uytterhoeven
  Cc: Jianping Shen, David Lechner, Nuno Sá, Andy Shevchenko,
	linux-iio, linux-kernel

On Thu, 15 Jan 2026 15:24:16 +0100
Geert Uytterhoeven <geert+renesas@glider.be> wrote:

> Drop the driver-specific smi330_field_get() and smi330_field_prep()
> macros, in favor of the globally available variants from
> <linux/bitfield.h>.
> 
> Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be>
Hi Geert

Thanks for coming back to this.

Applied to the testing branch of iio.git. Once the bots are happy with
that I'll push it out as togreg for linux-next to pick up.

Jonathan

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

* AW: [PATCH v7] iio: imu: smi330: Convert to common field_{get,prep}() helpers
  2026-01-15 14:24 [PATCH v7] iio: imu: smi330: Convert to common field_{get,prep}() helpers Geert Uytterhoeven
  2026-01-16 19:45 ` Jonathan Cameron
@ 2026-01-17  9:56 ` Shen Jianping (ME-SE/EAD2)
  1 sibling, 0 replies; 3+ messages in thread
From: Shen Jianping (ME-SE/EAD2) @ 2026-01-17  9:56 UTC (permalink / raw)
  To: Geert Uytterhoeven, Jonathan Cameron, David Lechner, Nuno Sá,
	Andy Shevchenko
  Cc: linux-iio@vger.kernel.org, linux-kernel@vger.kernel.org


>Betreff: [PATCH v7] iio: imu: smi330: Convert to common field_{get,prep}() helpers
>
>Drop the driver-specific smi330_field_get() and smi330_field_prep() macros, in
>favor of the globally available variants from <linux/bitfield.h>.
>
>Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be>
>---
>v7:
>  - Update for the renamed smi330_field_{get,prep}() helpers,
>
>v6:
>  - No changes,
>
>v5:
>  - New.
>---
> drivers/iio/imu/smi330/smi330_core.c | 8 ++------
> 1 file changed, 2 insertions(+), 6 deletions(-)
>
>diff --git a/drivers/iio/imu/smi330/smi330_core.c
>b/drivers/iio/imu/smi330/smi330_core.c
>index 7564f12543e0ca04..83e0dff5d973d046 100644
>--- a/drivers/iio/imu/smi330/smi330_core.c
>+++ b/drivers/iio/imu/smi330/smi330_core.c
>@@ -67,10 +67,6 @@
> #define SMI330_CHIP_ID 0x42
> #define SMI330_SOFT_RESET_DELAY 2000
>
>-/* Non-constant mask variant of FIELD_GET() and FIELD_PREP() */ -#define
>smi330_field_get(_mask, _reg) (((_reg) & (_mask)) >> (ffs(_mask) - 1)) -#define
>smi330_field_prep(_mask, _val) (((_val) << (ffs(_mask) - 1)) & (_mask))
>-
> #define SMI330_ACCEL_CHANNEL(_axis) {					\
> 	.type = IIO_ACCEL,						\
> 	.modified = 1,							\
>@@ -361,7 +357,7 @@ static int smi330_get_sensor_config(struct smi330_data
>*data,
> 	if (ret)
> 		return ret;
>
>-	reg_val = smi330_field_get(attr->mask, reg_val);
>+	reg_val = field_get(attr->mask, reg_val);
>
> 	if (attr->type == IIO_VAL_INT) {
> 		for (i = 0; i < attr->len; i++) {
>@@ -410,7 +406,7 @@ static int smi330_set_sensor_config(struct smi330_data
>*data,
> 	if (ret)
> 		return ret;
>
>-	reg_val = smi330_field_prep(attr->mask, reg_val);
>+	reg_val = field_prep(attr->mask, reg_val);
> 	ret = regmap_update_bits(data->regmap, reg, attr->mask, reg_val);
> 	if (ret)
> 		return ret;
>--
>2.43.0

Hi Geert

Thanks for using the standard kernel implementation.
Reviewed-by: Jianping Shen <Jianping.Shen@de.bosch.com>



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

end of thread, other threads:[~2026-01-17  9:56 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-01-15 14:24 [PATCH v7] iio: imu: smi330: Convert to common field_{get,prep}() helpers Geert Uytterhoeven
2026-01-16 19:45 ` Jonathan Cameron
2026-01-17  9:56 ` AW: " Shen Jianping (ME-SE/EAD2)

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