refactor: use an enum for FF-A errors
Change-Id: Id30f36840e0668daa152ab90a2559fade7883c5f
Signed-off-by: Karl Meakin <karl.meakin@arm.com>
diff --git a/include/runtime_services/ffa_svc.h b/include/runtime_services/ffa_svc.h
index ddf4559..4c82507 100644
--- a/include/runtime_services/ffa_svc.h
+++ b/include/runtime_services/ffa_svc.h
@@ -15,18 +15,22 @@
* FFA error codes.
* Don't forget to update `ffa_error_name` if you add a new one.
*/
-#define FFA_ERROR_NOT_SUPPORTED -1
-#define FFA_ERROR_INVALID_PARAMETER -2
-#define FFA_ERROR_NO_MEMORY -3
-#define FFA_ERROR_BUSY -4
-#define FFA_ERROR_INTERRUPTED -5
-#define FFA_ERROR_DENIED -6
-#define FFA_ERROR_RETRY -7
-#define FFA_ERROR_ABORTED -8
-#define FFA_ERROR_NO_DATA -9
+/* clang-format off */
+enum ffa_error {
+ FFA_ERROR_NOT_SUPPORTED = -1,
+ FFA_ERROR_INVALID_PARAMETER = -2,
+ FFA_ERROR_NO_MEMORY = -3,
+ FFA_ERROR_BUSY = -4,
+ FFA_ERROR_INTERRUPTED = -5,
+ FFA_ERROR_DENIED = -6,
+ FFA_ERROR_RETRY = -7,
+ FFA_ERROR_ABORTED = -8,
+ FFA_ERROR_NO_DATA = -9,
+};
+/* clang-format on */
/* Return the name of the error code. */
-static inline const char *ffa_error_name(int32_t error)
+static inline const char *ffa_error_name(enum ffa_error error)
{
switch (error) {
case FFA_ERROR_NOT_SUPPORTED:
@@ -47,9 +51,8 @@
return "FFA_ERROR_ABORTED";
case FFA_ERROR_NO_DATA:
return "FFA_ERROR_NO_DATA";
- default:
- return "UNKNOWN";
}
+ return "UNKNOWN";
}
/* The macros below are used to identify FFA calls from the SMC function ID */
diff --git a/include/runtime_services/spm_test_helpers.h b/include/runtime_services/spm_test_helpers.h
index 14b2fb5..93675ce 100644
--- a/include/runtime_services/spm_test_helpers.h
+++ b/include/runtime_services/spm_test_helpers.h
@@ -15,14 +15,16 @@
#define SKIP_TEST_IF_FFA_VERSION_LESS_THAN(major, minor) \
do { \
struct ffa_value ret = ffa_version(FFA_VERSION_COMPILED); \
- enum ffa_version version = ret.fid; \
+ enum ffa_version version; \
\
- if (version == FFA_ERROR_NOT_SUPPORTED) { \
+ if (ret.fid == FFA_ERROR_NOT_SUPPORTED) { \
tftf_testcase_printf("FFA_VERSION not supported.\n"); \
return TEST_RESULT_SKIPPED; \
} \
\
- if (!ffa_version_is_valid(version)) { \
+ version = ret.fid; \
+ \
+ if (!ffa_version_is_valid(version)) { \
tftf_testcase_printf("FFA_VERSION bad response: %x\n", \
version); \
return TEST_RESULT_FAIL; \