Skip to content

Commit

Permalink
USB: serial: clean up generic write start busy test
Browse files Browse the repository at this point in the history
Submit write urb if it is not already in use and we have buffered data.

Signed-off-by: Johan Hovold <jhovold@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
  • Loading branch information
Johan Hovold authored and Greg Kroah-Hartman committed May 20, 2010
1 parent 1a1405e commit 50a5f70
Showing 1 changed file with 4 additions and 11 deletions.
15 changes: 4 additions & 11 deletions drivers/usb/serial/generic.c
Original file line number Diff line number Diff line change
Expand Up @@ -259,22 +259,15 @@ static int usb_serial_generic_write_start(struct usb_serial_port *port)
int result;
int count;
unsigned long flags;
bool start_io;

/* Atomically determine whether we can and need to start a USB
* operation. */
spin_lock_irqsave(&port->lock, flags);
if (port->write_urb_busy)
start_io = false;
else {
start_io = (kfifo_len(&port->write_fifo) != 0);
port->write_urb_busy = start_io;
if (port->write_urb_busy || !kfifo_len(&port->write_fifo)) {
spin_unlock_irqrestore(&port->lock, flags);
return 0;
}
port->write_urb_busy = 1;
spin_unlock_irqrestore(&port->lock, flags);

if (!start_io)
return 0;

data = port->write_urb->transfer_buffer;
count = kfifo_out_locked(&port->write_fifo, data, port->bulk_out_size, &port->lock);
usb_serial_debug_data(debug, &port->dev, __func__, count, data);
Expand Down

0 comments on commit 50a5f70

Please sign in to comment.