* [PATCH] riscv: Simplify base extension checks and direct boolean return
@ 2025-01-29 20:38 Chin Yik Ming
2025-01-30 8:50 ` Andrew Jones
2025-03-27 3:24 ` patchwork-bot+linux-riscv
0 siblings, 2 replies; 3+ messages in thread
From: Chin Yik Ming @ 2025-01-29 20:38 UTC (permalink / raw)
To: conor
Cc: paul.walmsley, palmer, aou, charlie, ajones, samuel.holland,
cleger, andybnac, alexghiti, peterlin, linux-riscv, linux-kernel,
yikming2222
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 <yikming2222@gmail.com>
---
arch/riscv/kernel/cpufeature.c | 6 ++----
arch/riscv/kernel/vendor_extensions.c | 2 +-
2 files changed, 3 insertions(+), 5 deletions(-)
diff --git a/arch/riscv/kernel/cpufeature.c b/arch/riscv/kernel/cpufeature.c
index c0916ed318c2..32525b69ab99 100644
--- a/arch/riscv/kernel/cpufeature.c
+++ b/arch/riscv/kernel/cpufeature.c
@@ -49,9 +49,7 @@ struct riscv_isainfo hart_isa[NR_CPUS];
*/
unsigned long riscv_isa_extension_base(const unsigned long *isa_bitmap)
{
- if (!isa_bitmap)
- return riscv_isa[0];
- return isa_bitmap[0];
+ return !isa_bitmap ? riscv_isa[0] : isa_bitmap[0];
}
EXPORT_SYMBOL_GPL(riscv_isa_extension_base);
@@ -72,7 +70,7 @@ bool __riscv_isa_extension_available(const unsigned long *isa_bitmap, unsigned i
if (bit >= RISCV_ISA_EXT_MAX)
return false;
- return test_bit(bit, bmap) ? true : false;
+ return test_bit(bit, bmap);
}
EXPORT_SYMBOL_GPL(__riscv_isa_extension_available);
diff --git a/arch/riscv/kernel/vendor_extensions.c b/arch/riscv/kernel/vendor_extensions.c
index a8126d118341..62f55bc779e9 100644
--- a/arch/riscv/kernel/vendor_extensions.c
+++ b/arch/riscv/kernel/vendor_extensions.c
@@ -51,6 +51,6 @@ bool __riscv_isa_vendor_extension_available(int cpu, unsigned long vendor, unsig
if (bit >= RISCV_ISA_VENDOR_EXT_MAX)
return false;
- return test_bit(bit, bmap->isa) ? true : false;
+ return test_bit(bit, bmap->isa);
}
EXPORT_SYMBOL_GPL(__riscv_isa_vendor_extension_available);
--
2.34.1
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] riscv: Simplify base extension checks and direct boolean return
2025-01-29 20:38 [PATCH] riscv: Simplify base extension checks and direct boolean return Chin Yik Ming
@ 2025-01-30 8:50 ` Andrew Jones
2025-03-27 3:24 ` patchwork-bot+linux-riscv
1 sibling, 0 replies; 3+ messages in thread
From: Andrew Jones @ 2025-01-30 8:50 UTC (permalink / raw)
To: Chin Yik Ming
Cc: conor, paul.walmsley, palmer, aou, charlie, samuel.holland,
cleger, andybnac, alexghiti, peterlin, linux-riscv, linux-kernel
On Thu, Jan 30, 2025 at 04:38:43AM +0800, Chin Yik Ming wrote:
> 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 <yikming2222@gmail.com>
> ---
> arch/riscv/kernel/cpufeature.c | 6 ++----
> arch/riscv/kernel/vendor_extensions.c | 2 +-
> 2 files changed, 3 insertions(+), 5 deletions(-)
>
> diff --git a/arch/riscv/kernel/cpufeature.c b/arch/riscv/kernel/cpufeature.c
> index c0916ed318c2..32525b69ab99 100644
> --- a/arch/riscv/kernel/cpufeature.c
> +++ b/arch/riscv/kernel/cpufeature.c
> @@ -49,9 +49,7 @@ struct riscv_isainfo hart_isa[NR_CPUS];
> */
> unsigned long riscv_isa_extension_base(const unsigned long *isa_bitmap)
> {
> - if (!isa_bitmap)
> - return riscv_isa[0];
> - return isa_bitmap[0];
> + return !isa_bitmap ? riscv_isa[0] : isa_bitmap[0];
> }
> EXPORT_SYMBOL_GPL(riscv_isa_extension_base);
>
> @@ -72,7 +70,7 @@ bool __riscv_isa_extension_available(const unsigned long *isa_bitmap, unsigned i
> if (bit >= RISCV_ISA_EXT_MAX)
> return false;
>
> - return test_bit(bit, bmap) ? true : false;
> + return test_bit(bit, bmap);
> }
> EXPORT_SYMBOL_GPL(__riscv_isa_extension_available);
>
> diff --git a/arch/riscv/kernel/vendor_extensions.c b/arch/riscv/kernel/vendor_extensions.c
> index a8126d118341..62f55bc779e9 100644
> --- a/arch/riscv/kernel/vendor_extensions.c
> +++ b/arch/riscv/kernel/vendor_extensions.c
> @@ -51,6 +51,6 @@ bool __riscv_isa_vendor_extension_available(int cpu, unsigned long vendor, unsig
> if (bit >= RISCV_ISA_VENDOR_EXT_MAX)
> return false;
>
> - return test_bit(bit, bmap->isa) ? true : false;
> + return test_bit(bit, bmap->isa);
> }
> EXPORT_SYMBOL_GPL(__riscv_isa_vendor_extension_available);
> --
> 2.34.1
>
Since the changes are harmless and I do prefer the way the code looks
with them,
Reviewed-by: Andrew Jones <ajones@ventanamicro.com>
but these types of changes are pretty much just pointless churn...
Thanks,
drew
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] riscv: Simplify base extension checks and direct boolean return
2025-01-29 20:38 [PATCH] riscv: Simplify base extension checks and direct boolean return Chin Yik Ming
2025-01-30 8:50 ` Andrew Jones
@ 2025-03-27 3:24 ` patchwork-bot+linux-riscv
1 sibling, 0 replies; 3+ messages in thread
From: patchwork-bot+linux-riscv @ 2025-03-27 3:24 UTC (permalink / raw)
To: Chin Yik Ming
Cc: linux-riscv, conor, paul.walmsley, palmer, aou, charlie, ajones,
samuel.holland, cleger, andybnac, alexghiti, peterlin,
linux-kernel
Hello:
This patch was applied to riscv/linux.git (for-next)
by Alexandre Ghiti <alexghiti@rivosinc.com>:
On Thu, 30 Jan 2025 04:38:43 +0800 you wrote:
> 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 <yikming2222@gmail.com>
>
> [...]
Here is the summary with links:
- riscv: Simplify base extension checks and direct boolean return
https://git.kernel.org/riscv/c/7f238b12660e
You are awesome, thank you!
--
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2025-03-27 3:24 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-01-29 20:38 [PATCH] riscv: Simplify base extension checks and direct boolean return Chin Yik Ming
2025-01-30 8:50 ` Andrew Jones
2025-03-27 3:24 ` patchwork-bot+linux-riscv
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox