[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20251209100313.2867-4-david.laight.linux@gmail.com>
Date: Tue, 9 Dec 2025 10:03:07 +0000
From: david.laight.linux@...il.com
To: Yury Norov <yury.norov@...il.com>,
Rasmus Villemoes <linux@...musvillemoes.dk>,
linux-kernel@...r.kernel.org,
linux-usb@...r.kernel.org,
Geert Uytterhoeven <geert+renesas@...der.be>,
Alexandre Belloni <alexandre.belloni@...tlin.com>,
Jonathan Cameron <Jonathan.Cameron@...wei.com>,
Crt Mori <cmo@...exis.com>,
Richard Genoud <richard.genoud@...tlin.com>,
Andy Shevchenko <andriy.shevchenko@...el.com>,
Luo Jie <quic_luoj@...cinc.com>,
Peter Zijlstra <peterz@...radead.org>,
Jakub Kicinski <kuba@...nel.org>,
netdev@...r.kernel.org,
"David S . Miller" <davem@...emloft.net>,
Simon Horman <simon.horman@...ronome.com>,
Mika Westerberg <mika.westerberg@...ux.intel.com>,
Andreas Noever <andreas.noever@...il.com>,
Yehezkel Bernat <YehezkelShB@...il.com>,
Nicolas Frattaroli <nicolas.frattaroli@...labora.com>
Cc: David Laight <david.laight.linux@...il.com>
Subject: [PATCH 3/9] bitmap: Use FIELD_PREP() in expansion of FIELD_PREP_WM16()
From: David Laight <david.laight.linux@...il.com>
Instead of directly expanding __BF_FIELD_CHECK() (which really ought
not be used outside bitfield) and open-coding the generation of the
masked value, just call FIELD_PREP() and add an extra check for
the mask being at most 16 bits.
Signed-off-by: David Laight <david.laight.linux@...il.com>
---
include/linux/hw_bitfield.h | 17 ++++++++---------
1 file changed, 8 insertions(+), 9 deletions(-)
diff --git a/include/linux/hw_bitfield.h b/include/linux/hw_bitfield.h
index df202e167ce4..d7f21b60449b 100644
--- a/include/linux/hw_bitfield.h
+++ b/include/linux/hw_bitfield.h
@@ -23,15 +23,14 @@
* register, a bit in the lower half is only updated if the corresponding bit
* in the upper half is high.
*/
-#define FIELD_PREP_WM16(_mask, _val) \
- ({ \
- typeof(_val) __val = _val; \
- typeof(_mask) __mask = _mask; \
- __BF_FIELD_CHECK(__mask, ((u16)0U), __val, \
- "HWORD_UPDATE: "); \
- (((typeof(__mask))(__val) << __bf_shf(__mask)) & (__mask)) | \
- ((__mask) << 16); \
- })
+#define FIELD_PREP_WM16(mask, val) \
+({ \
+ __auto_type _mask = mask; \
+ u32 _val = FIELD_PREP(_mask, val); \
+ BUILD_BUG_ON_MSG(_mask > 0xffffu, \
+ "FIELD_PREP_WM16: mask too large"); \
+ _val | (_mask << 16); \
+})
/**
* FIELD_PREP_WM16_CONST() - prepare a constant bitfield element with a mask in
--
2.39.5
Powered by blists - more mailing lists