From: Thorsten Blum <thorsten.blum@linux.dev>
To: "Paul Walmsley" <pjw@kernel.org>,
"Palmer Dabbelt" <palmer@dabbelt.com>,
"Albert Ou" <aou@eecs.berkeley.edu>,
"Alexandre Ghiti" <alex@ghiti.fr>,
"Björn Töpel" <bjorn@rivosinc.com>,
"Conor Dooley" <conor.dooley@microchip.com>,
"Yu-Chun Lin" <eleanor.lin@realtek.com>,
"Kuan-Wei Chiu" <visitorckw@gmail.com>,
"Han Gao" <rabenda.cn@gmail.com>,
"Nam Cao" <namcao@linutronix.de>, "Pu Lehui" <pulehui@huawei.com>,
"Klara Modin" <klarasmodin@gmail.com>
Cc: Ben Dooks <ben.dooks@codethink.co.uk>,
Thorsten Blum <thorsten.blum@linux.dev>,
Alexandre Ghiti <alexghiti@rivosinc.com>,
linux-riscv@lists.infradead.org, linux-kernel@vger.kernel.org
Subject: [PATCH v2] riscv: propagate insert_resource result from add_resource
Date: Tue, 12 May 2026 19:20:35 +0200 [thread overview]
Message-ID: <20260512172034.328405-4-thorsten.blum@linux.dev> (raw)
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).
Use %pR to print the full resource range while at it.
Signed-off-by: Thorsten Blum <thorsten.blum@linux.dev>
---
Changes in v2:
- Use %pR to print the full resource range as suggested by Ben Dooks
- v1: https://lore.kernel.org/lkml/20260512124628.300360-3-thorsten.blum@linux.dev/
---
arch/riscv/kernel/setup.c | 11 ++++-------
1 file changed, 4 insertions(+), 7 deletions(-)
diff --git a/arch/riscv/kernel/setup.c b/arch/riscv/kernel/setup.c
index c89cc272440b..52d1d2b8f338 100644
--- a/arch/riscv/kernel/setup.c
+++ b/arch/riscv/kernel/setup.c
@@ -71,16 +71,13 @@ 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) {
- pr_err("Failed to add a %s resource at %llx\n",
- res->name, (unsigned long long) res->start);
- return ret;
- }
+ if (ret < 0)
+ pr_err("Failed to add resource %s %pR\n", res->name, res);
- return 1;
+ return ret;
}
static int __init add_kernel_resources(void)
reply other threads:[~2026-05-12 17:21 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20260512172034.328405-4-thorsten.blum@linux.dev \
--to=thorsten.blum@linux.dev \
--cc=alex@ghiti.fr \
--cc=alexghiti@rivosinc.com \
--cc=aou@eecs.berkeley.edu \
--cc=ben.dooks@codethink.co.uk \
--cc=bjorn@rivosinc.com \
--cc=conor.dooley@microchip.com \
--cc=eleanor.lin@realtek.com \
--cc=klarasmodin@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-riscv@lists.infradead.org \
--cc=namcao@linutronix.de \
--cc=palmer@dabbelt.com \
--cc=pjw@kernel.org \
--cc=pulehui@huawei.com \
--cc=rabenda.cn@gmail.com \
--cc=visitorckw@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox