From b2fde9f68b075158e4faf30da4c09a2aa1f33ea5 Mon Sep 17 00:00:00 2001 From: Sebastian Ene Date: Thu, 27 Feb 2025 18:03:47 +0000 Subject: [PATCH] FROMLIST: firmware: arm_ffa: Move the ffa_to_linux definition to the ffa header Keep the ffa_to_linux error map in the header and move it away from the arm ffa driver to make it accessible for other components. Bug: 269285339 Bug: 278749606 Change-Id: I9f26e956738907a13e4e42b06defe1cd1ce90d68 Link: https://lore.kernel.org/all/20250326113901.3308804-3-sebastianene@google.com/ Signed-off-by: Sebastian Ene Reviewed-by: Sudeep Holla --- drivers/firmware/arm_ffa/driver.c | 26 -------------------------- include/linux/arm_ffa.h | 27 +++++++++++++++++++++++++++ 2 files changed, 27 insertions(+), 26 deletions(-) diff --git a/drivers/firmware/arm_ffa/driver.c b/drivers/firmware/arm_ffa/driver.c index 2c2ec3c35f15..3f88509a15b7 100644 --- a/drivers/firmware/arm_ffa/driver.c +++ b/drivers/firmware/arm_ffa/driver.c @@ -61,30 +61,6 @@ static ffa_fn *invoke_ffa_fn; -static const int ffa_linux_errmap[] = { - /* better than switch case as long as return value is continuous */ - 0, /* FFA_RET_SUCCESS */ - -EOPNOTSUPP, /* FFA_RET_NOT_SUPPORTED */ - -EINVAL, /* FFA_RET_INVALID_PARAMETERS */ - -ENOMEM, /* FFA_RET_NO_MEMORY */ - -EBUSY, /* FFA_RET_BUSY */ - -EINTR, /* FFA_RET_INTERRUPTED */ - -EACCES, /* FFA_RET_DENIED */ - -EAGAIN, /* FFA_RET_RETRY */ - -ECANCELED, /* FFA_RET_ABORTED */ - -ENODATA, /* FFA_RET_NO_DATA */ - -EAGAIN, /* FFA_RET_NOT_READY */ -}; - -static inline int ffa_to_linux_errno(int errno) -{ - int err_idx = -errno; - - if (err_idx >= 0 && err_idx < ARRAY_SIZE(ffa_linux_errmap)) - return ffa_linux_errmap[err_idx]; - return -EINVAL; -} - struct ffa_pcpu_irq { struct ffa_drv_info *info; }; @@ -238,8 +214,6 @@ static int ffa_features(u32 func_feat_id, u32 input_props, return 0; } -#define PARTITION_INFO_GET_RETURN_COUNT_ONLY BIT(0) - /* buffer must be sizeof(struct ffa_partition_info) * num_partitions */ static int __ffa_partition_info_get(u32 uuid0, u32 uuid1, u32 uuid2, u32 uuid3, diff --git a/include/linux/arm_ffa.h b/include/linux/arm_ffa.h index 74169dd0f659..cdaa162060f4 100644 --- a/include/linux/arm_ffa.h +++ b/include/linux/arm_ffa.h @@ -223,6 +223,9 @@ extern const struct bus_type ffa_bus_type; /* The FF-A 1.0 partition structure lacks the uuid[4] */ #define FFA_1_0_PARTITON_INFO_SZ (8) +/* Return the count of partitions deployed in the system */ +#define PARTITION_INFO_GET_RETURN_COUNT_ONLY BIT(0) + /* FFA transport related */ struct ffa_partition_info { u16 id; @@ -475,4 +478,28 @@ struct ffa_ops { const struct ffa_notifier_ops *notifier_ops; }; +static const int ffa_linux_errmap[] = { + /* better than switch case as long as return value is continuous */ + 0, /* FFA_RET_SUCCESS */ + -EOPNOTSUPP, /* FFA_RET_NOT_SUPPORTED */ + -EINVAL, /* FFA_RET_INVALID_PARAMETERS */ + -ENOMEM, /* FFA_RET_NO_MEMORY */ + -EBUSY, /* FFA_RET_BUSY */ + -EINTR, /* FFA_RET_INTERRUPTED */ + -EACCES, /* FFA_RET_DENIED */ + -EAGAIN, /* FFA_RET_RETRY */ + -ECANCELED, /* FFA_RET_ABORTED */ + -ENODATA, /* FFA_RET_NO_DATA */ + -EAGAIN, /* FFA_RET_NOT_READY */ +}; + +static inline int ffa_to_linux_errno(int errno) +{ + int err_idx = -errno; + + if (err_idx >= 0 && err_idx < ARRAY_SIZE(ffa_linux_errmap)) + return ffa_linux_errmap[err_idx]; + return -EINVAL; +} + #endif /* _LINUX_ARM_FFA_H */