Skip to content

Commit 4133709

Browse files
jason77-wangPaul Walmsley
authored andcommitted
riscv: cpufeature: Use pre-defined ISA ext macros to index isa2hwcap
We have pre-defined ISA extension macros, here use those macros to replace a magic number for isa2hwcap definition and some array indexing for isa2hwcap access. This doesn't change the original functionality, just improve the code maintainability and readability. Signed-off-by: Hui Wang <hui.wang@canonical.com> Link: https://patch.msgid.link/20260506132152.53239-1-hui.wang@canonical.com Signed-off-by: Paul Walmsley <pjw@kernel.org>
1 parent db909bd commit 4133709

1 file changed

Lines changed: 8 additions & 8 deletions

File tree

arch/riscv/kernel/cpufeature.c

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1102,16 +1102,16 @@ early_param("riscv_isa_fallback", riscv_isa_fallback_setup);
11021102
void __init riscv_fill_hwcap(void)
11031103
{
11041104
char print_str[NUM_ALPHA_EXTS + 1];
1105-
unsigned long isa2hwcap[26] = {0};
1105+
unsigned long isa2hwcap[RISCV_ISA_EXT_BASE] = {0};
11061106
int i, j;
11071107

1108-
isa2hwcap['i' - 'a'] = COMPAT_HWCAP_ISA_I;
1109-
isa2hwcap['m' - 'a'] = COMPAT_HWCAP_ISA_M;
1110-
isa2hwcap['a' - 'a'] = COMPAT_HWCAP_ISA_A;
1111-
isa2hwcap['f' - 'a'] = COMPAT_HWCAP_ISA_F;
1112-
isa2hwcap['d' - 'a'] = COMPAT_HWCAP_ISA_D;
1113-
isa2hwcap['c' - 'a'] = COMPAT_HWCAP_ISA_C;
1114-
isa2hwcap['v' - 'a'] = COMPAT_HWCAP_ISA_V;
1108+
isa2hwcap[RISCV_ISA_EXT_i] = COMPAT_HWCAP_ISA_I;
1109+
isa2hwcap[RISCV_ISA_EXT_m] = COMPAT_HWCAP_ISA_M;
1110+
isa2hwcap[RISCV_ISA_EXT_a] = COMPAT_HWCAP_ISA_A;
1111+
isa2hwcap[RISCV_ISA_EXT_f] = COMPAT_HWCAP_ISA_F;
1112+
isa2hwcap[RISCV_ISA_EXT_d] = COMPAT_HWCAP_ISA_D;
1113+
isa2hwcap[RISCV_ISA_EXT_c] = COMPAT_HWCAP_ISA_C;
1114+
isa2hwcap[RISCV_ISA_EXT_v] = COMPAT_HWCAP_ISA_V;
11151115

11161116
if (!acpi_disabled) {
11171117
riscv_fill_hwcap_from_isa_string(isa2hwcap);

0 commit comments

Comments
 (0)