[PATCH v2 2/3] serial: 8250_exar: Refactor exar_shutdown()

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



First of all, boolean variable should be assigned with boolean values.
Second, it's not needed at all in this case.

Drop unneeded boolean variable and use 'break' statement instead.

While here, change iterations to be more visible by moving the number of them
to the variable definition block.

Signed-off-by: Andy Shevchenko <andriy.shevchenko@xxxxxxxxxxxxxxx>
---
v2: Check kernel buffer first as in the original conditional (Robert)
 drivers/tty/serial/8250/8250_exar.c | 11 +++++------
 1 file changed, 5 insertions(+), 6 deletions(-)

diff --git a/drivers/tty/serial/8250/8250_exar.c b/drivers/tty/serial/8250/8250_exar.c
index 873aa6b0c2f3..8f9baae92831 100644
--- a/drivers/tty/serial/8250/8250_exar.c
+++ b/drivers/tty/serial/8250/8250_exar.c
@@ -169,19 +169,18 @@ static void xr17v35x_set_divisor(struct uart_port *p, unsigned int baud,
 static void exar_shutdown(struct uart_port *port)
 {
 	unsigned char lsr;
-	bool tx_complete = 0;
 	struct uart_8250_port *up = up_to_u8250p(port);
 	struct circ_buf *xmit = &port->state->xmit;
-	int i = 0;
+	unsigned int retries = 1000;
 
 	do {
+		if (uart_circ_empty(xmit))
+			break;
 		lsr = serial_in(up, UART_LSR);
 		if (lsr & (UART_LSR_TEMT | UART_LSR_THRE))
-			tx_complete = 1;
-		else
-			tx_complete = 0;
+			break;
 		msleep(1);
-	} while (!uart_circ_empty(xmit) && !tx_complete && i++ < 1000);
+	} while (--retries);
 
 	serial8250_do_shutdown(port);
 }
-- 
2.20.1




[Index of Archives]     [Kernel Newbies]     [Security]     [Netfilter]     [Bugtraq]     [Linux PPP]     [Linux FS]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Samba]     [Video 4 Linux]     [Linmodem]     [Device Mapper]     [Linux Kernel for ARM]

  Powered by Linux