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)
*/
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 */
......
......@@ -459,6 +459,7 @@ void gicv2_set_interrupt_type(unsigned int id, unsigned int type)
break;
default:
assert(0);
break;
}
spin_unlock(&gic_lock);
}
......
......@@ -1004,6 +1004,7 @@ void gicv3_set_interrupt_type(unsigned int id, unsigned int proc_num,
break;
default:
assert(0);
break;
}
if (id < MIN_SPI_ID) {
......
......@@ -321,6 +321,7 @@ static int dw_set_ios(int clk, int width)
break;
default:
assert(0);
break;
}
dw_set_clk(clk);
return 0;
......
......@@ -271,6 +271,7 @@ static int ufs_prepare_cmd(utp_utrd_t *utrd, uint8_t op, uint8_t lun,
break;
default:
assert(0);
break;
}
if (hd->dd == DD_IN)
flush_dcache_range(buf, length);
......@@ -359,6 +360,7 @@ static int ufs_prepare_query(utp_utrd_t *utrd, uint8_t op, uint8_t idn,
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 @@ static void ufs_query(uint8_t op, uint8_t idn, uint8_t index, uint8_t sel,
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 @@ 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)),
size);
break;
default:
/* Do nothing in default case */
break;
}
(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