driver: uart: ns16550: Simplify drv_cmd function

There is only one possible command, so just use if instead of switch
to avoid several MISRA-C violations and also avoid set dev_data wrongly
unused when UART_NS16550_DLF_ENABLED is defined.

Signed-off-by: Flavio Ceolin <flavio.ceolin@intel.com>
This commit is contained in:
Flavio Ceolin 2020-01-22 14:15:18 -08:00 committed by Anas Nashif
commit 2abfccb352

View file

@ -793,20 +793,14 @@ static int uart_ns16550_line_ctrl_set(struct device *dev,
*/
static int uart_ns16550_drv_cmd(struct device *dev, u32_t cmd, u32_t p)
{
struct uart_ns16550_dev_data_t * const dev_data = DEV_DATA(dev);
ARG_UNUSED(dev_data);
switch (cmd) {
#ifdef UART_NS16550_DLF_ENABLED
case CMD_SET_DLF:
if (cmd == CMD_SET_DLF) {
struct uart_ns16550_dev_data_t * const dev_data = DEV_DATA(dev);
dev_data->dlf = p;
OUTBYTE(DLF(dev), dev_data->dlf);
return 0;
#endif
}
#endif
return -ENOTSUP;
}