Skip to content

Commit fed14be

Browse files
ConchuODpalmer-dabbelt
authored andcommitted
RISC-V: simplify register width check in ISA string parsing
Saving off the `isa` pointer to a temp variable, followed by checking if it has been incremented is a bit of an odd pattern. Perhaps it was done to avoid a funky looking if statement mixed with the ifdeffery. Now that we use IS_ENABLED() here just return from the parser as soon as we detect a mismatch between the string and the currently running kernel. Reviewed-by: Andrew Jones <[email protected]> Signed-off-by: Conor Dooley <[email protected]> Reviewed-by: Sunil V L <[email protected]> Link: https://lore.kernel.org/r/20230607-splatter-bacterium-a75bb9f0d0b7@spud Signed-off-by: Palmer Dabbelt <[email protected]>
1 parent 748462b commit fed14be

File tree

1 file changed

+7
-8
lines changed

1 file changed

+7
-8
lines changed

arch/riscv/kernel/cpufeature.c

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,6 @@ void __init riscv_fill_hwcap(void)
126126
for_each_possible_cpu(cpu) {
127127
unsigned long this_hwcap = 0;
128128
DECLARE_BITMAP(this_isa, RISCV_ISA_EXT_MAX);
129-
const char *temp;
130129

131130
if (acpi_disabled) {
132131
node = of_cpu_device_node_get(cpu);
@@ -149,14 +148,14 @@ void __init riscv_fill_hwcap(void)
149148
}
150149
}
151150

152-
temp = isa;
153-
if (IS_ENABLED(CONFIG_32BIT) && !strncasecmp(isa, "rv32", 4))
154-
isa += 4;
155-
else if (IS_ENABLED(CONFIG_64BIT) && !strncasecmp(isa, "rv64", 4))
156-
isa += 4;
157-
/* The riscv,isa DT property must start with rv64 or rv32 */
158-
if (temp == isa)
151+
if (IS_ENABLED(CONFIG_32BIT) && strncasecmp(isa, "rv32", 4))
159152
continue;
153+
154+
if (IS_ENABLED(CONFIG_64BIT) && strncasecmp(isa, "rv64", 4))
155+
continue;
156+
157+
isa += 4;
158+
160159
bitmap_zero(this_isa, RISCV_ISA_EXT_MAX);
161160
for (; *isa; ++isa) {
162161
const char *ext = isa++;

0 commit comments

Comments
 (0)