mirror of
https://github.com/ARM-software/arm-trusted-firmware.git
synced 2025-04-29 00:33:49 +00:00
fix(xilinx): modify function to have single return
This corrects the MISRA violation C2012-15.5: A function should have a single point of exit at the end. Introduced a temporary variable to store the return value to ensure single return for the function. Change-Id: Ice3eb939664ffc62c1f586b641e37481f10ffff6 Signed-off-by: Nithin G <nithing@amd.com> Signed-off-by: Maheedhar Bollapalli <maheedharsai.bollapalli@amd.com>
This commit is contained in:
parent
3f6d47945a
commit
906d589277
5 changed files with 78 additions and 41 deletions
|
@ -123,14 +123,17 @@ static uint32_t get_xbl_ss(const struct xbl_partition *partition)
|
||||||
static uint32_t get_xbl_endian(const struct xbl_partition *partition)
|
static uint32_t get_xbl_endian(const struct xbl_partition *partition)
|
||||||
{
|
{
|
||||||
uint64_t flags = partition->flags & XBL_FLAGS_ENDIAN_MASK;
|
uint64_t flags = partition->flags & XBL_FLAGS_ENDIAN_MASK;
|
||||||
|
uint32_t spsr_value = 0U;
|
||||||
|
|
||||||
flags >>= XBL_FLAGS_ENDIAN_SHIFT;
|
flags >>= XBL_FLAGS_ENDIAN_SHIFT;
|
||||||
|
|
||||||
if (flags == XBL_FLAGS_ENDIAN_BE) {
|
if (flags == XBL_FLAGS_ENDIAN_BE) {
|
||||||
return SPSR_E_BIG;
|
spsr_value = SPSR_E_BIG;
|
||||||
} else {
|
} else {
|
||||||
return SPSR_E_LITTLE;
|
spsr_value = SPSR_E_LITTLE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return spsr_value;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -182,10 +185,12 @@ enum xbl_handoff xbl_handover(entry_point_info_t *bl32,
|
||||||
uint64_t handoff_addr)
|
uint64_t handoff_addr)
|
||||||
{
|
{
|
||||||
const struct xbl_handoff_params *HandoffParams;
|
const struct xbl_handoff_params *HandoffParams;
|
||||||
|
enum xbl_handoff xbl_status = XBL_HANDOFF_SUCCESS;
|
||||||
|
|
||||||
if (handoff_addr == 0U) {
|
if (handoff_addr == 0U) {
|
||||||
WARN("BL31: No handoff structure passed\n");
|
WARN("BL31: No handoff structure passed\n");
|
||||||
return XBL_HANDOFF_NO_STRUCT;
|
xbl_status = XBL_HANDOFF_NO_STRUCT;
|
||||||
|
goto exit_label;
|
||||||
}
|
}
|
||||||
|
|
||||||
HandoffParams = (struct xbl_handoff_params *)handoff_addr;
|
HandoffParams = (struct xbl_handoff_params *)handoff_addr;
|
||||||
|
@ -194,7 +199,8 @@ enum xbl_handoff xbl_handover(entry_point_info_t *bl32,
|
||||||
(HandoffParams->magic[2] != (uint8_t)'N') ||
|
(HandoffParams->magic[2] != (uint8_t)'N') ||
|
||||||
(HandoffParams->magic[3] != (uint8_t)'X')) {
|
(HandoffParams->magic[3] != (uint8_t)'X')) {
|
||||||
ERROR("BL31: invalid handoff structure at %" PRIx64 "\n", handoff_addr);
|
ERROR("BL31: invalid handoff structure at %" PRIx64 "\n", handoff_addr);
|
||||||
return XBL_HANDOFF_INVAL_STRUCT;
|
xbl_status = XBL_HANDOFF_INVAL_STRUCT;
|
||||||
|
goto exit_label;
|
||||||
}
|
}
|
||||||
|
|
||||||
VERBOSE("BL31: TF-A handoff params at:0x%" PRIx64 ", entries:%u\n",
|
VERBOSE("BL31: TF-A handoff params at:0x%" PRIx64 ", entries:%u\n",
|
||||||
|
@ -202,7 +208,8 @@ enum xbl_handoff xbl_handover(entry_point_info_t *bl32,
|
||||||
if (HandoffParams->num_entries > XBL_MAX_PARTITIONS) {
|
if (HandoffParams->num_entries > XBL_MAX_PARTITIONS) {
|
||||||
ERROR("BL31: TF-A handoff params: too many partitions (%u/%u)\n",
|
ERROR("BL31: TF-A handoff params: too many partitions (%u/%u)\n",
|
||||||
HandoffParams->num_entries, XBL_MAX_PARTITIONS);
|
HandoffParams->num_entries, XBL_MAX_PARTITIONS);
|
||||||
return XBL_HANDOFF_TOO_MANY_PARTS;
|
xbl_status = XBL_HANDOFF_TOO_MANY_PARTS;
|
||||||
|
goto exit_label;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -304,5 +311,6 @@ enum xbl_handoff xbl_handover(entry_point_info_t *bl32,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return XBL_HANDOFF_SUCCESS;
|
exit_label:
|
||||||
|
return xbl_status;
|
||||||
}
|
}
|
||||||
|
|
|
@ -149,10 +149,11 @@ enum pm_ret_status pm_self_suspend(uint32_t nid,
|
||||||
uint32_t payload[PAYLOAD_ARG_CNT];
|
uint32_t payload[PAYLOAD_ARG_CNT];
|
||||||
uint32_t cpuid = plat_my_core_pos();
|
uint32_t cpuid = plat_my_core_pos();
|
||||||
const struct pm_proc *proc = pm_get_proc(cpuid);
|
const struct pm_proc *proc = pm_get_proc(cpuid);
|
||||||
|
enum pm_ret_status ret = PM_RET_ERROR_INTERNAL;
|
||||||
|
|
||||||
if (proc == NULL) {
|
if (proc == NULL) {
|
||||||
WARN("Failed to get proc %d\n", cpuid);
|
WARN("Failed to get proc %d\n", cpuid);
|
||||||
return PM_RET_ERROR_INTERNAL;
|
goto exit_label;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -165,7 +166,10 @@ enum pm_ret_status pm_self_suspend(uint32_t nid,
|
||||||
PM_PACK_PAYLOAD6(payload, LIBPM_MODULE_ID, flag, PM_SELF_SUSPEND,
|
PM_PACK_PAYLOAD6(payload, LIBPM_MODULE_ID, flag, PM_SELF_SUSPEND,
|
||||||
proc->node_id, latency, state, address,
|
proc->node_id, latency, state, address,
|
||||||
(address >> 32));
|
(address >> 32));
|
||||||
return pm_ipi_send_sync(proc, payload, NULL, 0);
|
ret = pm_ipi_send_sync(proc, payload, NULL, 0);
|
||||||
|
|
||||||
|
exit_label:
|
||||||
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -215,15 +219,18 @@ enum pm_ret_status pm_req_suspend(uint32_t target, uint8_t ack,
|
||||||
uint32_t flag)
|
uint32_t flag)
|
||||||
{
|
{
|
||||||
uint32_t payload[PAYLOAD_ARG_CNT];
|
uint32_t payload[PAYLOAD_ARG_CNT];
|
||||||
|
enum pm_ret_status ret = PM_RET_SUCCESS;
|
||||||
|
|
||||||
/* Send request to the PMU */
|
/* Send request to the PMU */
|
||||||
PM_PACK_PAYLOAD4(payload, LIBPM_MODULE_ID, flag, PM_REQ_SUSPEND, target,
|
PM_PACK_PAYLOAD4(payload, LIBPM_MODULE_ID, flag, PM_REQ_SUSPEND, target,
|
||||||
latency, state);
|
latency, state);
|
||||||
if (ack == (uint32_t)IPI_BLOCKING) {
|
if (ack == (uint32_t)IPI_BLOCKING) {
|
||||||
return pm_ipi_send_sync(primary_proc, payload, NULL, 0);
|
ret = pm_ipi_send_sync(primary_proc, payload, NULL, 0);
|
||||||
} else {
|
} else {
|
||||||
return pm_ipi_send(primary_proc, payload);
|
ret = pm_ipi_send(primary_proc, payload);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -273,16 +280,16 @@ enum pm_ret_status pm_req_wakeup(uint32_t target, uint32_t set_address,
|
||||||
enum pm_ret_status pm_get_callbackdata(uint32_t *data, size_t count, uint32_t flag, uint32_t ack)
|
enum pm_ret_status pm_get_callbackdata(uint32_t *data, size_t count, uint32_t flag, uint32_t ack)
|
||||||
{
|
{
|
||||||
enum pm_ret_status ret = PM_RET_SUCCESS;
|
enum pm_ret_status ret = PM_RET_SUCCESS;
|
||||||
|
|
||||||
/* Return if interrupt is not from PMU */
|
/* Return if interrupt is not from PMU */
|
||||||
if (pm_ipi_irq_status(primary_proc) == 0U) {
|
if (pm_ipi_irq_status(primary_proc) != 0U) {
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
ret = pm_ipi_buff_read_callb(data, count);
|
ret = pm_ipi_buff_read_callb(data, count);
|
||||||
|
|
||||||
if (ack != 0U) {
|
if (ack != 0U) {
|
||||||
pm_ipi_irq_clear(primary_proc);
|
pm_ipi_irq_clear(primary_proc);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
@ -302,16 +309,19 @@ enum pm_ret_status pm_force_powerdown(uint32_t target, uint8_t ack,
|
||||||
uint32_t flag)
|
uint32_t flag)
|
||||||
{
|
{
|
||||||
uint32_t payload[PAYLOAD_ARG_CNT];
|
uint32_t payload[PAYLOAD_ARG_CNT];
|
||||||
|
enum pm_ret_status ret = PM_RET_SUCCESS;
|
||||||
|
|
||||||
/* Send request to the PMC */
|
/* Send request to the PMC */
|
||||||
PM_PACK_PAYLOAD3(payload, LIBPM_MODULE_ID, flag, PM_FORCE_POWERDOWN,
|
PM_PACK_PAYLOAD3(payload, LIBPM_MODULE_ID, flag, PM_FORCE_POWERDOWN,
|
||||||
target, ack);
|
target, ack);
|
||||||
|
|
||||||
if (ack == (uint32_t)IPI_BLOCKING) {
|
if (ack == (uint32_t)IPI_BLOCKING) {
|
||||||
return pm_ipi_send_sync(primary_proc, payload, NULL, 0);
|
ret = pm_ipi_send_sync(primary_proc, payload, NULL, 0);
|
||||||
} else {
|
} else {
|
||||||
return pm_ipi_send(primary_proc, payload);
|
ret = pm_ipi_send(primary_proc, payload);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -328,18 +338,22 @@ enum pm_ret_status pm_system_shutdown(uint32_t type, uint32_t subtype,
|
||||||
uint32_t flag)
|
uint32_t flag)
|
||||||
{
|
{
|
||||||
uint32_t payload[PAYLOAD_ARG_CNT];
|
uint32_t payload[PAYLOAD_ARG_CNT];
|
||||||
|
enum pm_ret_status ret = PM_RET_SUCCESS;
|
||||||
|
|
||||||
if (type == XPM_SHUTDOWN_TYPE_SETSCOPE_ONLY) {
|
if (type == XPM_SHUTDOWN_TYPE_SETSCOPE_ONLY) {
|
||||||
/* Setting scope for subsequent PSCI reboot or shutdown */
|
/* Setting scope for subsequent PSCI reboot or shutdown */
|
||||||
pm_shutdown_scope = subtype;
|
pm_shutdown_scope = subtype;
|
||||||
return PM_RET_SUCCESS;
|
goto exit_label;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Send request to the PMC */
|
/* Send request to the PMC */
|
||||||
PM_PACK_PAYLOAD3(payload, LIBPM_MODULE_ID, flag, PM_SYSTEM_SHUTDOWN,
|
PM_PACK_PAYLOAD3(payload, LIBPM_MODULE_ID, flag, PM_SYSTEM_SHUTDOWN,
|
||||||
type, subtype);
|
type, subtype);
|
||||||
|
|
||||||
return pm_ipi_send_non_blocking(primary_proc, payload);
|
ret = pm_ipi_send_non_blocking(primary_proc, payload);
|
||||||
|
|
||||||
|
exit_label:
|
||||||
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -412,16 +426,19 @@ enum pm_ret_status pm_feature_check(uint32_t api_id, uint32_t *ret_payload,
|
||||||
{
|
{
|
||||||
uint32_t payload[PAYLOAD_ARG_CNT];
|
uint32_t payload[PAYLOAD_ARG_CNT];
|
||||||
uint32_t module_id;
|
uint32_t module_id;
|
||||||
|
enum pm_ret_status ret;
|
||||||
|
|
||||||
/* Return version of API which are implemented in TF-A only */
|
/* Return version of API which are implemented in TF-A only */
|
||||||
switch (api_id) {
|
switch (api_id) {
|
||||||
case PM_GET_CALLBACK_DATA:
|
case PM_GET_CALLBACK_DATA:
|
||||||
case PM_GET_TRUSTZONE_VERSION:
|
case PM_GET_TRUSTZONE_VERSION:
|
||||||
ret_payload[0] = PM_API_VERSION_2;
|
ret_payload[0] = PM_API_VERSION_2;
|
||||||
return PM_RET_SUCCESS;
|
ret = PM_RET_SUCCESS;
|
||||||
|
goto exit_label;
|
||||||
case TF_A_PM_REGISTER_SGI:
|
case TF_A_PM_REGISTER_SGI:
|
||||||
ret_payload[0] = PM_API_BASE_VERSION;
|
ret_payload[0] = PM_API_BASE_VERSION;
|
||||||
return PM_RET_SUCCESS;
|
ret = PM_RET_SUCCESS;
|
||||||
|
goto exit_label;
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -433,12 +450,17 @@ enum pm_ret_status pm_feature_check(uint32_t api_id, uint32_t *ret_payload,
|
||||||
* If module_id is 0, then we consider it LIBPM module as default id
|
* If module_id is 0, then we consider it LIBPM module as default id
|
||||||
*/
|
*/
|
||||||
if ((module_id > 0U) && (module_id != LIBPM_MODULE_ID)) {
|
if ((module_id > 0U) && (module_id != LIBPM_MODULE_ID)) {
|
||||||
return PM_RET_SUCCESS;
|
ret = PM_RET_SUCCESS;
|
||||||
|
goto exit_label;
|
||||||
}
|
}
|
||||||
|
|
||||||
PM_PACK_PAYLOAD2(payload, LIBPM_MODULE_ID, flag,
|
PM_PACK_PAYLOAD2(payload, LIBPM_MODULE_ID, flag,
|
||||||
PM_FEATURE_CHECK, api_id);
|
PM_FEATURE_CHECK, api_id);
|
||||||
return pm_ipi_send_sync(primary_proc, payload, ret_payload, RET_PAYLOAD_ARG_CNT);
|
ret = pm_ipi_send_sync(primary_proc, payload, ret_payload, RET_PAYLOAD_ARG_CNT);
|
||||||
|
|
||||||
|
exit_label:
|
||||||
|
return ret;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -294,14 +294,17 @@ void pm_ipi_irq_clear(const struct pm_proc *proc)
|
||||||
uint32_t pm_ipi_irq_status(const struct pm_proc *proc)
|
uint32_t pm_ipi_irq_status(const struct pm_proc *proc)
|
||||||
{
|
{
|
||||||
int32_t ret;
|
int32_t ret;
|
||||||
|
int32_t result = 0;
|
||||||
|
|
||||||
ret = ipi_mb_enquire_status(proc->ipi->local_ipi_id,
|
ret = ipi_mb_enquire_status(proc->ipi->local_ipi_id,
|
||||||
proc->ipi->remote_ipi_id);
|
proc->ipi->remote_ipi_id);
|
||||||
if (((uint32_t)ret & IPI_MB_STATUS_RECV_PENDING) != 0U) {
|
if (((uint32_t)ret & IPI_MB_STATUS_RECV_PENDING) != 0U) {
|
||||||
return 1;
|
result = 1;
|
||||||
} else {
|
} else {
|
||||||
return 0;
|
result = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
#if IPI_CRC_CHECK
|
#if IPI_CRC_CHECK
|
||||||
|
|
|
@ -154,7 +154,7 @@ static uint64_t ipi_fiq_handler(uint32_t id, uint32_t flags, void *handle,
|
||||||
ipi_status = ipi_mb_enquire_status(IPI_ID_APU, IPI_ID_PMC);
|
ipi_status = ipi_mb_enquire_status(IPI_ID_APU, IPI_ID_PMC);
|
||||||
if (((uint32_t)ipi_status & IPI_MB_STATUS_RECV_PENDING) == 0U) {
|
if (((uint32_t)ipi_status & IPI_MB_STATUS_RECV_PENDING) == 0U) {
|
||||||
plat_ic_end_of_interrupt(id);
|
plat_ic_end_of_interrupt(id);
|
||||||
return 0;
|
goto exit_label;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Handle PMC case */
|
/* Handle PMC case */
|
||||||
|
@ -201,6 +201,7 @@ static uint64_t ipi_fiq_handler(uint32_t id, uint32_t flags, void *handle,
|
||||||
/* Clear FIQ */
|
/* Clear FIQ */
|
||||||
plat_ic_end_of_interrupt(id);
|
plat_ic_end_of_interrupt(id);
|
||||||
|
|
||||||
|
exit_label:
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -218,21 +219,19 @@ static uint64_t ipi_fiq_handler(uint32_t id, uint32_t flags, void *handle,
|
||||||
*/
|
*/
|
||||||
int32_t pm_register_sgi(uint32_t sgi_num, uint32_t reset)
|
int32_t pm_register_sgi(uint32_t sgi_num, uint32_t reset)
|
||||||
{
|
{
|
||||||
|
int32_t ret = 0;
|
||||||
|
|
||||||
if (reset == 1U) {
|
if (reset == 1U) {
|
||||||
sgi = INVALID_SGI;
|
sgi = INVALID_SGI;
|
||||||
return 0;
|
} else if (sgi != INVALID_SGI) {
|
||||||
}
|
ret = -EBUSY;
|
||||||
|
} else if (sgi_num >= GICV3_MAX_SGI_TARGETS) {
|
||||||
if (sgi != INVALID_SGI) {
|
ret = -EINVAL;
|
||||||
return -EBUSY;
|
} else {
|
||||||
}
|
|
||||||
|
|
||||||
if (sgi_num >= GICV3_MAX_SGI_TARGETS) {
|
|
||||||
return -EINVAL;
|
|
||||||
}
|
|
||||||
|
|
||||||
sgi = (uint32_t)sgi_num;
|
sgi = (uint32_t)sgi_num;
|
||||||
return 0;
|
}
|
||||||
|
|
||||||
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -25,12 +25,17 @@
|
||||||
*/
|
*/
|
||||||
int32_t plat_is_smccc_feature_available(u_register_t fid)
|
int32_t plat_is_smccc_feature_available(u_register_t fid)
|
||||||
{
|
{
|
||||||
|
int32_t ret = 0;
|
||||||
|
|
||||||
switch (fid) {
|
switch (fid) {
|
||||||
case SMCCC_ARCH_SOC_ID:
|
case SMCCC_ARCH_SOC_ID:
|
||||||
return SMC_ARCH_CALL_SUCCESS;
|
ret = SMC_ARCH_CALL_SUCCESS;
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
return SMC_ARCH_CALL_NOT_SUPPORTED;
|
ret = SMC_ARCH_CALL_NOT_SUPPORTED;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
Loading…
Add table
Reference in a new issue