aboutsummaryrefslogtreecommitdiff
path: root/drivers/char/isicom.c
diff options
context:
space:
mode:
authorAlan Cox <alan@redhat.com>2009-01-02 13:45:26 +0000
committerLinus Torvalds <torvalds@linux-foundation.org>2009-01-02 10:19:38 -0800
commit3e61696bdc2103107674b06d0daf30b76193e922 (patch)
treecc4f2b7b7b0ce2162613bb9d3cf819f6bbfd3628 /drivers/char/isicom.c
parent5d951fb458f847e5485b5251597fbf326000bb3b (diff)
isicom: redo locking to use tty port locks
This helps set the basis for moving block_til_ready into common code. We also introduce a tty_port_hangup helper as this will also be generally needed. Signed-off-by: Alan Cox <alan@redhat.com> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'drivers/char/isicom.c')
-rw-r--r--drivers/char/isicom.c35
1 files changed, 15 insertions, 20 deletions
diff --git a/drivers/char/isicom.c b/drivers/char/isicom.c
index a449449e301..db53db91ae4 100644
--- a/drivers/char/isicom.c
+++ b/drivers/char/isicom.c
@@ -841,7 +841,6 @@ static int isicom_carrier_raised(struct tty_port *port)
static int block_til_ready(struct tty_struct *tty, struct file *filp,
struct isi_port *ip)
{
- struct isi_board *card = ip->card;
struct tty_port *port = &ip->port;
int do_clocal = 0, retval;
unsigned long flags;
@@ -876,11 +875,11 @@ static int block_til_ready(struct tty_struct *tty, struct file *filp,
retval = 0;
add_wait_queue(&port->open_wait, &wait);
- spin_lock_irqsave(&card->card_lock, flags);
+ spin_lock_irqsave(&port->lock, flags);
if (!tty_hung_up_p(filp))
port->count--;
port->blocked_open++;
- spin_unlock_irqrestore(&card->card_lock, flags);
+ spin_unlock_irqrestore(&port->lock, flags);
while (1) {
tty_port_raise_dtr_rts(port);
@@ -905,14 +904,13 @@ static int block_til_ready(struct tty_struct *tty, struct file *filp,
}
set_current_state(TASK_RUNNING);
remove_wait_queue(&port->open_wait, &wait);
- spin_lock_irqsave(&card->card_lock, flags);
+ spin_lock_irqsave(&port->lock, flags);
if (!tty_hung_up_p(filp))
port->count++;
port->blocked_open--;
- spin_unlock_irqrestore(&card->card_lock, flags);
- if (retval)
- return retval;
- port->flags |= ASYNC_NORMAL_ACTIVE;
+ if (retval == 0)
+ port->flags |= ASYNC_NORMAL_ACTIVE;
+ spin_unlock_irqrestore(&port->lock, flags);
return 0;
}
@@ -1034,9 +1032,9 @@ static void isicom_close(struct tty_struct *tty, struct file *filp)
pr_dbg("Close start!!!.\n");
- spin_lock_irqsave(&card->card_lock, flags);
+ spin_lock_irqsave(&port->port.lock, flags);
if (tty_hung_up_p(filp)) {
- spin_unlock_irqrestore(&card->card_lock, flags);
+ spin_unlock_irqrestore(&port->port.lock, flags);
return;
}
@@ -1054,12 +1052,12 @@ static void isicom_close(struct tty_struct *tty, struct file *filp)
}
if (port->port.count) {
- spin_unlock_irqrestore(&card->card_lock, flags);
+ spin_unlock_irqrestore(&port->port.lock, flags);
return;
}
port->port.flags |= ASYNC_CLOSING;
tty->closing = 1;
- spin_unlock_irqrestore(&card->card_lock, flags);
+ spin_unlock_irqrestore(&port->port.lock, flags);
if (port->port.closing_wait != ASYNC_CLOSING_WAIT_NONE)
tty_wait_until_sent(tty, port->port.closing_wait);
@@ -1076,22 +1074,22 @@ static void isicom_close(struct tty_struct *tty, struct file *filp)
isicom_flush_buffer(tty);
tty_ldisc_flush(tty);
- spin_lock_irqsave(&card->card_lock, flags);
+ spin_lock_irqsave(&port->port.lock, flags);
tty->closing = 0;
if (port->port.blocked_open) {
- spin_unlock_irqrestore(&card->card_lock, flags);
+ spin_unlock_irqrestore(&port->port.lock, flags);
if (port->port.close_delay) {
pr_dbg("scheduling until time out.\n");
msleep_interruptible(
jiffies_to_msecs(port->port.close_delay));
}
- spin_lock_irqsave(&card->card_lock, flags);
+ spin_lock_irqsave(&port->port.lock, flags);
wake_up_interruptible(&port->port.open_wait);
}
port->port.flags &= ~(ASYNC_NORMAL_ACTIVE | ASYNC_CLOSING);
wake_up_interruptible(&port->port.close_wait);
- spin_unlock_irqrestore(&card->card_lock, flags);
+ spin_unlock_irqrestore(&port->port.lock, flags);
}
/* write et all */
@@ -1430,10 +1428,7 @@ static void isicom_hangup(struct tty_struct *tty)
isicom_shutdown_port(port);
spin_unlock_irqrestore(&port->card->card_lock, flags);
- port->port.count = 0;
- port->port.flags &= ~ASYNC_NORMAL_ACTIVE;
- tty_port_tty_set(&port->port, NULL);
- wake_up_interruptible(&port->port.open_wait);
+ tty_port_hangup(&port->port);
}