[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20251209100313.2867-6-david.laight.linux@gmail.com>
Date: Tue, 9 Dec 2025 10:03:09 +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 5/9] bitfield: FIELD_MODIFY: Only do a single read/write on the target
From: David Laight <david.laight.linux@...il.com>
Replace the:
*reg &= ~mask; *reg |= new_value;
with a single assignment.
While the compiler will usually optimise the extra access away
it isn't guaranteed.
Signed-off-by: David Laight <david.laight.linux@...il.com>
---
include/linux/bitfield.h | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)
diff --git a/include/linux/bitfield.h b/include/linux/bitfield.h
index 3e013da9ea12..3e0e8533bb66 100644
--- a/include/linux/bitfield.h
+++ b/include/linux/bitfield.h
@@ -200,8 +200,7 @@
__auto_type _val = 1 ? (val) : _mask; \
typecheck_pointer(_reg_p); \
__BF_FIELD_CHECK(_mask, *_reg_p, _val, "FIELD_MODIFY: "); \
- *_reg_p &= ~_mask; \
- *_reg_p |= ((_val << __bf_shf(_mask)) & _mask); \
+ *_reg_p = (*_reg_p & ~_mask) | ((_val << __bf_shf(_mask)) & _mask); \
})
extern void __compiletime_error("value doesn't fit into mask")
--
2.39.5
Powered by blists - more mailing lists