generic: 6.1, 6.6: replace Airoha EN8811H PHY driver with upstream
[openwrt/staging/blogic.git] / target / linux / generic / backport-6.6 / 301-v6.9-kernel.h-removed-REPEAT_BYTE-from-kernel.h.patch
1 From 66a5c40f60f5d88ad8d47ba6a4ba05892853fa1f Mon Sep 17 00:00:00 2001
2 From: Tanzir Hasan <tanzirh@google.com>
3 Date: Tue, 26 Dec 2023 18:00:00 +0000
4 Subject: [PATCH] kernel.h: removed REPEAT_BYTE from kernel.h
5
6 This patch creates wordpart.h and includes it in asm/word-at-a-time.h
7 for all architectures. WORD_AT_A_TIME_CONSTANTS depends on kernel.h
8 because of REPEAT_BYTE. Moving this to another header and including it
9 where necessary allows us to not include the bloated kernel.h. Making
10 this implicit dependency on REPEAT_BYTE explicit allows for later
11 improvements in the lib/string.c inclusion list.
12
13 Suggested-by: Al Viro <viro@zeniv.linux.org.uk>
14 Suggested-by: Andy Shevchenko <andy.shevchenko@gmail.com>
15 Signed-off-by: Tanzir Hasan <tanzirh@google.com>
16 Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.com>
17 Link: https://lore.kernel.org/r/20231226-libstringheader-v6-1-80aa08c7652c@google.com
18 Signed-off-by: Kees Cook <keescook@chromium.org>
19 ---
20 arch/arm/include/asm/word-at-a-time.h | 3 ++-
21 arch/arm64/include/asm/word-at-a-time.h | 3 ++-
22 arch/powerpc/include/asm/word-at-a-time.h | 4 ++--
23 arch/riscv/include/asm/word-at-a-time.h | 3 ++-
24 arch/s390/include/asm/word-at-a-time.h | 3 ++-
25 arch/sh/include/asm/word-at-a-time.h | 2 ++
26 arch/x86/include/asm/word-at-a-time.h | 3 ++-
27 arch/x86/kvm/mmu/mmu.c | 1 +
28 fs/namei.c | 2 +-
29 include/asm-generic/word-at-a-time.h | 3 ++-
30 include/linux/kernel.h | 8 --------
31 include/linux/wordpart.h | 13 +++++++++++++
32 12 files changed, 31 insertions(+), 17 deletions(-)
33 create mode 100644 include/linux/wordpart.h
34
35 --- a/arch/arm/include/asm/word-at-a-time.h
36 +++ b/arch/arm/include/asm/word-at-a-time.h
37 @@ -8,7 +8,8 @@
38 * Little-endian word-at-a-time zero byte handling.
39 * Heavily based on the x86 algorithm.
40 */
41 -#include <linux/kernel.h>
42 +#include <linux/bitops.h>
43 +#include <linux/wordpart.h>
44
45 struct word_at_a_time {
46 const unsigned long one_bits, high_bits;
47 --- a/arch/arm64/include/asm/word-at-a-time.h
48 +++ b/arch/arm64/include/asm/word-at-a-time.h
49 @@ -9,7 +9,8 @@
50
51 #ifndef __AARCH64EB__
52
53 -#include <linux/kernel.h>
54 +#include <linux/bitops.h>
55 +#include <linux/wordpart.h>
56
57 struct word_at_a_time {
58 const unsigned long one_bits, high_bits;
59 --- a/arch/powerpc/include/asm/word-at-a-time.h
60 +++ b/arch/powerpc/include/asm/word-at-a-time.h
61 @@ -4,8 +4,8 @@
62 /*
63 * Word-at-a-time interfaces for PowerPC.
64 */
65 -
66 -#include <linux/kernel.h>
67 +#include <linux/bitops.h>
68 +#include <linux/wordpart.h>
69 #include <asm/asm-compat.h>
70 #include <asm/extable.h>
71
72 --- a/arch/sh/include/asm/word-at-a-time.h
73 +++ b/arch/sh/include/asm/word-at-a-time.h
74 @@ -5,6 +5,8 @@
75 #ifdef CONFIG_CPU_BIG_ENDIAN
76 # include <asm-generic/word-at-a-time.h>
77 #else
78 +#include <linux/bitops.h>
79 +#include <linux/wordpart.h>
80 /*
81 * Little-endian version cribbed from x86.
82 */
83 --- a/arch/x86/include/asm/word-at-a-time.h
84 +++ b/arch/x86/include/asm/word-at-a-time.h
85 @@ -2,7 +2,8 @@
86 #ifndef _ASM_WORD_AT_A_TIME_H
87 #define _ASM_WORD_AT_A_TIME_H
88
89 -#include <linux/kernel.h>
90 +#include <linux/bitops.h>
91 +#include <linux/wordpart.h>
92
93 /*
94 * This is largely generic for little-endian machines, but the
95 --- a/arch/x86/kvm/mmu/mmu.c
96 +++ b/arch/x86/kvm/mmu/mmu.c
97 @@ -47,6 +47,7 @@
98 #include <linux/kern_levels.h>
99 #include <linux/kstrtox.h>
100 #include <linux/kthread.h>
101 +#include <linux/wordpart.h>
102
103 #include <asm/page.h>
104 #include <asm/memtype.h>
105 --- a/fs/namei.c
106 +++ b/fs/namei.c
107 @@ -17,8 +17,8 @@
108
109 #include <linux/init.h>
110 #include <linux/export.h>
111 -#include <linux/kernel.h>
112 #include <linux/slab.h>
113 +#include <linux/wordpart.h>
114 #include <linux/fs.h>
115 #include <linux/filelock.h>
116 #include <linux/namei.h>
117 --- a/include/asm-generic/word-at-a-time.h
118 +++ b/include/asm-generic/word-at-a-time.h
119 @@ -2,7 +2,8 @@
120 #ifndef _ASM_WORD_AT_A_TIME_H
121 #define _ASM_WORD_AT_A_TIME_H
122
123 -#include <linux/kernel.h>
124 +#include <linux/bitops.h>
125 +#include <linux/wordpart.h>
126 #include <asm/byteorder.h>
127
128 #ifdef __BIG_ENDIAN
129 --- a/include/linux/kernel.h
130 +++ b/include/linux/kernel.h
131 @@ -38,14 +38,6 @@
132
133 #define STACK_MAGIC 0xdeadbeef
134
135 -/**
136 - * REPEAT_BYTE - repeat the value @x multiple times as an unsigned long value
137 - * @x: value to repeat
138 - *
139 - * NOTE: @x is not checked for > 0xff; larger values produce odd results.
140 - */
141 -#define REPEAT_BYTE(x) ((~0ul / 0xff) * (x))
142 -
143 /* generic data direction definitions */
144 #define READ 0
145 #define WRITE 1
146 --- /dev/null
147 +++ b/include/linux/wordpart.h
148 @@ -0,0 +1,13 @@
149 +/* SPDX-License-Identifier: GPL-2.0 */
150 +
151 +#ifndef _LINUX_WORDPART_H
152 +#define _LINUX_WORDPART_H
153 +/**
154 + * REPEAT_BYTE - repeat the value @x multiple times as an unsigned long value
155 + * @x: value to repeat
156 + *
157 + * NOTE: @x is not checked for > 0xff; larger values produce odd results.
158 + */
159 +#define REPEAT_BYTE(x) ((~0ul / 0xff) * (x))
160 +
161 +#endif // _LINUX_WORDPART_H