From 195e363f84c080bc0e8f3799391164fff1aece70 Mon Sep 17 00:00:00 2001 From: Antonio Nino Diaz Date: Thu, 25 Oct 2018 17:38:23 +0100 Subject: [PATCH] Fix MISRA defects in PMF No functional changes. Change-Id: I64abd72026082218a40b1a4b8f7dc26ff2478ba6 Signed-off-by: Antonio Nino Diaz --- include/lib/pmf/pmf.h | 17 +++++++++-------- include/lib/pmf/pmf_helpers.h | 1 - lib/pmf/pmf_main.c | 14 +++++++------- lib/pmf/pmf_smc.c | 6 ++++-- 4 files changed, 20 insertions(+), 18 deletions(-) diff --git a/include/lib/pmf/pmf.h b/include/lib/pmf/pmf.h index a3812fbf..18ef0a55 100644 --- a/include/lib/pmf/pmf.h +++ b/include/lib/pmf/pmf.h @@ -9,17 +9,18 @@ #include #include +#include /* * Constants used for/by PMF services. */ -#define PMF_ARM_TIF_IMPL_ID 0x41 +#define PMF_ARM_TIF_IMPL_ID U(0x41) #define PMF_TID_SHIFT 0 -#define PMF_TID_MASK (0xFF << PMF_TID_SHIFT) +#define PMF_TID_MASK (U(0xFF) << PMF_TID_SHIFT) #define PMF_SVC_ID_SHIFT 10 -#define PMF_SVC_ID_MASK (0x3F << PMF_SVC_ID_SHIFT) +#define PMF_SVC_ID_MASK (U(0x3F) << PMF_SVC_ID_SHIFT) #define PMF_IMPL_ID_SHIFT 24 -#define PMF_IMPL_ID_MASK (0xFFU << PMF_IMPL_ID_SHIFT) +#define PMF_IMPL_ID_MASK (U(0xFF) << PMF_IMPL_ID_SHIFT) /* * Flags passed to PMF_REGISTER_SERVICE @@ -37,16 +38,16 @@ /* * Defines for PMF SMC function ids. */ -#define PMF_SMC_GET_TIMESTAMP_32 0x82000010u -#define PMF_SMC_GET_TIMESTAMP_64 0xC2000010u +#define PMF_SMC_GET_TIMESTAMP_32 U(0x82000010) +#define PMF_SMC_GET_TIMESTAMP_64 U(0xC2000010) #define PMF_NUM_SMC_CALLS 2 /* * The macros below are used to identify * PMF calls from the SMC function ID. */ -#define PMF_FID_MASK 0xffe0u -#define PMF_FID_VALUE 0u +#define PMF_FID_MASK U(0xffe0) +#define PMF_FID_VALUE U(0) #define is_pmf_fid(_fid) (((_fid) & PMF_FID_MASK) == PMF_FID_VALUE) /* Following are the supported PMF service IDs */ diff --git a/include/lib/pmf/pmf_helpers.h b/include/lib/pmf/pmf_helpers.h index b9757de0..c535b222 100644 --- a/include/lib/pmf/pmf_helpers.h +++ b/include/lib/pmf/pmf_helpers.h @@ -11,7 +11,6 @@ #include #include #include -#include #include #include diff --git a/lib/pmf/pmf_main.c b/lib/pmf/pmf_main.c index 25513c19..fe7bb742 100644 --- a/lib/pmf/pmf_main.c +++ b/lib/pmf/pmf_main.c @@ -26,7 +26,7 @@ IMPORT_SYM(uintptr_t, __PMF_SVC_DESCS_START__, PMF_SVC_DESCS_START); IMPORT_SYM(uintptr_t, __PMF_SVC_DESCS_END__, PMF_SVC_DESCS_END); IMPORT_SYM(uintptr_t, __PMF_PERCPU_TIMESTAMP_END__, PMF_PERCPU_TIMESTAMP_END); -IMPORT_SYM(intptr_t, __PMF_TIMESTAMP_START__, PMF_TIMESTAMP_ARRAY_START); +IMPORT_SYM(uintptr_t, __PMF_TIMESTAMP_START__, PMF_TIMESTAMP_ARRAY_START); #define PMF_PERCPU_TIMESTAMP_SIZE (PMF_PERCPU_TIMESTAMP_END - PMF_TIMESTAMP_ARRAY_START) @@ -67,15 +67,15 @@ int pmf_setup(void) pmf_svc_descs = (pmf_svc_desc_t *) PMF_SVC_DESCS_START; for (ii = 0; ii < pmf_svc_descs_num; ii++) { - assert(pmf_svc_descs[ii].get_ts); + assert(pmf_svc_descs[ii].get_ts != NULL); /* * Call the initialization routine for this * PMF service, if it is defined. */ - if (pmf_svc_descs[ii].init) { + if (pmf_svc_descs[ii].init != NULL) { rc = pmf_svc_descs[ii].init(); - if (rc) { + if (rc != 0) { WARN("Could not initialize PMF" "service %s - skipping \n", pmf_svc_descs[ii].name); @@ -125,7 +125,7 @@ static pmf_svc_desc_t *get_service(unsigned int tid) if (pmf_num_services == 0) return NULL; - assert(pmf_svc_descs); + assert(pmf_svc_descs != NULL); do { mid = (low + high) / 2; @@ -158,7 +158,7 @@ int pmf_get_timestamp_smc(unsigned int tid, unsigned long long *ts_value) { pmf_svc_desc_t *svc_desc; - assert(ts_value); + assert(ts_value != NULL); /* Search for registered service. */ svc_desc = get_service(tid); @@ -247,7 +247,7 @@ unsigned long long __pmf_get_timestamp(uintptr_t base_addr, unsigned long long *ts_addr = (unsigned long long *)calc_ts_addr(base_addr, tid, cpuid); - if (flags & PMF_CACHE_MAINT) + if ((flags & PMF_CACHE_MAINT) != 0U) inv_dcache_range((uintptr_t)ts_addr, sizeof(unsigned long long)); return *ts_addr; diff --git a/lib/pmf/pmf_smc.c b/lib/pmf/pmf_smc.c index e8661180..4c5b14f9 100644 --- a/lib/pmf/pmf_smc.c +++ b/lib/pmf/pmf_smc.c @@ -37,7 +37,8 @@ uintptr_t pmf_smc_handler(unsigned int smc_fid, * x0 --> error code. * x1 - x2 --> time-stamp value. */ - rc = pmf_get_timestamp_smc(x1, x2, x3, &ts_value); + rc = pmf_get_timestamp_smc((unsigned int)x1, x2, + (unsigned int)x3, &ts_value); SMC_RET3(handle, rc, (uint32_t)ts_value, (uint32_t)(ts_value >> 32)); } @@ -49,7 +50,8 @@ uintptr_t pmf_smc_handler(unsigned int smc_fid, * x0 --> error code. * x1 --> time-stamp value. */ - rc = pmf_get_timestamp_smc(x1, x2, x3, &ts_value); + rc = pmf_get_timestamp_smc((unsigned int)x1, x2, + (unsigned int)x3, &ts_value); SMC_RET2(handle, rc, ts_value); } } -- 2.30.2