aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/serial/serial_core.c
diff options
context:
space:
mode:
authorRussell King <rmk@dyn-67.arm.linux.org.uk>2005-06-29 04:42:38 -0400
committerRussell King <rmk+kernel@arm.linux.org.uk>2005-06-29 04:42:38 -0400
commitc5f4644e6c8ba21666128603e4e92544d3cd740d (patch)
tree1a8b4c730ca575d4b1118af174b070764803fb2c /drivers/serial/serial_core.c
parenta839688362e32f01608838516036697e30618b39 (diff)
[PATCH] Serial: Adjust serial locking
This patch changes the way serial ports are locked when getting modem status. This change is necessary because we will need to atomically read the modem status and take action depending on the CTS status. Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
Diffstat (limited to 'drivers/serial/serial_core.c')
-rw-r--r--drivers/serial/serial_core.c11
1 files changed, 10 insertions, 1 deletions
diff --git a/drivers/serial/serial_core.c b/drivers/serial/serial_core.c
index 36b1ae083fb..f5ce58d0514 100644
--- a/drivers/serial/serial_core.c
+++ b/drivers/serial/serial_core.c
@@ -828,7 +828,10 @@ static int uart_tiocmget(struct tty_struct *tty, struct file *file)
828 if ((!file || !tty_hung_up_p(file)) && 828 if ((!file || !tty_hung_up_p(file)) &&
829 !(tty->flags & (1 << TTY_IO_ERROR))) { 829 !(tty->flags & (1 << TTY_IO_ERROR))) {
830 result = port->mctrl; 830 result = port->mctrl;
831
832 spin_lock_irq(&port->lock);
831 result |= port->ops->get_mctrl(port); 833 result |= port->ops->get_mctrl(port);
834 spin_unlock_irq(&port->lock);
832 } 835 }
833 up(&state->sem); 836 up(&state->sem);
834 837
@@ -1369,6 +1372,7 @@ uart_block_til_ready(struct file *filp, struct uart_state *state)
1369 DECLARE_WAITQUEUE(wait, current); 1372 DECLARE_WAITQUEUE(wait, current);
1370 struct uart_info *info = state->info; 1373 struct uart_info *info = state->info;
1371 struct uart_port *port = state->port; 1374 struct uart_port *port = state->port;
1375 unsigned int mctrl;
1372 1376
1373 info->blocked_open++; 1377 info->blocked_open++;
1374 state->count--; 1378 state->count--;
@@ -1416,7 +1420,10 @@ uart_block_til_ready(struct file *filp, struct uart_state *state)
1416 * and wait for the carrier to indicate that the 1420 * and wait for the carrier to indicate that the
1417 * modem is ready for us. 1421 * modem is ready for us.
1418 */ 1422 */
1419 if (port->ops->get_mctrl(port) & TIOCM_CAR) 1423 spin_lock_irq(&port->lock);
1424 mctrl = port->ops->get_mctrl(port);
1425 spin_unlock_irq(&port->lock);
1426 if (mctrl & TIOCM_CAR)
1420 break; 1427 break;
1421 1428
1422 up(&state->sem); 1429 up(&state->sem);
@@ -1618,7 +1625,9 @@ static int uart_line_info(char *buf, struct uart_driver *drv, int i)
1618 1625
1619 if(capable(CAP_SYS_ADMIN)) 1626 if(capable(CAP_SYS_ADMIN))
1620 { 1627 {
1628 spin_lock_irq(&port->lock);
1621 status = port->ops->get_mctrl(port); 1629 status = port->ops->get_mctrl(port);
1630 spin_unlock_irq(&port->lock);
1622 1631
1623 ret += sprintf(buf + ret, " tx:%d rx:%d", 1632 ret += sprintf(buf + ret, " tx:%d rx:%d",
1624 port->icount.tx, port->icount.rx); 1633 port->icount.tx, port->icount.rx);