Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 82273
b: refs/heads/master
c: 9e3b1d8
h: refs/heads/master
i:
  82271: fc78c06
v: v3
  • Loading branch information
Oliver Neukum authored and Greg Kroah-Hartman committed Feb 1, 2008
1 parent 977072f commit 438dfea
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 10 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: 0b3f5fe673d4626ea91816ca9c486b43b39a2fd1
refs/heads/master: 9e3b1d8e3d5d135ac7be43f6710b7a67b569c292
25 changes: 16 additions & 9 deletions trunk/drivers/usb/serial/cypress_m8.c
Original file line number Diff line number Diff line change
Expand Up @@ -682,34 +682,40 @@ static void cypress_close(struct usb_serial_port *port, struct file * filp)
{
struct cypress_private *priv = usb_get_serial_port_data(port);
unsigned int c_cflag;
unsigned long flags;
int bps;
long timeout;
wait_queue_t wait;

dbg("%s - port %d", __FUNCTION__, port->number);

/* wait for data to drain from buffer */
spin_lock_irqsave(&priv->lock, flags);
spin_lock_irq(&priv->lock);
timeout = CYPRESS_CLOSING_WAIT;
init_waitqueue_entry(&wait, current);
add_wait_queue(&port->tty->write_wait, &wait);
for (;;) {
set_current_state(TASK_INTERRUPTIBLE);
if (cypress_buf_data_avail(priv->buf) == 0
|| timeout == 0 || signal_pending(current)
|| !usb_get_intfdata(port->serial->interface))
/* without mutex, allowed due to harmless failure mode */
|| port->serial->disconnected)
break;
spin_unlock_irqrestore(&priv->lock, flags);
spin_unlock_irq(&priv->lock);
timeout = schedule_timeout(timeout);
spin_lock_irqsave(&priv->lock, flags);
spin_lock_irq(&priv->lock);
}
set_current_state(TASK_RUNNING);
remove_wait_queue(&port->tty->write_wait, &wait);
/* clear out any remaining data in the buffer */
cypress_buf_clear(priv->buf);
spin_unlock_irqrestore(&priv->lock, flags);

spin_unlock_irq(&priv->lock);

/* writing is potentially harmful, lock must be taken */
mutex_lock(&port->serial->disc_mutex);
if (port->serial->disconnected) {
mutex_unlock(&port->serial->disc_mutex);
return;
}
/* wait for characters to drain from device */
bps = tty_get_baud_rate(port->tty);
if (bps > 1200)
Expand All @@ -727,17 +733,18 @@ static void cypress_close(struct usb_serial_port *port, struct file * filp)
if (c_cflag & HUPCL) {
/* drop dtr and rts */
priv = usb_get_serial_port_data(port);
spin_lock_irqsave(&priv->lock, flags);
spin_lock_irq(&priv->lock);
priv->line_control = 0;
priv->cmd_ctrl = 1;
spin_unlock_irqrestore(&priv->lock, flags);
spin_unlock_irq(&priv->lock);
cypress_write(port, NULL, 0);
}
}

if (stats)
dev_info (&port->dev, "Statistics: %d Bytes In | %d Bytes Out | %d Commands Issued\n",
priv->bytes_in, priv->bytes_out, priv->cmd_count);
mutex_unlock(&port->serial->disc_mutex);
} /* cypress_close */


Expand Down

0 comments on commit 438dfea

Please sign in to comment.