Skip to content

Commit 7f238b1

Browse files
ChinYikMingAlexandre Ghiti
authored andcommitted
riscv: Simplify base extension checks and direct boolean return
Reduce three lines checking to single line using a ternary conditional expression for getting the base extension word. In addition, the test_bit macro function already return a boolean which matches the return type of the caller, so directly return the result of the test_bit macro function. Signed-off-by: Chin Yik Ming <[email protected]> Reviewed-by: Andrew Jones <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Alexandre Ghiti <[email protected]>
1 parent a4a58f5 commit 7f238b1

File tree

2 files changed

+3
-5
lines changed

2 files changed

+3
-5
lines changed

arch/riscv/kernel/cpufeature.c

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -54,9 +54,7 @@ u32 thead_vlenb_of;
5454
*/
5555
unsigned long riscv_isa_extension_base(const unsigned long *isa_bitmap)
5656
{
57-
if (!isa_bitmap)
58-
return riscv_isa[0];
59-
return isa_bitmap[0];
57+
return !isa_bitmap ? riscv_isa[0] : isa_bitmap[0];
6058
}
6159
EXPORT_SYMBOL_GPL(riscv_isa_extension_base);
6260

@@ -77,7 +75,7 @@ bool __riscv_isa_extension_available(const unsigned long *isa_bitmap, unsigned i
7775
if (bit >= RISCV_ISA_EXT_MAX)
7876
return false;
7977

80-
return test_bit(bit, bmap) ? true : false;
78+
return test_bit(bit, bmap);
8179
}
8280
EXPORT_SYMBOL_GPL(__riscv_isa_extension_available);
8381

arch/riscv/kernel/vendor_extensions.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,6 @@ bool __riscv_isa_vendor_extension_available(int cpu, unsigned long vendor, unsig
6161
if (bit >= RISCV_ISA_VENDOR_EXT_MAX)
6262
return false;
6363

64-
return test_bit(bit, bmap->isa) ? true : false;
64+
return test_bit(bit, bmap->isa);
6565
}
6666
EXPORT_SYMBOL_GPL(__riscv_isa_vendor_extension_available);

0 commit comments

Comments
 (0)