bitops: Move aligned_byte_mask() to wordpart.h
authorAndy Shevchenko <andriy.shevchenko@linux.intel.com>
Tue, 7 May 2024 20:01:31 +0000 (23:01 +0300)
committerYury Norov <yury.norov@gmail.com>
Sun, 19 May 2024 23:12:38 +0000 (16:12 -0700)
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.

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Signed-off-by: Yury Norov <yury.norov@gmail.com>
include/linux/bitops.h
include/linux/wordpart.h
lib/usercopy.c

index 57ecef354f47bbe491da00e50bdcdf7491152468..3313d2c04e6d9f57b4acbd5fb68e52e87155aa0c 100644 (file)
@@ -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))
index f6f8f83b15b04391ba47768b296361a0783d9712..4ca1ba66d2f07b18712ee84de56e4fde82d8ef45 100644 (file)
  */
 #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
index d29fe29c6849417e6606cd06a9533aecacd8354a..4b62e6299cc84ee87bcae94bb03bb781b7f28834 100644 (file)
@@ -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 */