diff --git a/drivers/serial/serial.c b/drivers/serial/serial.c index ea64a7c07ed..b33d1fa80a2 100644 --- a/drivers/serial/serial.c +++ b/drivers/serial/serial.c @@ -900,17 +900,13 @@ static ssize_t uart_read(FAR struct file *filep, else { -#ifdef CONFIG_SERIAL_RXDMA - /* Disable all interrupts and test again... - * uart_disablerxint() is insufficient for the check in DMA mode. - */ + /* Disable all interrupts and test again... */ flags = enter_critical_section(); -#else + /* Disable Rx interrupts and test again... */ uart_disablerxint(dev); -#endif /* If the Rx ring buffer still empty? Bytes may have been added * between the last time that we checked and when we disabled @@ -927,14 +923,12 @@ static ssize_t uart_read(FAR struct file *filep, /* Notify DMA that there is free space in the RX buffer */ uart_dmarxfree(dev); -#else +#endif /* Wait with the RX interrupt re-enabled. All interrupts are * disabled briefly to assure that the following operations * are atomic. */ - flags = enter_critical_section(); - /* Re-enable UART Rx interrupts */ uart_enablerxint(dev); @@ -952,7 +946,6 @@ static ssize_t uart_read(FAR struct file *filep, leave_critical_section(flags); continue; } -#endif #ifdef CONFIG_SERIAL_REMOVABLE /* Check again if the removable device is still connected @@ -1020,11 +1013,9 @@ static ssize_t uart_read(FAR struct file *filep, * the loop. */ -#ifdef CONFIG_SERIAL_RXDMA leave_critical_section(flags); -#else + uart_enablerxint(dev); -#endif } } } @@ -1037,11 +1028,9 @@ static ssize_t uart_read(FAR struct file *filep, leave_critical_section(flags); #endif -#ifndef CONFIG_SERIAL_RXDMA /* RX interrupt could be disabled by RX buffer overflow. Enable it now. */ uart_enablerxint(dev); -#endif #ifdef CONFIG_SERIAL_IFLOWCONTROL #ifdef CONFIG_SERIAL_IFLOWCONTROL_WATERMARKS