Skip to contentSkip to conversation

bitops: Reshuffle bitops.h and wordpart,h

PATCH In review Andy Shevchenko 2 participants 4 messages May 7, 2024

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

v2 cover bitops: Reshuffle bitops.h and wordpart,h

Move word part related macros to the respective header. While at it, fix the inclusion mess in lib/usercopy.h.

Andy Shevchenko (2):
bitops: Move aligned_byte_mask() to wordpart.h
usercopy: Don't use "proxy" headers

 include/linux/bitops.h   | 7 -------
 include/linux/wordpart.h | 7 +++++++
 lib/usercopy.c           | 9 +++++++--
 3 files changed, 14 insertions(+), 9 deletions(-)
Signature · 1 line
2.43.0.rc1.1336.g36b5255a03ac
#1 lore raw

PATCH v2 1/2 bitops: Move aligned_byte_mask() to wordpart.h

The bitops.h is for bit related operations. The aligned_byte_mask() is about byte (or part of the machine word) operations, for which we have a separate header, move the mentioned macro to wordpart.h to consolidate similar operations.

---
 include/linux/bitops.h   | 7 -------
 include/linux/wordpart.h | 7 +++++++
 lib/usercopy.c           | 1 +
 3 files changed, 8 insertions(+), 7 deletions(-)
include/linux/bitops.h +0 -7
index 0b561ee6b4a4..ec45284c03f5 100644
@@ -8,13 +8,6 @@
 
 #include <uapi/linux/kernel.h>
 
-/* Set bits in the first 'n' bytes when loaded from memory */
-#ifdef __LITTLE_ENDIAN
-#  define aligned_byte_mask(n) ((1UL << 8*(n))-1)
-#else
-#  define aligned_byte_mask(n) (~0xffUL << (BITS_PER_LONG - 8 - 8*(n)))
-#endif
-
 #define BITS_PER_TYPE(type)	(sizeof(type) * BITS_PER_BYTE)
 #define BITS_TO_LONGS(nr)	__KERNEL_DIV_ROUND_UP(nr, BITS_PER_TYPE(long))
 #define BITS_TO_U64(nr)		__KERNEL_DIV_ROUND_UP(nr, BITS_PER_TYPE(u64))
include/linux/wordpart.h +7 -0
index f6f8f83b15b0..4ca1ba66d2f0 100644
@@ -39,4 +39,11 @@
  */
 #define REPEAT_BYTE(x)	((~0ul / 0xff) * (x))
 
+/* Set bits in the first 'n' bytes when loaded from memory */
+#ifdef __LITTLE_ENDIAN
+#  define aligned_byte_mask(n) ((1UL << 8*(n))-1)
+#else
+#  define aligned_byte_mask(n) (~0xffUL << (BITS_PER_LONG - 8 - 8*(n)))
+#endif
+
 #endif // _LINUX_WORDPART_H
lib/usercopy.c +1 -0
index d29fe29c6849..4b62e6299cc8 100644
@@ -3,6 +3,7 @@
 #include <linux/fault-inject-usercopy.h>
 #include <linux/instrumented.h>
 #include <linux/uaccess.h>
+#include <linux/wordpart.h>
 #include <linux/nospec.h>
 
 /* out-of-line parts */
Signature · 1 line
2.43.0.rc1.1336.g36b5255a03ac
#2 lore raw

PATCH v2 2/2 usercopy: Don't use "proxy" headers

In reply to Andy Shevchenko

Update header inclusions to follow IWYU (Include What You Use) principle.

---
 lib/usercopy.c | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)
lib/usercopy.c +6 -2
index 4b62e6299cc8..499a7a7d54db 100644
@@ -1,10 +1,14 @@
 // SPDX-License-Identifier: GPL-2.0
-#include <linux/bitops.h>
+#include <linux/compiler.h>
+#include <linux/errno.h>
+#include <linux/export.h>
 #include <linux/fault-inject-usercopy.h>
 #include <linux/instrumented.h>
+#include <linux/kernel.h>
+#include <linux/nospec.h>
+#include <linux/string.h>
 #include <linux/uaccess.h>
 #include <linux/wordpart.h>
-#include <linux/nospec.h>
 
 /* out-of-line parts */
 
Signature · 1 line
2.43.0.rc1.1336.g36b5255a03ac
maintainer
#3 lore raw
In reply to Andy Shevchenko
Quoted 11 lines · Andy Shevchenko

Move word part related macros to the respective header. While at it, fix the inclusion mess in lib/usercopy.h.

Andy Shevchenko (2):
bitops: Move aligned_byte_mask() to wordpart.h
usercopy: Don't use "proxy" headers

 include/linux/bitops.h   | 7 -------
 include/linux/wordpart.h | 7 +++++++
 lib/usercopy.c           | 9 +++++++--
 3 files changed, 14 insertions(+), 9 deletions(-)

Thanks, adding it in bitmap-for-next for testing.