Skip to contentSkip to conversation

iio: frequency: ad9832: Update bit manipulation macros to use FIELD_PREP and GENMASK

PATCH Superseded Siddharth Menon 1 participant 1 message Mar 26, 2025

Subsystems (4)

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 iio: frequency: ad9832: Update bit manipulation macros to use FIELD_PREP and GENMASK

Update AD9832_PHASE and RES_MASK to use FIELD_PREP and GENMASK for clean bitmask generation and improved maintainability.

---
 drivers/staging/iio/frequency/ad9832.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/staging/iio/frequency/ad9832.c +2 -2
index 07baa574aa46..1627b0d5de8a 100644
@@ -62,7 +62,7 @@
 #define AD9832_CMD_SLEEPRESCLR	0xC
 
 #define AD9832_FREQ		BIT(11)
-#define AD9832_PHASE(x)		(((x) & 3) << 9)
+#define AD9832_PHASE(x)	FIELD_PREP(GENMASK(10, 9), x)
 #define AD9832_SYNC		BIT(13)
 #define AD9832_SELSRC		BIT(12)
 #define AD9832_SLEEP		BIT(13)
@@ -70,7 +70,7 @@
 #define AD9832_CLR		BIT(11)
 #define AD9832_FREQ_BITS	32
 #define AD9832_PHASE_BITS	12
-#define RES_MASK(bits)		((1 << (bits)) - 1)
+#define RES_MASK(bits)	GENMASK((bits) - 1, 0)
 #define AD9832_CMD_MSK	GENMASK(15, 12)
 #define AD9832_ADD_MSK	GENMASK(11, 8)
 #define AD9832_DAT_MSK	GENMASK(7, 0)
Signature · 1 line
2.49.0