From 964e55928c8f966633cc57e41987aa00890f5da7 Mon Sep 17 00:00:00 2001 From: Jay Buddhabhatti Date: Thu, 9 Feb 2023 22:56:53 -0800 Subject: [PATCH] fix(xilinx): fix misra defects This patch fixes defects 5.5, 10.1, 10.3, 10.4, 10.7 reported by MISRA-2012 scan. Signed-off-by: Jay Buddhabhatti Change-Id: Ie6f6e9bf2ce1335bbb61aa2e69a3a196865fd504 --- plat/xilinx/common/include/pm_defs.h | 6 +++--- plat/xilinx/common/include/pm_node.h | 8 ++++---- plat/xilinx/common/pm_service/pm_api_sys.c | 12 ++++++------ plat/xilinx/common/pm_service/pm_svc_main.c | 18 +++++++++--------- 4 files changed, 22 insertions(+), 22 deletions(-) diff --git a/plat/xilinx/common/include/pm_defs.h b/plat/xilinx/common/include/pm_defs.h index eae1f842d..09507dda5 100644 --- a/plat/xilinx/common/include/pm_defs.h +++ b/plat/xilinx/common/include/pm_defs.h @@ -30,9 +30,9 @@ #define XPM_DEVID_ACPU_0 APU_DEVID(XPM_NODEIDX_DEV_ACPU_0) #define XPM_DEVID_ACPU_1 APU_DEVID(XPM_NODEIDX_DEV_ACPU_1) -#define PERIPH_DEVID(IDX) NODEID(XPM_NODECLASS_DEVICE, \ - XPM_NODESUBCL_DEV_PERIPH, \ - XPM_NODETYPE_DEV_PERIPH, (IDX)) +#define PERIPH_DEVID(IDX) NODEID((uint32_t)XPM_NODECLASS_DEVICE, \ + (uint32_t)XPM_NODESUBCL_DEV_PERIPH, \ + (uint32_t)XPM_NODETYPE_DEV_PERIPH, (IDX)) #define PM_GET_CALLBACK_DATA 0xa01U #define PM_GET_TRUSTZONE_VERSION 0xa03U diff --git a/plat/xilinx/common/include/pm_node.h b/plat/xilinx/common/include/pm_node.h index 0d5616c73..b6c2d8142 100644 --- a/plat/xilinx/common/include/pm_node.h +++ b/plat/xilinx/common/include/pm_node.h @@ -18,10 +18,10 @@ #define NODE_SUBCLASS_SHIFT 20U #define NODE_TYPE_SHIFT 14U #define NODE_INDEX_SHIFT 0U -#define NODE_CLASS_MASK_BITS 0x3F -#define NODE_SUBCLASS_MASK_BITS 0x3F -#define NODE_TYPE_MASK_BITS 0x3F -#define NODE_INDEX_MASK_BITS 0x3FFF +#define NODE_CLASS_MASK_BITS GENMASK_32(5, 0) +#define NODE_SUBCLASS_MASK_BITS GENMASK_32(5, 0) +#define NODE_TYPE_MASK_BITS GENMASK_32(5, 0) +#define NODE_INDEX_MASK_BITS GENMASK_32(13, 0) #define NODE_CLASS_MASK (NODE_CLASS_MASK_BITS << NODE_CLASS_SHIFT) #define NODE_SUBCLASS_MASK (NODE_SUBCLASS_MASK_BITS << NODE_SUBCLASS_SHIFT) #define NODE_TYPE_MASK (NODE_TYPE_MASK_BITS << NODE_TYPE_SHIFT) diff --git a/plat/xilinx/common/pm_service/pm_api_sys.c b/plat/xilinx/common/pm_service/pm_api_sys.c index 582b724f8..c36a0ec8f 100644 --- a/plat/xilinx/common/pm_service/pm_api_sys.c +++ b/plat/xilinx/common/pm_service/pm_api_sys.c @@ -48,7 +48,7 @@ void pm_client_set_wakeup_sources(uint32_t node_id) { uint32_t reg_num, device_id; uint8_t pm_wakeup_nodes_set[XPM_NODEIDX_DEV_MAX] = {0U}; - uintptr_t isenabler1 = PLAT_GICD_BASE_VALUE + GICD_ISENABLER + 4U; + uint32_t isenabler1 = PLAT_GICD_BASE_VALUE + GICD_ISENABLER + 4U; zeromem(&pm_wakeup_nodes_set, (u_register_t)sizeof(pm_wakeup_nodes_set)); @@ -65,7 +65,7 @@ void pm_client_set_wakeup_sources(uint32_t node_id) uint32_t idx, irq, lowest_set = reg & (-reg); enum pm_ret_status ret; - idx = __builtin_ctz(lowest_set); + idx = (uint32_t)__builtin_ctz(lowest_set); irq = base_irq + idx; if (irq > IRQ_MAX) { @@ -78,7 +78,7 @@ void pm_client_set_wakeup_sources(uint32_t node_id) if (node_idx > XPM_NODEIDX_DEV_MIN) { if (pm_wakeup_nodes_set[node_idx] == 0U) { /* Get device ID from node index */ - device_id = PERIPH_DEVID(node_idx); + device_id = PERIPH_DEVID((uint32_t)node_idx); ret = pm_set_wakeup_source(node_id, device_id, 1U, SECURE_FLAG); @@ -461,7 +461,7 @@ enum pm_ret_status pm_query_data(uint32_t qid, uint32_t arg1, uint32_t arg2, PM_PACK_PAYLOAD5(payload, LIBPM_MODULE_ID, flag, PM_QUERY_DATA, qid, arg1, arg2, arg3); - ret = pm_feature_check(PM_QUERY_DATA, &version[0], flag); + ret = pm_feature_check((uint32_t)PM_QUERY_DATA, &version[0], flag); if (ret == PM_RET_SUCCESS) { fw_api_version = version[0] & 0xFFFFU; if ((fw_api_version == 2U) && @@ -515,10 +515,10 @@ enum pm_ret_status pm_api_ioctl(uint32_t device_id, uint32_t ioctl_id, ret = pm_pll_get_mode(arg1, value, flag); break; case IOCTL_SET_PLL_FRAC_DATA: - ret = pm_pll_set_param(arg1, PM_PLL_PARAM_DATA, arg2, flag); + ret = pm_pll_set_param(arg1, (uint32_t)PM_PLL_PARAM_DATA, arg2, flag); break; case IOCTL_GET_PLL_FRAC_DATA: - ret = pm_pll_get_param(arg1, PM_PLL_PARAM_DATA, value, flag); + ret = pm_pll_get_param(arg1, (uint32_t)PM_PLL_PARAM_DATA, value, flag); break; case IOCTL_SET_SGI: /* Get the sgi number */ diff --git a/plat/xilinx/common/pm_service/pm_svc_main.c b/plat/xilinx/common/pm_service/pm_svc_main.c index 6fd7f0d52..1bd2192a6 100644 --- a/plat/xilinx/common/pm_service/pm_svc_main.c +++ b/plat/xilinx/common/pm_service/pm_svc_main.c @@ -168,7 +168,7 @@ static uintptr_t eemi_for_compatibility(uint32_t api_id, uint32_t *pm_arg, switch (api_id) { - case PM_IOCTL: + case (uint32_t)PM_IOCTL: { uint32_t value = 0U; @@ -181,7 +181,7 @@ static uintptr_t eemi_for_compatibility(uint32_t api_id, uint32_t *pm_arg, SMC_RET1(handle, (uint64_t)ret | ((uint64_t)value) << 32U); } - case PM_QUERY_DATA: + case (uint32_t)PM_QUERY_DATA: { uint32_t data[PAYLOAD_ARG_CNT] = { 0 }; @@ -192,7 +192,7 @@ static uintptr_t eemi_for_compatibility(uint32_t api_id, uint32_t *pm_arg, (uint64_t)data[1] | ((uint64_t)data[2] << 32U)); } - case PM_FEATURE_CHECK: + case (uint32_t)PM_FEATURE_CHECK: { uint32_t result[PAYLOAD_ARG_CNT] = {0U}; @@ -230,25 +230,25 @@ static uintptr_t eemi_psci_debugfs_handler(uint32_t api_id, uint32_t *pm_arg, switch (api_id) { - case PM_SELF_SUSPEND: + case (uint32_t)PM_SELF_SUSPEND: ret = pm_self_suspend(pm_arg[0], pm_arg[1], pm_arg[2], pm_arg[3], security_flag); SMC_RET1(handle, (u_register_t)ret); - case PM_FORCE_POWERDOWN: + case (uint32_t)PM_FORCE_POWERDOWN: ret = pm_force_powerdown(pm_arg[0], pm_arg[1], security_flag); SMC_RET1(handle, (u_register_t)ret); - case PM_REQ_SUSPEND: + case (uint32_t)PM_REQ_SUSPEND: ret = pm_req_suspend(pm_arg[0], pm_arg[1], pm_arg[2], pm_arg[3], security_flag); SMC_RET1(handle, (u_register_t)ret); - case PM_ABORT_SUSPEND: + case (uint32_t)PM_ABORT_SUSPEND: ret = pm_abort_suspend(pm_arg[0], security_flag); SMC_RET1(handle, (u_register_t)ret); - case PM_SYSTEM_SHUTDOWN: + case (uint32_t)PM_SYSTEM_SHUTDOWN: ret = pm_system_shutdown(pm_arg[0], pm_arg[1], security_flag); SMC_RET1(handle, (u_register_t)ret); @@ -330,7 +330,7 @@ static uintptr_t eemi_handler(uint32_t api_id, uint32_t *pm_arg, * receive only 4 words from TF-A. So, this needs to be handled separately * than other eemi calls. */ - if (api_id == PM_QUERY_DATA) { + if (api_id == (uint32_t)PM_QUERY_DATA) { if ((pm_arg[0] == XPM_QID_CLOCK_GET_NAME || pm_arg[0] == XPM_QID_PINCTRL_GET_FUNCTION_NAME) && ret == PM_RET_SUCCESS) { -- 2.39.5