tools: refresh all patches
[openwrt/staging/pepe2k.git] / target / linux / generic / backport-6.1 / 302-v6.9-kernel.h-Move-upper_-_bits-and-lower_-_bits-to-wordp.patch
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
5 wordpart.h
6
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.
10
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).
14
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>
19 ---
20 include/linux/kernel.h | 30 ++----------------------------
21 include/linux/wordpart.h | 29 +++++++++++++++++++++++++++++
22 2 files changed, 31 insertions(+), 28 deletions(-)
23
24 --- a/include/linux/kernel.h
25 +++ b/include/linux/kernel.h
26 @@ -30,6 +30,8 @@
27 #include <linux/build_bug.h>
28 #include <linux/static_call_types.h>
29 #include <linux/instruction_pointer.h>
30 +#include <linux/wordpart.h>
31 +
32 #include <asm/byteorder.h>
33
34 #include <uapi/linux/kernel.h>
35 @@ -55,34 +57,6 @@
36 } \
37 )
38
39 -/**
40 - * upper_32_bits - return bits 32-63 of a number
41 - * @n: the number we're accessing
42 - *
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
45 - * 32-bits.
46 - */
47 -#define upper_32_bits(n) ((u32)(((n) >> 16) >> 16))
48 -
49 -/**
50 - * lower_32_bits - return bits 0-31 of a number
51 - * @n: the number we're accessing
52 - */
53 -#define lower_32_bits(n) ((u32)((n) & 0xffffffff))
54 -
55 -/**
56 - * upper_16_bits - return bits 16-31 of a number
57 - * @n: the number we're accessing
58 - */
59 -#define upper_16_bits(n) ((u16)((n) >> 16))
60 -
61 -/**
62 - * lower_16_bits - return bits 0-15 of a number
63 - * @n: the number we're accessing
64 - */
65 -#define lower_16_bits(n) ((u16)((n) & 0xffff))
66 -
67 struct completion;
68 struct user;
69
70 --- a/include/linux/wordpart.h
71 +++ b/include/linux/wordpart.h
72 @@ -2,6 +2,35 @@
73
74 #ifndef _LINUX_WORDPART_H
75 #define _LINUX_WORDPART_H
76 +
77 +/**
78 + * upper_32_bits - return bits 32-63 of a number
79 + * @n: the number we're accessing
80 + *
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
83 + * 32-bits.
84 + */
85 +#define upper_32_bits(n) ((u32)(((n) >> 16) >> 16))
86 +
87 +/**
88 + * lower_32_bits - return bits 0-31 of a number
89 + * @n: the number we're accessing
90 + */
91 +#define lower_32_bits(n) ((u32)((n) & 0xffffffff))
92 +
93 +/**
94 + * upper_16_bits - return bits 16-31 of a number
95 + * @n: the number we're accessing
96 + */
97 +#define upper_16_bits(n) ((u16)((n) >> 16))
98 +
99 +/**
100 + * lower_16_bits - return bits 0-15 of a number
101 + * @n: the number we're accessing
102 + */
103 +#define lower_16_bits(n) ((u16)((n) & 0xffff))
104 +
105 /**
106 * REPEAT_BYTE - repeat the value @x multiple times as an unsigned long value
107 * @x: value to repeat