public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Mohamed Ayman <mohamedaymanworkspace@gmail.com>
To: pjw@kernel.org, palmer@dabbelt.com, aou@eecs.berkeley.edu, alex@ghiti.fr
Cc: linux-riscv@lists.infradead.org, linux-kernel@vger.kernel.org,
	Mohamed Ayman <mohamedaymanworkspace@gmail.com>
Subject: [PATCH v3] riscv: Replace non-standard -1 return with -ENODEV in riscv_of_parent_hartid()
Date: Sun,  3 May 2026 19:19:31 +0300	[thread overview]
Message-ID: <20260503161931.688010-1-mohamedaymanworkspace@gmail.com> (raw)
In-Reply-To: <20260502161802.515547-1-mohamedaymanworkspace@gmail.com>

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@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


      parent reply	other threads:[~2026-05-03 16:19 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-05-02 16:17 [PATCH] riscv: cpuinfo: Fix NULL dereference and inconsistent error code Mohamed Ayman
2026-05-03 12:26 ` Michael Ellerman
2026-05-03 16:11   ` MOHAMED AYMAN
2026-05-03 16:19 ` Mohamed Ayman [this message]

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=20260503161931.688010-1-mohamedaymanworkspace@gmail.com \
    --to=mohamedaymanworkspace@gmail.com \
    --cc=alex@ghiti.fr \
    --cc=aou@eecs.berkeley.edu \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-riscv@lists.infradead.org \
    --cc=palmer@dabbelt.com \
    --cc=pjw@kernel.org \
    /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