mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
synced 2026-01-15 03:27:00 -05:00
firmware: arm_scmi: Move errors defs and code to common.h
Move SCMI error codes definitions and helper to the common.h header together with the delayed response timeout define. No functional change. Signed-off-by: Cristian Marussi <cristian.marussi@arm.com> Tested-by: Florian Fainelli <f.fainelli@gmail.com> Tested-by: Vincent Guittot <vincent.guittot@linaro.org> Link: https://lore.kernel.org/r/20230118121426.492864-7-cristian.marussi@arm.com Signed-off-by: Sudeep Holla <sudeep.holla@arm.com>
This commit is contained in:
committed by
Sudeep Holla
parent
3095a3e25d
commit
936a2b91c2
@@ -27,6 +27,46 @@
|
||||
#include "protocols.h"
|
||||
#include "notify.h"
|
||||
|
||||
#define SCMI_MAX_RESPONSE_TIMEOUT (2 * MSEC_PER_SEC)
|
||||
|
||||
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 */
|
||||
};
|
||||
|
||||
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 */
|
||||
};
|
||||
|
||||
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)
|
||||
|
||||
@@ -39,20 +39,6 @@
|
||||
#define CREATE_TRACE_POINTS
|
||||
#include <trace/events/scmi.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 */
|
||||
};
|
||||
|
||||
static DEFINE_IDR(scmi_protocols);
|
||||
static DEFINE_SPINLOCK(protocol_lock);
|
||||
|
||||
@@ -172,30 +158,6 @@ struct scmi_info {
|
||||
#define bus_nb_to_scmi_info(nb) container_of(nb, struct scmi_info, bus_nb)
|
||||
#define req_nb_to_scmi_info(nb) container_of(nb, struct scmi_info, dev_req_nb)
|
||||
|
||||
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 */
|
||||
};
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
static const struct scmi_protocol *scmi_protocol_get(int protocol_id)
|
||||
{
|
||||
const struct scmi_protocol *proto;
|
||||
@@ -1217,8 +1179,6 @@ static void reset_rx_to_maxsz(const struct scmi_protocol_handle *ph,
|
||||
xfer->rx.len = info->desc->max_msg_size;
|
||||
}
|
||||
|
||||
#define SCMI_MAX_RESPONSE_TIMEOUT (2 * MSEC_PER_SEC)
|
||||
|
||||
/**
|
||||
* do_xfer_with_response() - Do one transfer and wait until the delayed
|
||||
* response is received
|
||||
|
||||
Reference in New Issue
Block a user