[PATCH v3] riscv: Replace non-standard -1 return with -ENODEV in riscv_of_parent_hartid()
Mohamed Ayman
mohamedaymanworkspace at gmail.com
Sun May 3 09:19:31 PDT 2026
riscv_of_parent_hartid() returns -1 when no valid hart ID is found among
the parent nodes. This is non-standard; Linux kernel convention for a
"not found" condition is -ENODEV. Additionally, since several callers
propagate this return value up the call chain, a raw -1 could be
misinterpreted as -EPERM by code inspecting errno values.
Replace the -1 with -ENODEV for clarity and consistency with the rest
of the RISC-V CPU handling code.
Signed-off-by: Mohamed Ayman <mohamedaymanworkspace at gmail.com>
---
arch/riscv/kernel/cpu.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/arch/riscv/kernel/cpu.c b/arch/riscv/kernel/cpu.c
index 3dbc8cc55..414cd55df 100644
--- a/arch/riscv/kernel/cpu.c
+++ b/arch/riscv/kernel/cpu.c
@@ -135,7 +135,7 @@ int riscv_of_parent_hartid(struct device_node *node, unsigned long *hartid)
}
}
- return -1;
+ return -ENODEV;
}
unsigned long __init riscv_get_marchid(void)
--
2.34.1
More information about the linux-riscv
mailing list