* [PATCH v2 0/2] bitops: Reshuffle bitops.h and wordpart,h
@ 2024-05-07 20:01 Andy Shevchenko
2024-05-07 20:01 ` [PATCH v2 1/2] bitops: Move aligned_byte_mask() to wordpart.h Andy Shevchenko
` (2 more replies)
0 siblings, 3 replies; 4+ messages in thread
From: Andy Shevchenko @ 2024-05-07 20:01 UTC (permalink / raw)
To: Yury Norov, Andy Shevchenko, linux-kernel; +Cc: Rasmus Villemoes, Andrew Morton
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(-)
--
2.43.0.rc1.1336.g36b5255a03ac
^ permalink raw reply [flat|nested] 4+ messages in thread* [PATCH v2 1/2] bitops: Move aligned_byte_mask() to wordpart.h
2024-05-07 20:01 [PATCH v2 0/2] bitops: Reshuffle bitops.h and wordpart,h Andy Shevchenko
@ 2024-05-07 20:01 ` Andy Shevchenko
2024-05-07 20:01 ` [PATCH v2 2/2] usercopy: Don't use "proxy" headers Andy Shevchenko
2024-05-07 21:38 ` [PATCH v2 0/2] bitops: Reshuffle bitops.h and wordpart,h Yury Norov
2 siblings, 0 replies; 4+ messages in thread
From: Andy Shevchenko @ 2024-05-07 20:01 UTC (permalink / raw)
To: Yury Norov, Andy Shevchenko, linux-kernel; +Cc: Rasmus Villemoes, Andrew Morton
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>
---
include/linux/bitops.h | 7 -------
include/linux/wordpart.h | 7 +++++++
lib/usercopy.c | 1 +
3 files changed, 8 insertions(+), 7 deletions(-)
diff --git a/include/linux/bitops.h b/include/linux/bitops.h
index 0b561ee6b4a4..ec45284c03f5 100644
--- a/include/linux/bitops.h
+++ b/include/linux/bitops.h
@@ -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))
diff --git a/include/linux/wordpart.h b/include/linux/wordpart.h
index f6f8f83b15b0..4ca1ba66d2f0 100644
--- a/include/linux/wordpart.h
+++ b/include/linux/wordpart.h
@@ -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
diff --git a/lib/usercopy.c b/lib/usercopy.c
index d29fe29c6849..4b62e6299cc8 100644
--- a/lib/usercopy.c
+++ b/lib/usercopy.c
@@ -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 */
--
2.43.0.rc1.1336.g36b5255a03ac
^ permalink raw reply related [flat|nested] 4+ messages in thread
* [PATCH v2 2/2] usercopy: Don't use "proxy" headers
2024-05-07 20:01 [PATCH v2 0/2] bitops: Reshuffle bitops.h and wordpart,h Andy Shevchenko
2024-05-07 20:01 ` [PATCH v2 1/2] bitops: Move aligned_byte_mask() to wordpart.h Andy Shevchenko
@ 2024-05-07 20:01 ` Andy Shevchenko
2024-05-07 21:38 ` [PATCH v2 0/2] bitops: Reshuffle bitops.h and wordpart,h Yury Norov
2 siblings, 0 replies; 4+ messages in thread
From: Andy Shevchenko @ 2024-05-07 20:01 UTC (permalink / raw)
To: Yury Norov, Andy Shevchenko, linux-kernel; +Cc: Rasmus Villemoes, Andrew Morton
Update header inclusions to follow IWYU (Include What You Use)
principle.
Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
---
lib/usercopy.c | 8 ++++++--
1 file changed, 6 insertions(+), 2 deletions(-)
diff --git a/lib/usercopy.c b/lib/usercopy.c
index 4b62e6299cc8..499a7a7d54db 100644
--- a/lib/usercopy.c
+++ b/lib/usercopy.c
@@ -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 */
--
2.43.0.rc1.1336.g36b5255a03ac
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH v2 0/2] bitops: Reshuffle bitops.h and wordpart,h
2024-05-07 20:01 [PATCH v2 0/2] bitops: Reshuffle bitops.h and wordpart,h Andy Shevchenko
2024-05-07 20:01 ` [PATCH v2 1/2] bitops: Move aligned_byte_mask() to wordpart.h Andy Shevchenko
2024-05-07 20:01 ` [PATCH v2 2/2] usercopy: Don't use "proxy" headers Andy Shevchenko
@ 2024-05-07 21:38 ` Yury Norov
2 siblings, 0 replies; 4+ messages in thread
From: Yury Norov @ 2024-05-07 21:38 UTC (permalink / raw)
To: Andy Shevchenko; +Cc: linux-kernel, Rasmus Villemoes, Andrew Morton
On Tue, May 07, 2024 at 11:01:30PM +0300, Andy Shevchenko wrote:
> 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.
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2024-05-07 21:38 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-05-07 20:01 [PATCH v2 0/2] bitops: Reshuffle bitops.h and wordpart,h Andy Shevchenko
2024-05-07 20:01 ` [PATCH v2 1/2] bitops: Move aligned_byte_mask() to wordpart.h Andy Shevchenko
2024-05-07 20:01 ` [PATCH v2 2/2] usercopy: Don't use "proxy" headers Andy Shevchenko
2024-05-07 21:38 ` [PATCH v2 0/2] bitops: Reshuffle bitops.h and wordpart,h Yury Norov
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox