SST: Replace TFM SST errors by PSA PS errors

This patch replaces all TFM SST errors by PSA PS errors in the code as
the TF-M framework does not require any offset when using the
uniform secure function signature feature.

Change-Id: Iab314c001edc77e6fb1b8bb1641548c0a6c00a77
Signed-off-by: Marc Moreno <marc.morenoberengue@arm.com>
diff --git a/interface/include/tfm_sst_defs.h b/interface/include/tfm_sst_defs.h
index 1d54043..9132cce 100644
--- a/interface/include/tfm_sst_defs.h
+++ b/interface/include/tfm_sst_defs.h
@@ -8,53 +8,10 @@
 #ifndef __TFM_SST_DEFS_H__
 #define __TFM_SST_DEFS_H__
 
-#include <limits.h>
-#include "psa_protected_storage.h"
-#include "tfm_api.h"
-
 #ifdef __cplusplus
 extern "C" {
 #endif
 
-/* The return value is shared with the TF-M partition status value.
- * The SST return codes shouldn't overlap with predefined TF-M status values.
- */
-#define TFM_SST_ERR_OFFSET (TFM_PARTITION_SPECIFIC_ERROR_MIN)
-
-/**
- * \enum tfm_sst_err_t
- *
- * \brief TF-M Secure Storage service error types
- *
- */
-enum tfm_sst_err_t {
-    TFM_SST_ERR_SUCCESS = 0,
-    TFM_SST_ERR_WRITE_ONCE = TFM_SST_ERR_OFFSET,
-    TFM_SST_ERR_FLAGS_NOT_SUPPORTED,
-    TFM_SST_ERR_INSUFFICIENT_SPACE,
-    TFM_SST_ERR_STORAGE_FAILURE,
-    TFM_SST_ERR_UID_NOT_FOUND,
-    TFM_SST_ERR_INCORRECT_SIZE,
-    TFM_SST_ERR_OFFSET_INVALID,
-    TFM_SST_ERR_INVALID_ARGUMENT,
-    TFM_SST_ERR_DATA_CORRUPT,
-    TFM_SST_ERR_AUTH_FAILED,
-    TFM_SST_ERR_OPERATION_FAILED,
-    TFM_SST_ERR_NOT_SUPPORTED,
-    /* Add an invalid return code which forces the size of the type as well */
-    TFM_SST_ERR_INVALID = INT_MAX
-};
-
-/**
- * \brief A macro to translate TF-M API return values including the offset
- *        needed by TF-M, to the corresponding PSA value.
- */
-#define TFM_SST_PSA_RETURN(err) (                                              \
-    (err) == TFM_SST_ERR_SUCCESS ? err :                                       \
-    (err) >= TFM_SST_ERR_WRITE_ONCE ? ((err) - (TFM_SST_ERR_WRITE_ONCE - 1)) : \
-    TFM_SST_ERR_INVALID                                                        \
-)
-
 /* Invalid UID */
 #define TFM_SST_INVALID_UID 0
 
diff --git a/interface/src/tfm_sst_api.c b/interface/src/tfm_sst_api.c
index 5102b2f..0678dd4 100644
--- a/interface/src/tfm_sst_api.c
+++ b/interface/src/tfm_sst_api.c
@@ -8,7 +8,6 @@
 #include "psa_protected_storage.h"
 
 #include "tfm_ns_lock.h"
-#include "tfm_sst_defs.h"
 #include "tfm_veneers.h"
 
 #define IOVEC_LEN(x) (uint32_t)(sizeof(x)/sizeof(x[0]))
@@ -19,7 +18,7 @@
                            psa_ps_create_flags_t create_flags)
 {
     psa_status_t status;
-    enum tfm_sst_err_t err;
+    psa_ps_status_t err;
 
     psa_invec in_vec[] = {
         { .base = &uid,   .len = sizeof(uid) },
@@ -38,7 +37,7 @@
         return PSA_PS_ERROR_OPERATION_FAILED;
     }
 
-    return TFM_SST_PSA_RETURN(err);
+    return err;
 }
 
 psa_ps_status_t psa_ps_get(psa_ps_uid_t uid,
@@ -47,7 +46,7 @@
                            void *p_data)
 {
     psa_status_t status;
-    enum tfm_sst_err_t err;
+    psa_ps_status_t err;
 
     psa_invec in_vec[] = {
         { .base = &uid, .len = sizeof(uid) },
@@ -67,13 +66,13 @@
         return PSA_PS_ERROR_OPERATION_FAILED;
     }
 
-    return TFM_SST_PSA_RETURN(err);
+    return err;
 }
 
 psa_ps_status_t psa_ps_get_info(psa_ps_uid_t uid, struct psa_ps_info_t *p_info)
 {
     psa_status_t status;
-    enum tfm_sst_err_t err;
+    psa_ps_status_t err;
 
     psa_invec in_vec[] = {
         { .base = &uid, .len = sizeof(uid) }
@@ -92,13 +91,13 @@
         return PSA_PS_ERROR_OPERATION_FAILED;
     }
 
-    return TFM_SST_PSA_RETURN(err);
+    return err;
 }
 
 psa_ps_status_t psa_ps_remove(psa_ps_uid_t uid)
 {
     psa_status_t status;
-    enum tfm_sst_err_t err;
+    psa_ps_status_t err;
 
     psa_invec in_vec[] = {
         { .base = &uid, .len = sizeof(uid) }
@@ -116,7 +115,7 @@
         return PSA_PS_ERROR_OPERATION_FAILED;
     }
 
-    return TFM_SST_PSA_RETURN(err);
+    return err;
 }
 
 psa_ps_status_t psa_ps_create(psa_ps_uid_t uid, uint32_t size,