[PATCH 3/5] serial-uartlite: Spinlock inside the loop.

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

 



Better to hold the spinlock as short as possible.

Signed-off-by: Maarten Brock <m.brock@xxxxxxxxxxxxx>
---
 drivers/tty/serial/uartlite.c | 10 ++++------
 1 file changed, 4 insertions(+), 6 deletions(-)

diff --git a/drivers/tty/serial/uartlite.c b/drivers/tty/serial/uartlite.c
index f4ad0db..4fd81ad 100644
--- a/drivers/tty/serial/uartlite.c
+++ b/drivers/tty/serial/uartlite.c
@@ -147,7 +147,6 @@ static int ulite_receive(struct uart_port *port, int stat)
 	if (stat & ULITE_STATUS_PARITY)
 		flag = TTY_PARITY;
 
-
 	stat &= ~port->ignore_status_mask;
 
 	if (stat & ULITE_STATUS_RXVALID)
@@ -193,19 +192,18 @@ static int ulite_transmit(struct uart_port *port, int stat)
 static irqreturn_t ulite_isr(int irq, void *dev_id)
 {
 	struct uart_port *port = dev_id;
-	int busy, n = 0;
+	int stat, busy, n = 0;
 	unsigned long flags;
 
-	spin_lock_irqsave(&port->lock, flags);
 	do {
-		int stat = uart_in32(ULITE_STATUS, port);
+		spin_lock_irqsave(&port->lock, flags);
+		stat = uart_in32(ULITE_STATUS, port);
 		busy  = ulite_receive(port, stat);
 		busy |= ulite_transmit(port, stat);
+		spin_unlock_irqrestore(&port->lock, flags);
 		n++;
 	} while (busy);
 
-	spin_unlock_irqrestore(&port->lock, flags);
-
 	/* work done? */
 	if (n > 1) {
 		tty_flip_buffer_push(&port->state->port);
-- 
1.8.3.1

--
To unsubscribe from this list: send the line "unsubscribe linux-serial" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html



[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