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

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