aboutsummaryrefslogtreecommitdiff
path: root/drivers/arm
diff options
context:
space:
mode:
authorAntonio Nino Diaz <antonio.ninodiaz@arm.com>2018-08-23 10:19:23 +0100
committerAntonio Nino Diaz <antonio.ninodiaz@arm.com>2018-08-30 09:22:34 +0100
commit4213e9bacd4cfd98e19963af87a70320be73a1af (patch)
tree0d2e25b4947aa331bade795b5f84f06fd5976697 /drivers/arm
parent6d5f0631a63a7df7ad936fea4e6cd9edd25a9be0 (diff)
downloadtrusted-firmware-a-4213e9bacd4cfd98e19963af87a70320be73a1af.tar.gz
drivers: cci: Fix MISRA defects
Change-Id: Ifdb0ceec19d267b14d796b5d31f08f7342190484 Signed-off-by: Antonio Nino Diaz <antonio.ninodiaz@arm.com>
Diffstat (limited to 'drivers/arm')
-rw-r--r--drivers/arm/cci/cci.c45
1 files changed, 23 insertions, 22 deletions
diff --git a/drivers/arm/cci/cci.c b/drivers/arm/cci/cci.c
index a6ee77a50a..91245d46ca 100644
--- a/drivers/arm/cci/cci.c
+++ b/drivers/arm/cci/cci.c
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2015-2017, ARM Limited and Contributors. All rights reserved.
+ * Copyright (c) 2015-2018, ARM Limited and Contributors. All rights reserved.
*
* SPDX-License-Identifier: BSD-3-Clause
*/
@@ -10,11 +10,12 @@
#include <cci.h>
#include <debug.h>
#include <mmio.h>
+#include <stdbool.h>
#include <stdint.h>
-#define MAKE_CCI_PART_NUMBER(hi, lo) ((hi << 8) | lo)
-#define CCI_PART_LO_MASK 0xff
-#define CCI_PART_HI_MASK 0xf
+#define MAKE_CCI_PART_NUMBER(hi, lo) (((hi) << 8) | (lo))
+#define CCI_PART_LO_MASK U(0xff)
+#define CCI_PART_HI_MASK U(0xf)
/* CCI part number codes read from Peripheral ID registers 0 and 1 */
#define CCI400_PART_NUM 0x420
@@ -32,14 +33,14 @@ static const int *cci_slave_if_map;
static unsigned int max_master_id;
static int cci_num_slave_ports;
-static int validate_cci_map(const int *map)
+static bool validate_cci_map(const int *map)
{
- unsigned int valid_cci_map = 0;
+ unsigned int valid_cci_map = 0U;
int slave_if_id;
- int i;
+ unsigned int i;
/* Validate the map */
- for (i = 0; i <= max_master_id; i++) {
+ for (i = 0U; i <= max_master_id; i++) {
slave_if_id = map[i];
if (slave_if_id < 0)
@@ -47,22 +48,22 @@ static int validate_cci_map(const int *map)
if (slave_if_id >= cci_num_slave_ports) {
ERROR("Slave interface ID is invalid\n");
- return 0;
+ return false;
}
- if (valid_cci_map & (1 << slave_if_id)) {
+ if ((valid_cci_map & (1U << slave_if_id)) != 0U) {
ERROR("Multiple masters are assigned same slave interface ID\n");
- return 0;
+ return false;
}
- valid_cci_map |= 1 << slave_if_id;
+ valid_cci_map |= 1U << slave_if_id;
}
- if (!valid_cci_map) {
+ if (valid_cci_map == 0U) {
ERROR("No master is assigned a valid slave interface\n");
- return 0;
+ return false;
}
- return 1;
+ return true;
}
/*
@@ -108,8 +109,8 @@ static int get_slave_ports(unsigned int part_num)
void cci_init(uintptr_t base, const int *map, unsigned int num_cci_masters)
{
- assert(map);
- assert(base);
+ assert(map != NULL);
+ assert(base != 0U);
cci_base = base;
cci_slave_if_map = map;
@@ -119,7 +120,7 @@ void cci_init(uintptr_t base, const int *map, unsigned int num_cci_masters)
* Master Id's are assigned from zero, So in an array of size n
* the max master id is (n - 1).
*/
- max_master_id = num_cci_masters - 1;
+ max_master_id = num_cci_masters - 1U;
cci_num_slave_ports = get_slave_ports(read_cci_part_number(base));
#endif
assert(cci_num_slave_ports >= 0);
@@ -133,7 +134,7 @@ void cci_enable_snoop_dvm_reqs(unsigned int master_id)
assert(master_id <= max_master_id);
assert((slave_if_id < cci_num_slave_ports) && (slave_if_id >= 0));
- assert(cci_base);
+ assert(cci_base != 0U);
/*
* Enable Snoops and DVM messages, no need for Read/Modify/Write as
@@ -150,7 +151,7 @@ void cci_enable_snoop_dvm_reqs(unsigned int master_id)
dsbish();
/* Wait for the dust to settle down */
- while (mmio_read_32(cci_base + STATUS_REG) & CHANGE_PENDING_BIT)
+ while ((mmio_read_32(cci_base + STATUS_REG) & CHANGE_PENDING_BIT) != 0U)
;
}
@@ -160,7 +161,7 @@ void cci_disable_snoop_dvm_reqs(unsigned int master_id)
assert(master_id <= max_master_id);
assert((slave_if_id < cci_num_slave_ports) && (slave_if_id >= 0));
- assert(cci_base);
+ assert(cci_base != 0U);
/*
* Disable Snoops and DVM messages, no need for Read/Modify/Write as
@@ -177,7 +178,7 @@ void cci_disable_snoop_dvm_reqs(unsigned int master_id)
dsbish();
/* Wait for the dust to settle down */
- while (mmio_read_32(cci_base + STATUS_REG) & CHANGE_PENDING_BIT)
+ while ((mmio_read_32(cci_base + STATUS_REG) & CHANGE_PENDING_BIT) != 0U)
;
}