Skip to contentSkip to conversation

riscv: propagate insert_resource result from add_resource

PATCH In review Thorsten Blum 2 participants 2 messages May 12 – May 13 RISC-V

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 riscv: propagate insert_resource result from add_resource

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.

---
Changes in v2:
- Use %pR to print the full resource range as suggested by Ben Dooks
- v1: https://lore.kernel.org/lkml/[email protected]/

---
 arch/riscv/kernel/setup.c | 11 ++++-------
 1 file changed, 4 insertions(+), 7 deletions(-)
arch/riscv/kernel/setup.c +4 -7
index c89cc272440b..52d1d2b8f338 100644
@@ -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)
maintainer
#1 lore raw
Quoted 8 lines · Thorsten Blum

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.

Thanks, queued for v7.2.

- Paul