Skip to content

Commit d01404f

Browse files
Merge patch series "riscv: alternative-macros.h cleanups"
Andrew Jones <[email protected]> says: This series is a collection of cleanups for alternative-macros.h with the main motivation being that adding new ALTERNATIVE_3, ALTERNATIVE_4, ... will be possible without lots of bloat. * b4-shazam-merge: riscv: Don't duplicate _ALTERNATIVE_CFG* macros riscv: alternatives: Drop the underscores from the assembly macro names riscv: alternatives: Don't name unused macro parameters riscv: Don't duplicate __ALTERNATIVE_CFG in __ALTERNATIVE_CFG_2 Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Palmer Dabbelt <[email protected]>
2 parents 59a582a + 26fb4b9 commit d01404f

File tree

1 file changed

+30
-69
lines changed

1 file changed

+30
-69
lines changed

arch/riscv/include/asm/alternative-macros.h

Lines changed: 30 additions & 69 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@
3333
.endif
3434
.endm
3535

36-
.macro __ALTERNATIVE_CFG old_c, new_c, vendor_id, errata_id, enable
36+
.macro ALTERNATIVE_CFG old_c, new_c, vendor_id, errata_id, enable
3737
886 :
3838
.option push
3939
.option norvc
@@ -44,30 +44,14 @@
4444
ALT_NEW_CONTENT \vendor_id, \errata_id, \enable, \new_c
4545
.endm
4646

47-
#define _ALTERNATIVE_CFG(old_c, new_c, vendor_id, errata_id, CONFIG_k) \
48-
__ALTERNATIVE_CFG old_c, new_c, vendor_id, errata_id, IS_ENABLED(CONFIG_k)
49-
50-
.macro __ALTERNATIVE_CFG_2 old_c, new_c_1, vendor_id_1, errata_id_1, enable_1, \
51-
new_c_2, vendor_id_2, errata_id_2, enable_2
52-
886 :
53-
.option push
54-
.option norvc
55-
.option norelax
56-
\old_c
57-
.option pop
58-
887 :
59-
ALT_NEW_CONTENT \vendor_id_1, \errata_id_1, \enable_1, \new_c_1
47+
.macro ALTERNATIVE_CFG_2 old_c, new_c_1, vendor_id_1, errata_id_1, enable_1, \
48+
new_c_2, vendor_id_2, errata_id_2, enable_2
49+
ALTERNATIVE_CFG \old_c, \new_c_1, \vendor_id_1, \errata_id_1, \enable_1
6050
ALT_NEW_CONTENT \vendor_id_2, \errata_id_2, \enable_2, \new_c_2
6151
.endm
6252

63-
#define _ALTERNATIVE_CFG_2(old_c, new_c_1, vendor_id_1, errata_id_1, \
64-
CONFIG_k_1, \
65-
new_c_2, vendor_id_2, errata_id_2, \
66-
CONFIG_k_2) \
67-
__ALTERNATIVE_CFG_2 old_c, new_c_1, vendor_id_1, errata_id_1, \
68-
IS_ENABLED(CONFIG_k_1), \
69-
new_c_2, vendor_id_2, errata_id_2, \
70-
IS_ENABLED(CONFIG_k_2)
53+
#define __ALTERNATIVE_CFG(...) ALTERNATIVE_CFG __VA_ARGS__
54+
#define __ALTERNATIVE_CFG_2(...) ALTERNATIVE_CFG_2 __VA_ARGS__
7155

7256
#else /* !__ASSEMBLY__ */
7357

@@ -109,63 +93,44 @@
10993
"887 :\n" \
11094
ALT_NEW_CONTENT(vendor_id, errata_id, enable, new_c)
11195

112-
#define _ALTERNATIVE_CFG(old_c, new_c, vendor_id, errata_id, CONFIG_k) \
113-
__ALTERNATIVE_CFG(old_c, new_c, vendor_id, errata_id, IS_ENABLED(CONFIG_k))
114-
115-
#define __ALTERNATIVE_CFG_2(old_c, new_c_1, vendor_id_1, errata_id_1, \
116-
enable_1, \
117-
new_c_2, vendor_id_2, errata_id_2, \
118-
enable_2) \
119-
"886 :\n" \
120-
".option push\n" \
121-
".option norvc\n" \
122-
".option norelax\n" \
123-
old_c "\n" \
124-
".option pop\n" \
125-
"887 :\n" \
126-
ALT_NEW_CONTENT(vendor_id_1, errata_id_1, enable_1, new_c_1) \
96+
#define __ALTERNATIVE_CFG_2(old_c, new_c_1, vendor_id_1, errata_id_1, enable_1, \
97+
new_c_2, vendor_id_2, errata_id_2, enable_2) \
98+
__ALTERNATIVE_CFG(old_c, new_c_1, vendor_id_1, errata_id_1, enable_1) \
12799
ALT_NEW_CONTENT(vendor_id_2, errata_id_2, enable_2, new_c_2)
128100

129-
#define _ALTERNATIVE_CFG_2(old_c, new_c_1, vendor_id_1, errata_id_1, \
130-
CONFIG_k_1, \
131-
new_c_2, vendor_id_2, errata_id_2, \
132-
CONFIG_k_2) \
133-
__ALTERNATIVE_CFG_2(old_c, new_c_1, vendor_id_1, errata_id_1, \
134-
IS_ENABLED(CONFIG_k_1), \
135-
new_c_2, vendor_id_2, errata_id_2, \
136-
IS_ENABLED(CONFIG_k_2))
137-
138101
#endif /* __ASSEMBLY__ */
139102

103+
#define _ALTERNATIVE_CFG(old_c, new_c, vendor_id, errata_id, CONFIG_k) \
104+
__ALTERNATIVE_CFG(old_c, new_c, vendor_id, errata_id, IS_ENABLED(CONFIG_k))
105+
106+
#define _ALTERNATIVE_CFG_2(old_c, new_c_1, vendor_id_1, errata_id_1, CONFIG_k_1, \
107+
new_c_2, vendor_id_2, errata_id_2, CONFIG_k_2) \
108+
__ALTERNATIVE_CFG_2(old_c, new_c_1, vendor_id_1, errata_id_1, IS_ENABLED(CONFIG_k_1), \
109+
new_c_2, vendor_id_2, errata_id_2, IS_ENABLED(CONFIG_k_2))
110+
140111
#else /* CONFIG_RISCV_ALTERNATIVE */
141112
#ifdef __ASSEMBLY__
142113

143-
.macro __ALTERNATIVE_CFG old_c
114+
.macro ALTERNATIVE_CFG old_c
144115
\old_c
145116
.endm
146117

147-
#define _ALTERNATIVE_CFG(old_c, new_c, vendor_id, errata_id, CONFIG_k) \
148-
__ALTERNATIVE_CFG old_c
118+
#define _ALTERNATIVE_CFG(old_c, ...) \
119+
ALTERNATIVE_CFG old_c
149120

150-
#define _ALTERNATIVE_CFG_2(old_c, new_c_1, vendor_id_1, errata_id_1, \
151-
CONFIG_k_1, \
152-
new_c_2, vendor_id_2, errata_id_2, \
153-
CONFIG_k_2) \
154-
__ALTERNATIVE_CFG old_c
121+
#define _ALTERNATIVE_CFG_2(old_c, ...) \
122+
ALTERNATIVE_CFG old_c
155123

156124
#else /* !__ASSEMBLY__ */
157125

158-
#define __ALTERNATIVE_CFG(old_c) \
126+
#define __ALTERNATIVE_CFG(old_c) \
159127
old_c "\n"
160128

161-
#define _ALTERNATIVE_CFG(old_c, new_c, vendor_id, errata_id, CONFIG_k) \
129+
#define _ALTERNATIVE_CFG(old_c, ...) \
162130
__ALTERNATIVE_CFG(old_c)
163131

164-
#define _ALTERNATIVE_CFG_2(old_c, new_c_1, vendor_id_1, errata_id_1, \
165-
CONFIG_k_1, \
166-
new_c_2, vendor_id_2, errata_id_2, \
167-
CONFIG_k_2) \
168-
__ALTERNATIVE_CFG(old_c)
132+
#define _ALTERNATIVE_CFG_2(old_c, ...) \
133+
__ALTERNATIVE_CFG(old_c)
169134

170135
#endif /* __ASSEMBLY__ */
171136
#endif /* CONFIG_RISCV_ALTERNATIVE */
@@ -193,13 +158,9 @@
193158
* on the following sample code and then replace ALTERNATIVE() with
194159
* ALTERNATIVE_2() to append its customized content.
195160
*/
196-
#define ALTERNATIVE_2(old_content, new_content_1, vendor_id_1, \
197-
errata_id_1, CONFIG_k_1, \
198-
new_content_2, vendor_id_2, \
199-
errata_id_2, CONFIG_k_2) \
200-
_ALTERNATIVE_CFG_2(old_content, new_content_1, vendor_id_1, \
201-
errata_id_1, CONFIG_k_1, \
202-
new_content_2, vendor_id_2, \
203-
errata_id_2, CONFIG_k_2)
161+
#define ALTERNATIVE_2(old_content, new_content_1, vendor_id_1, errata_id_1, CONFIG_k_1, \
162+
new_content_2, vendor_id_2, errata_id_2, CONFIG_k_2) \
163+
_ALTERNATIVE_CFG_2(old_content, new_content_1, vendor_id_1, errata_id_1, CONFIG_k_1, \
164+
new_content_2, vendor_id_2, errata_id_2, CONFIG_k_2)
204165

205166
#endif

0 commit comments

Comments
 (0)