[PATCH v15 03/35] firmware: arm_scmi: Introduce a dedicated SCMI Errors header

Jonathan Cameron jonathan.cameron at oss.qualcomm.com
Mon Nov 9 14:01:29 PST 2026


On Mon,  9 Nov 2026 09:11:49 +0000
Cristian Marussi <cristian.marussi at arm.com> wrote:

> Add a new dedicated header and move all of the errors definitions and
> mapping helpers into it and out of common.h so that SCMI errors definitions
> alone can be easily included in protocol files without all of the unrelated
> additional stuff contained in common.h

In ideal world I'd move first and add the new codes later.
(so swap this and previous patch).

Trivial thing but reduce the patch size a tiny bit!

Other than that, seems like there are enough of these
for a separate header to perhaps make sense.

Reviewed-by: Jonathan Cameron <jonathan.cameron at oss.qualcomm.com>

> 
> Signed-off-by: Cristian Marussi <cristian.marussi at arm.com>
> ---
>  drivers/firmware/arm_scmi/common.h | 43 +----------------------
>  drivers/firmware/arm_scmi/errors.h | 56 ++++++++++++++++++++++++++++++
>  2 files changed, 57 insertions(+), 42 deletions(-)
>  create mode 100644 drivers/firmware/arm_scmi/errors.h
> 
> diff --git a/drivers/firmware/arm_scmi/common.h b/drivers/firmware/arm_scmi/common.h
> index e3390686fc58..cdd6f887fae7 100644
> --- a/drivers/firmware/arm_scmi/common.h
> +++ b/drivers/firmware/arm_scmi/common.h
> @@ -26,6 +26,7 @@
>  
>  #include <linux/unaligned.h>
>  
> +#include "errors.h"
>  #include "protocols.h"
>  #include "notify.h"
>  
> @@ -37,48 +38,6 @@
>  
>  #define SCMI_TRANSPORT_DEVNAME_PREFIX	"__scmi_transport_device"
>  
> -enum scmi_error_codes {
> -	SCMI_SUCCESS = 0,	/* Success */
> -	SCMI_ERR_SUPPORT = -1,	/* Not supported */
> -	SCMI_ERR_PARAMS = -2,	/* Invalid Parameters */
> -	SCMI_ERR_ACCESS = -3,	/* Invalid access/permission denied */
> -	SCMI_ERR_ENTRY = -4,	/* Not found */
> -	SCMI_ERR_RANGE = -5,	/* Value out of range */
> -	SCMI_ERR_BUSY = -6,	/* Device busy */
> -	SCMI_ERR_COMMS = -7,	/* Communication Error */
> -	SCMI_ERR_GENERIC = -8,	/* Generic Error */
> -	SCMI_ERR_HARDWARE = -9,	/* Hardware Error */
> -	SCMI_ERR_PROTOCOL = -10,/* Protocol Error */
> -	SCMI_ERR_IN_USE = -11,  /* In Use Error */
> -	SCMI_ERR_PARTIAL = -12, /* Partial Error */
> -};
> -
> -static const int scmi_linux_errmap[] = {
> -	/* better than switch case as long as return value is continuous */
> -	0,			/* SCMI_SUCCESS */
> -	-EOPNOTSUPP,		/* SCMI_ERR_SUPPORT */
> -	-EINVAL,		/* SCMI_ERR_PARAM */
> -	-EACCES,		/* SCMI_ERR_ACCESS */
> -	-ENOENT,		/* SCMI_ERR_ENTRY */
> -	-ERANGE,		/* SCMI_ERR_RANGE */
> -	-EBUSY,			/* SCMI_ERR_BUSY */
> -	-ECOMM,			/* SCMI_ERR_COMMS */
> -	-EIO,			/* SCMI_ERR_GENERIC */
> -	-EREMOTEIO,		/* SCMI_ERR_HARDWARE */
> -	-EPROTO,		/* SCMI_ERR_PROTOCOL */
> -	-EBUSY,			/* SCMI_ERR_IN_USE */
> -	-EBADMSG,		/* SCMI_ERR_PARTIAL */
> -};
> -
> -static inline int scmi_to_linux_errno(int errno)
> -{
> -	int err_idx = -errno;
> -
> -	if (err_idx >= SCMI_SUCCESS && err_idx < ARRAY_SIZE(scmi_linux_errmap))
> -		return scmi_linux_errmap[err_idx];
> -	return -EIO;
> -}
> -
>  #define MSG_ID_MASK		GENMASK(7, 0)
>  #define MSG_XTRACT_ID(hdr)	FIELD_GET(MSG_ID_MASK, (hdr))
>  #define MSG_TYPE_MASK		GENMASK(9, 8)
> diff --git a/drivers/firmware/arm_scmi/errors.h b/drivers/firmware/arm_scmi/errors.h
> new file mode 100644
> index 000000000000..707761cd8d34
> --- /dev/null
> +++ b/drivers/firmware/arm_scmi/errors.h
> @@ -0,0 +1,56 @@
> +/* SPDX-License-Identifier: GPL-2.0 */
> +/*
> + * System Control and Management Interface (SCMI) Message Protocol
> + * header containing SCMI errors definitions and Linux mapping.
> + *
> + * Copyright (C) 2018-2026 ARM Ltd.
> + */
> +#ifndef _SCMI_ERRORS_H
> +#define _SCMI_ERRORS_H
> +
> +#include <linux/errno.h>
> +#include <linux/array_size.h>
> +
> +enum scmi_error_codes {
> +	SCMI_SUCCESS = 0,	/* Success */
> +	SCMI_ERR_SUPPORT = -1,	/* Not supported */
> +	SCMI_ERR_PARAMS = -2,	/* Invalid Parameters */
> +	SCMI_ERR_ACCESS = -3,	/* Invalid access/permission denied */
> +	SCMI_ERR_ENTRY = -4,	/* Not found */
> +	SCMI_ERR_RANGE = -5,	/* Value out of range */
> +	SCMI_ERR_BUSY = -6,	/* Device busy */
> +	SCMI_ERR_COMMS = -7,	/* Communication Error */
> +	SCMI_ERR_GENERIC = -8,	/* Generic Error */
> +	SCMI_ERR_HARDWARE = -9,	/* Hardware Error */
> +	SCMI_ERR_PROTOCOL = -10,/* Protocol Error */
> +	SCMI_ERR_IN_USE = -11,  /* In Use Error */
> +	SCMI_ERR_PARTIAL = -12, /* Partial Error */
> +};
> +
> +static const int scmi_linux_errmap[] = {
> +	/* better than switch case as long as return value is continuous */
> +	0,			/* SCMI_SUCCESS */
> +	-EOPNOTSUPP,		/* SCMI_ERR_SUPPORT */
> +	-EINVAL,		/* SCMI_ERR_PARAM */
> +	-EACCES,		/* SCMI_ERR_ACCESS */
> +	-ENOENT,		/* SCMI_ERR_ENTRY */
> +	-ERANGE,		/* SCMI_ERR_RANGE */
> +	-EBUSY,			/* SCMI_ERR_BUSY */
> +	-ECOMM,			/* SCMI_ERR_COMMS */
> +	-EIO,			/* SCMI_ERR_GENERIC */
> +	-EREMOTEIO,		/* SCMI_ERR_HARDWARE */
> +	-EPROTO,		/* SCMI_ERR_PROTOCOL */
> +	-EBUSY,			/* SCMI_ERR_IN_USE */
> +	-EBADMSG,		/* SCMI_ERR_PARTIAL */
> +};
> +
> +static inline int scmi_to_linux_errno(int errno)
> +{
> +	int err_idx = -errno;
> +
> +	if (err_idx >= SCMI_SUCCESS && err_idx < ARRAY_SIZE(scmi_linux_errmap))
> +		return scmi_linux_errmap[err_idx];
> +	return -EIO;
> +}
> +
> +#endif /* _SCMI_ERRORS_H */




More information about the linux-arm-kernel mailing list