[PATCH v2 2/4] KVM: arm64: Move the ffa_to_linux definition to the ffa header

From: Sebastian Ene
Date: Thu Feb 27 2025 - 13:18:26 EST


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.

Signed-off-by: Sebastian Ene <sebastianene@xxxxxxxxxx>
---
drivers/firmware/arm_ffa/driver.c | 24 ------------------------
include/linux/arm_ffa.h | 24 ++++++++++++++++++++++++
2 files changed, 24 insertions(+), 24 deletions(-)

diff --git a/drivers/firmware/arm_ffa/driver.c b/drivers/firmware/arm_ffa/driver.c
index 2c2ec3c35f15..b02b80f3dfe8 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;
};
diff --git a/include/linux/arm_ffa.h b/include/linux/arm_ffa.h
index 74169dd0f659..850577edadbc 100644
--- a/include/linux/arm_ffa.h
+++ b/include/linux/arm_ffa.h
@@ -475,4 +475,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 */
--
2.48.1.711.g2feabab25a-goog