* [PATCH] riscv: propagate insert_resource result from add_resource
@ 2026-05-12 12:46 Thorsten Blum
2026-05-12 12:49 ` Ben Dooks
0 siblings, 1 reply; 2+ messages in thread
From: Thorsten Blum @ 2026-05-12 12:46 UTC (permalink / raw)
To: Paul Walmsley, Palmer Dabbelt, Albert Ou, Alexandre Ghiti,
Björn Töpel, Conor Dooley, Nam Cao, Kuan-Wei Chiu,
Klara Modin, Han Gao, Pu Lehui
Cc: Thorsten Blum, Alexandre Ghiti, Yu-Chun Lin, linux-riscv,
linux-kernel
Currently, add_resource() returns 1 on success, even though its callers
only check for negative values. Instead, propagate the insert_resource()
result from add_resource() to align with standard kernel return-value
conventions (0 on success, negative errno on failure).
Signed-off-by: Thorsten Blum <thorsten.blum@linux.dev>
---
arch/riscv/kernel/setup.c | 8 +++-----
1 file changed, 3 insertions(+), 5 deletions(-)
diff --git a/arch/riscv/kernel/setup.c b/arch/riscv/kernel/setup.c
index c89cc272440b..6e3d8acae71a 100644
--- a/arch/riscv/kernel/setup.c
+++ b/arch/riscv/kernel/setup.c
@@ -71,16 +71,14 @@ static struct resource *standard_resources;
static int __init add_resource(struct resource *parent,
struct resource *res)
{
- int ret = 0;
+ int ret;
ret = insert_resource(parent, res);
- if (ret < 0) {
+ if (ret < 0)
pr_err("Failed to add a %s resource at %llx\n",
res->name, (unsigned long long) res->start);
- return ret;
- }
- return 1;
+ return ret;
}
static int __init add_kernel_resources(void)
^ permalink raw reply related [flat|nested] 2+ messages in thread* Re: [PATCH] riscv: propagate insert_resource result from add_resource
2026-05-12 12:46 [PATCH] riscv: propagate insert_resource result from add_resource Thorsten Blum
@ 2026-05-12 12:49 ` Ben Dooks
0 siblings, 0 replies; 2+ messages in thread
From: Ben Dooks @ 2026-05-12 12:49 UTC (permalink / raw)
To: Thorsten Blum, Paul Walmsley, Palmer Dabbelt, Albert Ou,
Alexandre Ghiti, Björn Töpel, Conor Dooley, Nam Cao,
Kuan-Wei Chiu, Klara Modin, Han Gao, Pu Lehui
Cc: Alexandre Ghiti, Yu-Chun Lin, linux-riscv, linux-kernel
On 12/05/2026 13:46, Thorsten Blum wrote:
> Currently, add_resource() returns 1 on success, even though its callers
> only check for negative values. Instead, propagate the insert_resource()
> result from add_resource() to align with standard kernel return-value
> conventions (0 on success, negative errno on failure).
>
> Signed-off-by: Thorsten Blum <thorsten.blum@linux.dev>
> ---
> arch/riscv/kernel/setup.c | 8 +++-----
> 1 file changed, 3 insertions(+), 5 deletions(-)
>
> diff --git a/arch/riscv/kernel/setup.c b/arch/riscv/kernel/setup.c
> index c89cc272440b..6e3d8acae71a 100644
> --- a/arch/riscv/kernel/setup.c
> +++ b/arch/riscv/kernel/setup.c
> @@ -71,16 +71,14 @@ static struct resource *standard_resources;
> static int __init add_resource(struct resource *parent,
> struct resource *res)
> {
> - int ret = 0;
> + int ret;
>
> ret = insert_resource(parent, res);
> - if (ret < 0) {
> + if (ret < 0)
> pr_err("Failed to add a %s resource at %llx\n",
> res->name, (unsigned long long) res->start);
Maybe just use %pR for the resource start/end here and avoid
the casting.
--
Ben Dooks http://www.codethink.co.uk/
Senior Engineer Codethink - Providing Genius
https://www.codethink.co.uk/privacy.html
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2026-05-12 12:50 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-05-12 12:46 [PATCH] riscv: propagate insert_resource result from add_resource Thorsten Blum
2026-05-12 12:49 ` Ben Dooks
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox