Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 125057
b: refs/heads/master
c: 36c621d
h: refs/heads/master
i:
  125055: 776edea
v: v3
  • Loading branch information
Alan Cox authored and Linus Torvalds committed Jan 2, 2009
1 parent 6f49bd5 commit dc3fa0a
Show file tree
Hide file tree
Showing 8 changed files with 116 additions and 236 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 3b6826b250633361f08a6427a4ac0035e5d88c72
refs/heads/master: 36c621d82b956ff6ff72273f848af53e6c581aba
79 changes: 2 additions & 77 deletions trunk/drivers/char/isicom.c
Original file line number Diff line number Diff line change
Expand Up @@ -838,82 +838,6 @@ static int isicom_carrier_raised(struct tty_port *port)
return (ip->status & ISI_DCD)?1 : 0;
}

static int block_til_ready(struct tty_struct *tty, struct file *filp,
struct isi_port *ip)
{
struct tty_port *port = &ip->port;
int do_clocal = 0, retval;
unsigned long flags;
DECLARE_WAITQUEUE(wait, current);
int cd;

/* block if port is in the process of being closed */

if (tty_hung_up_p(filp) || port->flags & ASYNC_CLOSING) {
pr_dbg("block_til_ready: close in progress.\n");
interruptible_sleep_on(&port->close_wait);
if (port->flags & ASYNC_HUP_NOTIFY)
return -EAGAIN;
else
return -ERESTARTSYS;
}

/* if non-blocking mode is set ... */

if ((filp->f_flags & O_NONBLOCK) ||
(tty->flags & (1 << TTY_IO_ERROR))) {
pr_dbg("block_til_ready: non-block mode.\n");
port->flags |= ASYNC_NORMAL_ACTIVE;
return 0;
}

if (C_CLOCAL(tty))
do_clocal = 1;

/* block waiting for DCD to be asserted, and while
callout dev is busy */
retval = 0;
add_wait_queue(&port->open_wait, &wait);

spin_lock_irqsave(&port->lock, flags);
if (!tty_hung_up_p(filp))
port->count--;
port->blocked_open++;
spin_unlock_irqrestore(&port->lock, flags);

while (1) {
tty_port_raise_dtr_rts(port);

set_current_state(TASK_INTERRUPTIBLE);
if (tty_hung_up_p(filp) || !(port->flags & ASYNC_INITIALIZED)) {
if (port->flags & ASYNC_HUP_NOTIFY)
retval = -EAGAIN;
else
retval = -ERESTARTSYS;
break;
}
cd = tty_port_carrier_raised(port);
if (!(port->flags & ASYNC_CLOSING) &&
(do_clocal || cd))
break;
if (signal_pending(current)) {
retval = -ERESTARTSYS;
break;
}
schedule();
}
set_current_state(TASK_RUNNING);
remove_wait_queue(&port->open_wait, &wait);
spin_lock_irqsave(&port->lock, flags);
if (!tty_hung_up_p(filp))
port->count++;
port->blocked_open--;
if (retval == 0)
port->flags |= ASYNC_NORMAL_ACTIVE;
spin_unlock_irqrestore(&port->lock, flags);
return 0;
}

static int isicom_open(struct tty_struct *tty, struct file *filp)
{
struct isi_port *port;
Expand All @@ -940,12 +864,13 @@ static int isicom_open(struct tty_struct *tty, struct file *filp)

isicom_setup_board(card);

/* FIXME: locking on port.count etc */
port->port.count++;
tty->driver_data = port;
tty_port_tty_set(&port->port, tty);
error = isicom_setup_port(tty);
if (error == 0)
error = block_til_ready(tty, filp, port);
error = tty_port_block_til_ready(&port->port, tty, filp);
return error;
}

Expand Down
71 changes: 1 addition & 70 deletions trunk/drivers/char/mxser.c
Original file line number Diff line number Diff line change
Expand Up @@ -558,75 +558,6 @@ static void mxser_raise_dtr_rts(struct tty_port *port)
spin_unlock_irqrestore(&mp->slock, flags);
}

static int mxser_block_til_ready(struct tty_struct *tty, struct file *filp,
struct mxser_port *mp)
{
DECLARE_WAITQUEUE(wait, current);
int retval;
int do_clocal = 0;
unsigned long flags;
int cd;
struct tty_port *port = &mp->port;

/*
* If non-blocking mode is set, or the port is not enabled,
* then make the check up front and then exit.
*/
if ((filp->f_flags & O_NONBLOCK) ||
test_bit(TTY_IO_ERROR, &tty->flags)) {
port->flags |= ASYNC_NORMAL_ACTIVE;
return 0;
}

if (tty->termios->c_cflag & CLOCAL)
do_clocal = 1;

/*
* Block waiting for the carrier detect and the line to become
* free (i.e., not in use by the callout). While we are in
* this loop, port->count is dropped by one, so that
* mxser_close() knows when to free things. We restore it upon
* exit, either normal or abnormal.
*/
retval = 0;
add_wait_queue(&port->open_wait, &wait);

spin_lock_irqsave(&port->lock, flags);
if (!tty_hung_up_p(filp))
port->count--;
port->blocked_open++;
spin_unlock_irqrestore(&port->lock, flags);
while (1) {
tty_port_raise_dtr_rts(port);
set_current_state(TASK_INTERRUPTIBLE);
if (tty_hung_up_p(filp) || !(port->flags & ASYNC_INITIALIZED)) {
if (port->flags & ASYNC_HUP_NOTIFY)
retval = -EAGAIN;
else
retval = -ERESTARTSYS;
break;
}
cd = tty_port_carrier_raised(port);
if (!(port->flags & ASYNC_CLOSING) && (do_clocal || cd))
break;
if (signal_pending(current)) {
retval = -ERESTARTSYS;
break;
}
schedule();
}
set_current_state(TASK_RUNNING);
remove_wait_queue(&port->open_wait, &wait);
spin_lock_irqsave(&port->lock, flags);
if (!tty_hung_up_p(filp))
port->count++;
port->blocked_open--;
if (retval == 0)
port->flags |= ASYNC_NORMAL_ACTIVE;
spin_unlock_irqrestore(&port->lock, flags);
return 0;
}

static int mxser_set_baud(struct tty_struct *tty, long newspd)
{
struct mxser_port *info = tty->driver_data;
Expand Down Expand Up @@ -1110,7 +1041,7 @@ static int mxser_open(struct tty_struct *tty, struct file *filp)
if (retval)
return retval;

retval = mxser_block_til_ready(tty, filp, info);
retval = tty_port_block_til_ready(&info->port, tty, filp);
if (retval)
return retval;

Expand Down
86 changes: 1 addition & 85 deletions trunk/drivers/char/riscom8.c
Original file line number Diff line number Diff line change
Expand Up @@ -874,90 +874,6 @@ static int carrier_raised(struct tty_port *port)
return CD;
}

static int block_til_ready(struct tty_struct *tty, struct file *filp,
struct riscom_port *rp)
{
DECLARE_WAITQUEUE(wait, current);
int retval;
int do_clocal = 0;
int CD;
unsigned long flags;
struct tty_port *port = &rp->port;

/*
* If the device is in the middle of being closed, then block
* until it's done, and then try again.
*/
if (tty_hung_up_p(filp) || port->flags & ASYNC_CLOSING) {
interruptible_sleep_on(&port->close_wait);
if (port->flags & ASYNC_HUP_NOTIFY)
return -EAGAIN;
else
return -ERESTARTSYS;
}

/*
* If non-blocking mode is set, or the port is not enabled,
* then make the check up front and then exit.
*/
if ((filp->f_flags & O_NONBLOCK) ||
(tty->flags & (1 << TTY_IO_ERROR))) {
port->flags |= ASYNC_NORMAL_ACTIVE;
return 0;
}

if (C_CLOCAL(tty))
do_clocal = 1;

/*
* Block waiting for the carrier detect and the line to become
* free (i.e., not in use by the callout). While we are in
* this loop, info->count is dropped by one, so that
* rs_close() knows when to free things. We restore it upon
* exit, either normal or abnormal.
*/
retval = 0;
add_wait_queue(&port->open_wait, &wait);

spin_lock_irqsave(&port->lock, flags);
if (!tty_hung_up_p(filp))
port->count--;
port->blocked_open++;
spin_unlock_irqrestore(&port->lock, flags);

while (1) {

CD = tty_port_carrier_raised(port);
set_current_state(TASK_INTERRUPTIBLE);
if (tty_hung_up_p(filp) ||
!(port->flags & ASYNC_INITIALIZED)) {
if (port->flags & ASYNC_HUP_NOTIFY)
retval = -EAGAIN;
else
retval = -ERESTARTSYS;
break;
}
if (!(port->flags & ASYNC_CLOSING) &&
(do_clocal || CD))
break;
if (signal_pending(current)) {
retval = -ERESTARTSYS;
break;
}
schedule();
}
__set_current_state(TASK_RUNNING);
remove_wait_queue(&port->open_wait, &wait);
spin_lock_irqsave(&port->lock, flags);
if (!tty_hung_up_p(filp))
port->count++;
port->blocked_open--;
if (retval == 0)
port->flags |= ASYNC_NORMAL_ACTIVE;
spin_unlock_irqrestore(&port->lock, flags);
return 0;
}

static int rc_open(struct tty_struct *tty, struct file *filp)
{
int board;
Expand All @@ -984,7 +900,7 @@ static int rc_open(struct tty_struct *tty, struct file *filp)

error = rc_setup_port(bp, port);
if (error == 0)
error = block_til_ready(tty, filp, port);
error = tty_port_block_til_ready(&port->port, tty, filp);
return error;
}

Expand Down
1 change: 1 addition & 0 deletions trunk/drivers/char/synclink.c
Original file line number Diff line number Diff line change
Expand Up @@ -3401,6 +3401,7 @@ static int block_til_ready(struct tty_struct *tty, struct file * filp,
set_current_state(TASK_RUNNING);
remove_wait_queue(&port->open_wait, &wait);

/* FIXME: Racy on hangup during close wait */
if (extra_count)
port->count++;
port->blocked_open--;
Expand Down
Loading

0 comments on commit dc3fa0a

Please sign in to comment.