[PATCH] bitfield: suggest using bitwise OR when combining bitfields

Peter Rosin posted 1 patch 2 years, 8 months ago
include/linux/bitfield.h | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
[PATCH] bitfield: suggest using bitwise OR when combining bitfields
Posted by Peter Rosin 2 years, 8 months ago
Logical OR fails to deliver the desired result. Most of the time.

Fixes: 3e9b3112ec74 ("add basic register-field manipulation macros")
Fixes: e2192de59e45 ("bitfield: add FIELD_PREP_CONST()")
Signed-off-by: Peter Rosin <peda@axentia.se>
---
 include/linux/bitfield.h | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/include/linux/bitfield.h b/include/linux/bitfield.h
index ebfa12f69501..d70fc96585e2 100644
--- a/include/linux/bitfield.h
+++ b/include/linux/bitfield.h
@@ -107,7 +107,7 @@
  * @_val:  value to put in the field
  *
  * FIELD_PREP() masks and shifts up the value.  The result should
- * be combined with other fields of the bitfield using logical OR.
+ * be combined with other fields of the bitfield using bitwise OR.
  */
 #define FIELD_PREP(_mask, _val)						\
 	({								\
@@ -123,7 +123,7 @@
  * @_val:  value to put in the field
  *
  * FIELD_PREP_CONST() masks and shifts up the value.  The result should
- * be combined with other fields of the bitfield using logical OR.
+ * be combined with other fields of the bitfield using bitwise OR.
  *
  * Unlike FIELD_PREP() this is a constant expression and can therefore
  * be used in initializers. Error checking is less comfortable for this
-- 
2.20.1
Re: [PATCH] bitfield: suggest using bitwise OR when combining bitfields
Posted by Jakub Kicinski 2 years, 8 months ago
On Tue, 23 May 2023 14:16:30 +0200 Peter Rosin wrote:
> Logical OR fails to deliver the desired result. Most of the time.
> 
> Fixes: 3e9b3112ec74 ("add basic register-field manipulation macros")
> Fixes: e2192de59e45 ("bitfield: add FIELD_PREP_CONST()")

Fixes tags for comment changes are an overkill. The change looks good.

Who are you expecting to take this patch? Feel free to repost this
CCing netdev@ so networking can take it, otherwise maybe Andrew will?
Not sure..