[PATCH] riscv: sbi: fix errno mapping for SBI_ERR_ALREADY_* error codes

Paul Walmsley pjw at kernel.org
Wed Jul 29 11:43:30 PDT 2026


Hi,

On Mon, 27 Jul 2026, Paul Sherman wrote:

> SBI error codes SBI_ERR_ALREADY_AVAILABLE (-6), SBI_ERR_ALREADY_STARTED
> (-7), and SBI_ERR_ALREADY_STOPPED (-8) have no explicit case in
> sbi_err_map_linux_errno() and fall through to the default branch,
> returning -ENOTSUPP (-524).
> 
> Map these three codes to -EALREADY, which correctly reflects their
> semantics: the requested operation was not performed because the target
> is already in the desired state.

It looks like -EALREADY is defined as "connection already in progress," 
which doesn't quite map to the meaning of these errors, here.

https://en.cppreference.com/cpp/error/errno_macros

Does this patch fix anything or change any behavior?

> Also add a documentation comment enumerating all SBI error codes and
> their Linux errno mappings, making the translation table self-documenting
> and making any future omissions immediately visible.

I don't think the comment is a good idea; it creates one more artifact 
that can get out of sync with the code.  We'd just expect people to read 
the code, I think.


- Paul



More information about the linux-riscv mailing list