Commit 5aa7498a authored by Jonathan Wright's avatar Jonathan Wright
Browse files

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: default avatarJonathan Wright <jonathan.wright@arm.com>
parent c9662db9
...@@ -83,22 +83,25 @@ static unsigned int read_cci_part_number(uintptr_t base) ...@@ -83,22 +83,25 @@ static unsigned int read_cci_part_number(uintptr_t base)
*/ */
static int get_slave_ports(unsigned int part_num) static int get_slave_ports(unsigned int part_num)
{ {
/* Macro to match CCI products */ int num_slave_ports = -1;
#define RET_ON_MATCH(product) \
case CCI ## product ## _PART_NUM: \
return CCI ## product ## _SLAVE_PORTS
switch (part_num) { switch (part_num) {
RET_ON_MATCH(400); case CCI400_PART_NUM:
RET_ON_MATCH(500); num_slave_ports = CCI400_SLAVE_PORTS;
RET_ON_MATCH(550); break;
case CCI500_PART_NUM:
num_slave_ports = CCI500_SLAVE_PORTS;
break;
case CCI550_PART_NUM:
num_slave_ports = CCI550_SLAVE_PORTS;
break;
default: default:
return -1; /* Do nothing in default case */
break;
} }
#undef RET_ON_MATCH return num_slave_ports;
} }
#endif /* ENABLE_ASSERTIONS */ #endif /* ENABLE_ASSERTIONS */
......
...@@ -459,6 +459,7 @@ void gicv2_set_interrupt_type(unsigned int id, unsigned int type) ...@@ -459,6 +459,7 @@ void gicv2_set_interrupt_type(unsigned int id, unsigned int type)
break; break;
default: default:
assert(0); assert(0);
break;
} }
spin_unlock(&gic_lock); spin_unlock(&gic_lock);
} }
......
...@@ -1004,6 +1004,7 @@ void gicv3_set_interrupt_type(unsigned int id, unsigned int proc_num, ...@@ -1004,6 +1004,7 @@ void gicv3_set_interrupt_type(unsigned int id, unsigned int proc_num,
break; break;
default: default:
assert(0); assert(0);
break;
} }
if (id < MIN_SPI_ID) { if (id < MIN_SPI_ID) {
......
...@@ -321,6 +321,7 @@ static int dw_set_ios(int clk, int width) ...@@ -321,6 +321,7 @@ static int dw_set_ios(int clk, int width)
break; break;
default: default:
assert(0); assert(0);
break;
} }
dw_set_clk(clk); dw_set_clk(clk);
return 0; return 0;
......
...@@ -271,6 +271,7 @@ static int ufs_prepare_cmd(utp_utrd_t *utrd, uint8_t op, uint8_t lun, ...@@ -271,6 +271,7 @@ static int ufs_prepare_cmd(utp_utrd_t *utrd, uint8_t op, uint8_t lun,
break; break;
default: default:
assert(0); assert(0);
break;
} }
if (hd->dd == DD_IN) if (hd->dd == DD_IN)
flush_dcache_range(buf, length); flush_dcache_range(buf, length);
...@@ -359,6 +360,7 @@ static int ufs_prepare_query(utp_utrd_t *utrd, uint8_t op, uint8_t idn, ...@@ -359,6 +360,7 @@ static int ufs_prepare_query(utp_utrd_t *utrd, uint8_t op, uint8_t idn,
break; break;
default: default:
assert(0); assert(0);
break;
} }
flush_dcache_range((uintptr_t)utrd, sizeof(utp_utrd_t)); flush_dcache_range((uintptr_t)utrd, sizeof(utp_utrd_t));
flush_dcache_range((uintptr_t)utrd->header, UFS_DESC_SIZE); flush_dcache_range((uintptr_t)utrd->header, UFS_DESC_SIZE);
...@@ -511,6 +513,9 @@ static void ufs_query(uint8_t op, uint8_t idn, uint8_t index, uint8_t sel, ...@@ -511,6 +513,9 @@ static void ufs_query(uint8_t op, uint8_t idn, uint8_t index, uint8_t sel,
case QUERY_WRITE_ATTR: case QUERY_WRITE_ATTR:
assert(((buf & 3) == 0) && (size != 0)); assert(((buf & 3) == 0) && (size != 0));
break; break;
default:
/* Do nothing in default case */
break;
} }
get_utrd(&utrd); get_utrd(&utrd);
ufs_prepare_query(&utrd, op, idn, index, sel, buf, size); ufs_prepare_query(&utrd, op, idn, index, sel, buf, size);
...@@ -533,6 +538,9 @@ static void ufs_query(uint8_t op, uint8_t idn, uint8_t index, uint8_t sel, ...@@ -533,6 +538,9 @@ static void ufs_query(uint8_t op, uint8_t idn, uint8_t index, uint8_t sel,
(void *)(utrd.resp_upiu + sizeof(query_resp_upiu_t)), (void *)(utrd.resp_upiu + sizeof(query_resp_upiu_t)),
size); size);
break; break;
default:
/* Do nothing in default case */
break;
} }
(void)result; (void)result;
} }
......
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