Commit bef9a10f authored by Antonio Nino Diaz's avatar Antonio Nino Diaz
Browse files

PMF: Fix MISRA defects



Fix instances of MISRA C-2012 Rule 10.1 and 21.1.

Change-Id: I5676edede0703481e3635be0bc4a635df8e48f5e
Signed-off-by: default avatarAntonio Nino Diaz <antonio.ninodiaz@arm.com>
parent 4829df83
......@@ -4,8 +4,8 @@
* SPDX-License-Identifier: BSD-3-Clause
*/
#ifndef __PMF_H__
#define __PMF_H__
#ifndef PMF_H
#define PMF_H
#include <cassert.h>
#include <pmf_helpers.h>
......@@ -31,8 +31,8 @@
* Flags passed to PMF_GET_TIMESTAMP_XXX
* and PMF_CAPTURE_TIMESTAMP
*/
#define PMF_CACHE_MAINT (1 << 0)
#define PMF_NO_CACHE_MAINT 0
#define PMF_CACHE_MAINT (U(1) << 0)
#define PMF_NO_CACHE_MAINT U(0)
/*
* Defines for PMF SMC function ids.
......@@ -68,7 +68,7 @@
#define PMF_CAPTURE_TIMESTAMP(_name, _tid, _flags) \
do { \
unsigned long long ts = read_cntpct_el0(); \
if ((_flags) & PMF_CACHE_MAINT) \
if (((_flags) & PMF_CACHE_MAINT) != 0U) \
pmf_capture_timestamp_with_cache_maint_ ## _name((_tid), ts);\
else \
pmf_capture_timestamp_ ## _name((_tid), ts); \
......@@ -78,7 +78,7 @@
do { \
(_tsval) = read_cntpct_el0(); \
CASSERT(sizeof(_tsval) == sizeof(unsigned long long), invalid_tsval_size);\
if ((_flags) & PMF_CACHE_MAINT) \
if (((_flags) & PMF_CACHE_MAINT) != 0U) \
pmf_capture_timestamp_with_cache_maint_ ## _name((_tid), (_tsval));\
else \
pmf_capture_timestamp_ ## _name((_tid), (_tsval));\
......@@ -87,7 +87,7 @@
#define PMF_WRITE_TIMESTAMP(_name, _tid, _flags, _wrval) \
do { \
CASSERT(sizeof(_wrval) == sizeof(unsigned long long), invalid_wrval_size);\
if ((_flags) & PMF_CACHE_MAINT) \
if (((_flags) & PMF_CACHE_MAINT) != 0U) \
pmf_capture_timestamp_with_cache_maint_ ## _name((_tid), (_wrval));\
else \
pmf_capture_timestamp_ ## _name((_tid), (_wrval));\
......@@ -173,4 +173,4 @@ uintptr_t pmf_smc_handler(unsigned int smc_fid,
void *handle,
u_register_t flags);
#endif /* __PMF_H__ */
#endif /* PMF_H */
......@@ -4,8 +4,8 @@
* SPDX-License-Identifier: BSD-3-Clause
*/
#ifndef __PMF_HELPERS_H__
#define __PMF_HELPERS_H__
#ifndef PMF_HELPERS_H
#define PMF_HELPERS_H
#include <arch_helpers.h>
#include <assert.h>
......@@ -77,9 +77,9 @@ typedef struct pmf_svc_desc {
CASSERT(_flags, select_proper_config); \
PMF_VALIDATE_TID(_name, tid); \
uintptr_t base_addr = (uintptr_t) pmf_ts_mem_ ## _name; \
if ((_flags) & PMF_STORE_ENABLE) \
if (((_flags) & PMF_STORE_ENABLE) != 0) \
__pmf_store_timestamp(base_addr, tid, ts); \
if ((_flags) & PMF_DUMP_ENABLE) \
if (((_flags) & PMF_DUMP_ENABLE) != 0) \
__pmf_dump_timestamp(tid, ts); \
} \
void pmf_capture_timestamp_with_cache_maint_ ## _name( \
......@@ -92,9 +92,9 @@ typedef struct pmf_svc_desc {
CASSERT(_flags, select_proper_config); \
PMF_VALIDATE_TID(_name, tid); \
uintptr_t base_addr = (uintptr_t) pmf_ts_mem_ ## _name; \
if ((_flags) & PMF_STORE_ENABLE) \
if (((_flags) & PMF_STORE_ENABLE) != 0) \
__pmf_store_timestamp_with_cache_maint(base_addr, tid, ts);\
if ((_flags) & PMF_DUMP_ENABLE) \
if (((_flags) & PMF_DUMP_ENABLE) != 0) \
__pmf_dump_timestamp(tid, ts); \
}
......@@ -159,4 +159,4 @@ unsigned long long __pmf_get_timestamp(uintptr_t base_addr,
unsigned int tid,
unsigned int cpuid,
unsigned int flags);
#endif /* __PMF_HELPERS_H__ */
#endif /* PMF_HELPERS_H */
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment