RISC-V: Fix error code returned by riscv_hartid_to_cpuid()
authorAnup Patel <anup.patel@wdc.com>
Thu, 15 Apr 2021 08:55:22 +0000 (14:25 +0530)
committerPalmer Dabbelt <palmerdabbelt@google.com>
Sat, 1 May 2021 15:53:19 +0000 (08:53 -0700)
We should return a negative error code upon failure in
riscv_hartid_to_cpuid() instead of NR_CPUS. This is also
aligned with all uses of riscv_hartid_to_cpuid() which
expect negative error code upon failure.

Fixes: 6825c7a80f18 ("RISC-V: Add logical CPU indexing for RISC-V")
Fixes: f99fb607fb2b ("RISC-V: Use Linux logical CPU number instead of hartid")
Signed-off-by: Anup Patel <anup.patel@wdc.com>
Signed-off-by: Palmer Dabbelt <palmerdabbelt@google.com>
arch/riscv/kernel/smp.c

index 366cb87..921d9d7 100644 (file)
@@ -56,7 +56,7 @@ int riscv_hartid_to_cpuid(int hartid)
                        return i;
 
        pr_err("Couldn't find cpu id for hartid [%d]\n", hartid);
-       return i;
+       return -ENOENT;
 }
 
 void riscv_cpuid_to_hartid_mask(const struct cpumask *in, struct cpumask *out)