drivers: fix switch statements to comply with MISRA rules
Ensure (where possible) that switch statements in drivers comply with
MISRA rules 16.1 - 16.7.
Change-Id: I7a91e04b02af80fbc4673a52293386c0f81a0f7a
Signed-off-by: Jonathan Wright <jonathan.wright@arm.com>
diff --git a/drivers/arm/cci/cci.c b/drivers/arm/cci/cci.c
index e156838..81808b9 100644
--- a/drivers/arm/cci/cci.c
+++ b/drivers/arm/cci/cci.c
@@ -83,22 +83,25 @@
*/
static int get_slave_ports(unsigned int part_num)
{
- /* Macro to match CCI products */
-#define RET_ON_MATCH(product) \
- case CCI ## product ## _PART_NUM: \
- return CCI ## product ## _SLAVE_PORTS
+ int num_slave_ports = -1;
switch (part_num) {
- RET_ON_MATCH(400);
- RET_ON_MATCH(500);
- RET_ON_MATCH(550);
-
+ case CCI400_PART_NUM:
+ num_slave_ports = CCI400_SLAVE_PORTS;
+ break;
+ case CCI500_PART_NUM:
+ num_slave_ports = CCI500_SLAVE_PORTS;
+ break;
+ case CCI550_PART_NUM:
+ num_slave_ports = CCI550_SLAVE_PORTS;
+ break;
default:
- return -1;
+ /* Do nothing in default case */
+ break;
}
-#undef RET_ON_MATCH
+ return num_slave_ports;
}
#endif /* ENABLE_ASSERTIONS */
diff --git a/drivers/arm/gic/v2/gicv2_main.c b/drivers/arm/gic/v2/gicv2_main.c
index 7e2c7a7..e25e501 100644
--- a/drivers/arm/gic/v2/gicv2_main.c
+++ b/drivers/arm/gic/v2/gicv2_main.c
@@ -459,6 +459,7 @@
break;
default:
assert(0);
+ break;
}
spin_unlock(&gic_lock);
}
diff --git a/drivers/arm/gic/v3/gicv3_main.c b/drivers/arm/gic/v3/gicv3_main.c
index f4a3ef8..d8fc7d6 100644
--- a/drivers/arm/gic/v3/gicv3_main.c
+++ b/drivers/arm/gic/v3/gicv3_main.c
@@ -1004,6 +1004,7 @@
break;
default:
assert(0);
+ break;
}
if (id < MIN_SPI_ID) {
diff --git a/drivers/synopsys/emmc/dw_mmc.c b/drivers/synopsys/emmc/dw_mmc.c
index 701e6d5..156c2b4 100644
--- a/drivers/synopsys/emmc/dw_mmc.c
+++ b/drivers/synopsys/emmc/dw_mmc.c
@@ -321,6 +321,7 @@
break;
default:
assert(0);
+ break;
}
dw_set_clk(clk);
return 0;
diff --git a/drivers/ufs/ufs.c b/drivers/ufs/ufs.c
index 254866f..515fc27 100644
--- a/drivers/ufs/ufs.c
+++ b/drivers/ufs/ufs.c
@@ -271,6 +271,7 @@
break;
default:
assert(0);
+ break;
}
if (hd->dd == DD_IN)
flush_dcache_range(buf, length);
@@ -359,6 +360,7 @@
break;
default:
assert(0);
+ break;
}
flush_dcache_range((uintptr_t)utrd, sizeof(utp_utrd_t));
flush_dcache_range((uintptr_t)utrd->header, UFS_DESC_SIZE);
@@ -511,6 +513,9 @@
case QUERY_WRITE_ATTR:
assert(((buf & 3) == 0) && (size != 0));
break;
+ default:
+ /* Do nothing in default case */
+ break;
}
get_utrd(&utrd);
ufs_prepare_query(&utrd, op, idn, index, sel, buf, size);
@@ -533,6 +538,9 @@
(void *)(utrd.resp_upiu + sizeof(query_resp_upiu_t)),
size);
break;
+ default:
+ /* Do nothing in default case */
+ break;
}
(void)result;
}