aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/usb/serial/generic.c
diff options
context:
space:
mode:
authorJohan Hovold <jhovold@gmail.com>2010-03-17 18:06:02 -0400
committerGreg Kroah-Hartman <gregkh@suse.de>2010-05-20 16:21:34 -0400
commit50a5f70cee11636908711abd339f5c5933375a7d (patch)
tree1145c5d38c20f9ad34df98f78b72fe0ce46314d8 /drivers/usb/serial/generic.c
parent1a1405e22563151de79fdc83aa5e5815d10f0291 (diff)
USB: serial: clean up generic write start busy test
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>
Diffstat (limited to 'drivers/usb/serial/generic.c')
-rw-r--r--drivers/usb/serial/generic.c15
1 files changed, 4 insertions, 11 deletions
diff --git a/drivers/usb/serial/generic.c b/drivers/usb/serial/generic.c
index 63b43308e160..9756b5c22d94 100644
--- a/drivers/usb/serial/generic.c
+++ b/drivers/usb/serial/generic.c
@@ -259,22 +259,15 @@ static int usb_serial_generic_write_start(struct usb_serial_port *port)
259 int result; 259 int result;
260 int count; 260 int count;
261 unsigned long flags; 261 unsigned long flags;
262 bool start_io;
263 262
264 /* Atomically determine whether we can and need to start a USB
265 * operation. */
266 spin_lock_irqsave(&port->lock, flags); 263 spin_lock_irqsave(&port->lock, flags);
267 if (port->write_urb_busy) 264 if (port->write_urb_busy || !kfifo_len(&port->write_fifo)) {
268 start_io = false; 265 spin_unlock_irqrestore(&port->lock, flags);
269 else { 266 return 0;
270 start_io = (kfifo_len(&port->write_fifo) != 0);
271 port->write_urb_busy = start_io;
272 } 267 }
268 port->write_urb_busy = 1;
273 spin_unlock_irqrestore(&port->lock, flags); 269 spin_unlock_irqrestore(&port->lock, flags);
274 270
275 if (!start_io)
276 return 0;
277
278 data = port->write_urb->transfer_buffer; 271 data = port->write_urb->transfer_buffer;
279 count = kfifo_out_locked(&port->write_fifo, data, port->bulk_out_size, &port->lock); 272 count = kfifo_out_locked(&port->write_fifo, data, port->bulk_out_size, &port->lock);
280 usb_serial_debug_data(debug, &port->dev, __func__, count, data); 273 usb_serial_debug_data(debug, &port->dev, __func__, count, data);