2023-05-23 12:35:36

by Peter Rosin

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

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 <[email protected]>
---
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




2023-05-23 15:35:48

by Jakub Kicinski

[permalink] [raw]
Subject: Re: [PATCH] bitfield: suggest using bitwise OR when combining bitfields

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..