1 From adeb04362d74188c1e22ccb824b15a0a7b3de2f4 Mon Sep 17 00:00:00 2001
2 From: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
3 Date: Wed, 14 Feb 2024 19:26:32 +0200
4 Subject: [PATCH] kernel.h: Move upper_*_bits() and lower_*_bits() to
7 The wordpart.h header is collecting APIs related to the handling
8 parts of the word (usually in byte granularity). The upper_*_bits()
9 and lower_*_bits() are good candidates to be moved to there.
11 This helps to clean up header dependency hell with regard to kernel.h
12 as the latter gathers completely unrelated stuff together and slows
13 down compilation (especially when it's included into other header).
15 Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
16 Link: https://lore.kernel.org/r/20240214172752.3605073-1-andriy.shevchenko@linux.intel.com
17 Reviewed-by: Randy Dunlap <rdunlap@infradead.org>
18 Signed-off-by: Kees Cook <keescook@chromium.org>
20 include/linux/kernel.h | 30 ++----------------------------
21 include/linux/wordpart.h | 29 +++++++++++++++++++++++++++++
22 2 files changed, 31 insertions(+), 28 deletions(-)
24 --- a/include/linux/kernel.h
25 +++ b/include/linux/kernel.h
27 #include <linux/sprintf.h>
28 #include <linux/static_call_types.h>
29 #include <linux/instruction_pointer.h>
30 +#include <linux/wordpart.h>
32 #include <asm/byteorder.h>
34 #include <uapi/linux/kernel.h>
40 - * upper_32_bits - return bits 32-63 of a number
41 - * @n: the number we're accessing
43 - * A basic shift-right of a 64- or 32-bit quantity. Use this to suppress
44 - * the "right shift count >= width of type" warning when that quantity is
47 -#define upper_32_bits(n) ((u32)(((n) >> 16) >> 16))
50 - * lower_32_bits - return bits 0-31 of a number
51 - * @n: the number we're accessing
53 -#define lower_32_bits(n) ((u32)((n) & 0xffffffff))
56 - * upper_16_bits - return bits 16-31 of a number
57 - * @n: the number we're accessing
59 -#define upper_16_bits(n) ((u16)((n) >> 16))
62 - * lower_16_bits - return bits 0-15 of a number
63 - * @n: the number we're accessing
65 -#define lower_16_bits(n) ((u16)((n) & 0xffff))
70 --- a/include/linux/wordpart.h
71 +++ b/include/linux/wordpart.h
74 #ifndef _LINUX_WORDPART_H
75 #define _LINUX_WORDPART_H
78 + * upper_32_bits - return bits 32-63 of a number
79 + * @n: the number we're accessing
81 + * A basic shift-right of a 64- or 32-bit quantity. Use this to suppress
82 + * the "right shift count >= width of type" warning when that quantity is
85 +#define upper_32_bits(n) ((u32)(((n) >> 16) >> 16))
88 + * lower_32_bits - return bits 0-31 of a number
89 + * @n: the number we're accessing
91 +#define lower_32_bits(n) ((u32)((n) & 0xffffffff))
94 + * upper_16_bits - return bits 16-31 of a number
95 + * @n: the number we're accessing
97 +#define upper_16_bits(n) ((u16)((n) >> 16))
100 + * lower_16_bits - return bits 0-15 of a number
101 + * @n: the number we're accessing
103 +#define lower_16_bits(n) ((u16)((n) & 0xffff))
106 * REPEAT_BYTE - repeat the value @x multiple times as an unsigned long value
107 * @x: value to repeat