On Tue, May 10, 2022 at 9:18 PM Yury Norov <[email protected]> wrote:
>
> bitmap_empty() is better than bitmap_weight() because it may return
> earlier, and improves on readability.
>
> CC: Albert Ou <[email protected]>
> CC: Anup Patel <[email protected]>
> CC: Atish Patra <[email protected]>
> CC: Jisheng Zhang <[email protected]>
> CC: Palmer Dabbelt <[email protected]>
> CC: Paul Walmsley <[email protected]>
> CC: Tsukasa OI <[email protected]>
> CC: [email protected]
> CC: [email protected]
> Signed-off-by: Yury Norov <[email protected]>
Looks good to me.
Reviewed-by: Anup Patel <[email protected]>
Regards,
Anup
> ---
> arch/riscv/kernel/cpufeature.c | 7 +++----
> 1 file changed, 3 insertions(+), 4 deletions(-)
>
> diff --git a/arch/riscv/kernel/cpufeature.c b/arch/riscv/kernel/cpufeature.c
> index 1b2d42d7f589..f0298d756f66 100644
> --- a/arch/riscv/kernel/cpufeature.c
> +++ b/arch/riscv/kernel/cpufeature.c
> @@ -206,11 +206,10 @@ void __init riscv_fill_hwcap(void)
> else
> elf_hwcap = this_hwcap;
>
> - if (bitmap_weight(riscv_isa, RISCV_ISA_EXT_MAX))
> - bitmap_and(riscv_isa, riscv_isa, this_isa, RISCV_ISA_EXT_MAX);
> - else
> + if (bitmap_empty(riscv_isa, RISCV_ISA_EXT_MAX))
> bitmap_copy(riscv_isa, this_isa, RISCV_ISA_EXT_MAX);
> -
> + else
> + bitmap_and(riscv_isa, riscv_isa, this_isa, RISCV_ISA_EXT_MAX);
> }
>
> /* We don't support systems with F but without D, so mask those out
> --
> 2.32.0
>