SPM: Refine the get_irq_line_for_signal function

This patch moves the signal bit check from calller to
get_irq_line_for_signal().
The check should have been included in the function.

Change-Id: Ic2b850ecc02ed3ce6477781cfcf213b5aa202db7
Signed-off-by: Kevin Peng <kevin.peng@arm.com>
diff --git a/secure_fw/spm/cmsis_func/spm_func.c b/secure_fw/spm/cmsis_func/spm_func.c
index 35702b2..17f0136 100644
--- a/secure_fw/spm/cmsis_func/spm_func.c
+++ b/secure_fw/spm/cmsis_func/spm_func.c
@@ -1087,6 +1087,10 @@
 {
     size_t i;
 
+    if (!tfm_is_one_bit_set(signal)) {
+        return -1;
+    }
+
     for (i = 0; i < tfm_core_irq_signals_count; ++i) {
         if (tfm_core_irq_signals[i].partition_id == partition_id &&
             tfm_core_irq_signals[i].signal_value == signal) {
@@ -1107,12 +1111,6 @@
                       tfm_spm_partition_get_partition_id(running_partition_idx);
     int32_t irq_line;
 
-    /* Only a single signal is allowed */
-    if (!tfm_is_one_bit_set(irq_signal)) {
-        /* FixMe: error severity TBD */
-        tfm_secure_api_error_handler();
-    }
-
     irq_line = get_irq_line_for_signal(running_partition_id, irq_signal);
 
     if (irq_line < 0) {
@@ -1134,12 +1132,6 @@
                       tfm_spm_partition_get_partition_id(running_partition_idx);
     int32_t irq_line;
 
-    /* Only a single signal is allowed */
-    if (!tfm_is_one_bit_set(irq_signal)) {
-        /* FixMe: error severity TBD */
-        tfm_secure_api_error_handler();
-    }
-
     irq_line = get_irq_line_for_signal(running_partition_id, irq_signal);
 
     if (irq_line < 0) {
@@ -1197,11 +1189,6 @@
                       tfm_spm_partition_get_partition_id(running_partition_idx);
     curr_part_data = tfm_spm_partition_get_runtime_data(running_partition_idx);
 
-    /* Only a single signal is allowed */
-    if (!tfm_is_one_bit_set(irq_signal)) {
-        tfm_secure_api_error_handler();
-    }
-
     irq_line = get_irq_line_for_signal(running_partition_id, irq_signal);
 
     if (irq_line < 0) {
diff --git a/secure_fw/spm/cmsis_psa/spm_ipc.c b/secure_fw/spm/cmsis_psa/spm_ipc.c
index 188c75f..b64cd1d 100644
--- a/secure_fw/spm/cmsis_psa/spm_ipc.c
+++ b/secure_fw/spm/cmsis_psa/spm_ipc.c
@@ -25,7 +25,6 @@
 #include "tfm_rpc.h"
 #include "tfm_core_trustzone.h"
 #include "tfm_list.h"
-#include "tfm_hal_isolation.h"
 #include "tfm_pools.h"
 #include "region.h"
 #include "region_defs.h"
@@ -878,6 +877,10 @@
 {
     size_t i;
 
+    if (!tfm_is_one_bit_set(signal)) {
+        return -1;
+    }
+
     for (i = 0; i < tfm_core_irq_signals_count; ++i) {
         if (tfm_core_irq_signals[i].partition_id == partition_id &&
             tfm_core_irq_signals[i].signal_value == signal) {
@@ -895,11 +898,6 @@
     int32_t irq_line = 0;
     struct partition_t *partition = NULL;
 
-    /* It is a fatal error if passed signal indicates more than one signals. */
-    if (!tfm_is_one_bit_set(irq_signal)) {
-        tfm_core_panic();
-    }
-
     partition = tfm_spm_get_running_partition();
     if (!partition) {
         tfm_core_panic();
@@ -921,11 +919,6 @@
     int32_t irq_line = 0;
     struct partition_t *partition = NULL;
 
-    /* It is a fatal error if passed signal indicates more than one signals. */
-    if (!tfm_is_one_bit_set(irq_signal)) {
-        tfm_core_panic();
-    }
-
     partition = tfm_spm_get_running_partition();
     if (!partition) {
         tfm_core_panic();
diff --git a/secure_fw/spm/cmsis_psa/spm_ipc.h b/secure_fw/spm/cmsis_psa/spm_ipc.h
index 3328a30..786ae65 100644
--- a/secure_fw/spm/cmsis_psa/spm_ipc.h
+++ b/secure_fw/spm/cmsis_psa/spm_ipc.h
@@ -506,11 +506,13 @@
  *
  * \param[in]      partition_id    The ID of the partition in which we look for
  *                                 the signal.
- * \param[in]      signal          The signal we do the query for.
+ * \param[in]      signal          The signal to query for.
  *
  * \retval None-negative value  The irq line associated with signal
- * \retval Negative value       There was an error finding the IRQ line for the
- *                              signal. irq_line is unchanged.
+ * \retval Negative value       if one of more the following are true:
+ *                              - the \ref signal indicates more than one signal
+ *                              - the \ref signal does not belong to the
+ *                                partition.
  */
 int32_t get_irq_line_for_signal(int32_t partition_id, psa_signal_t signal);
 
diff --git a/secure_fw/spm/common/psa_client_service_apis.c b/secure_fw/spm/common/psa_client_service_apis.c
index 285c85a..93ffbcb 100644
--- a/secure_fw/spm/common/psa_client_service_apis.c
+++ b/secure_fw/spm/common/psa_client_service_apis.c
@@ -590,11 +590,6 @@
     TFM_CORE_ASSERT(args != NULL);
     irq_signal = (psa_signal_t)args[0];
 
-    /* It is a fatal error if passed signal indicates more than one signals. */
-    if (!tfm_is_one_bit_set(irq_signal)) {
-        tfm_core_panic();
-    }
-
     partition = tfm_spm_get_running_partition();
     if (!partition) {
         tfm_core_panic();