aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/usb/serial/ir-usb.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/usb/serial/ir-usb.c')
-rw-r--r--drivers/usb/serial/ir-usb.c16
1 files changed, 11 insertions, 5 deletions
diff --git a/drivers/usb/serial/ir-usb.c b/drivers/usb/serial/ir-usb.c
index 59f234df5f89..937b2fdd7171 100644
--- a/drivers/usb/serial/ir-usb.c
+++ b/drivers/usb/serial/ir-usb.c
@@ -341,10 +341,14 @@ static int ir_write (struct usb_serial_port *port, const unsigned char *buf, int
341 if (count == 0) 341 if (count == 0)
342 return 0; 342 return 0;
343 343
344 if (port->write_urb->status == -EINPROGRESS) { 344 spin_lock(&port->lock);
345 dbg ("%s - already writing", __FUNCTION__); 345 if (port->write_urb_busy) {
346 spin_unlock(&port->lock);
347 dbg("%s - already writing", __FUNCTION__);
346 return 0; 348 return 0;
347 } 349 }
350 port->write_urb_busy = 1;
351 spin_unlock(&port->lock);
348 352
349 transfer_buffer = port->write_urb->transfer_buffer; 353 transfer_buffer = port->write_urb->transfer_buffer;
350 transfer_size = min(count, port->bulk_out_size - 1); 354 transfer_size = min(count, port->bulk_out_size - 1);
@@ -374,9 +378,10 @@ static int ir_write (struct usb_serial_port *port, const unsigned char *buf, int
374 port->write_urb->transfer_flags = URB_ZERO_PACKET; 378 port->write_urb->transfer_flags = URB_ZERO_PACKET;
375 379
376 result = usb_submit_urb (port->write_urb, GFP_ATOMIC); 380 result = usb_submit_urb (port->write_urb, GFP_ATOMIC);
377 if (result) 381 if (result) {
382 port->write_urb_busy = 0;
378 dev_err(&port->dev, "%s - failed submitting write urb, error %d\n", __FUNCTION__, result); 383 dev_err(&port->dev, "%s - failed submitting write urb, error %d\n", __FUNCTION__, result);
379 else 384 } else
380 result = transfer_size; 385 result = transfer_size;
381 386
382 return result; 387 return result;
@@ -387,7 +392,8 @@ static void ir_write_bulk_callback (struct urb *urb, struct pt_regs *regs)
387 struct usb_serial_port *port = (struct usb_serial_port *)urb->context; 392 struct usb_serial_port *port = (struct usb_serial_port *)urb->context;
388 393
389 dbg("%s - port %d", __FUNCTION__, port->number); 394 dbg("%s - port %d", __FUNCTION__, port->number);
390 395
396 port->write_urb_busy = 0;
391 if (urb->status) { 397 if (urb->status) {
392 dbg("%s - nonzero write bulk status received: %d", __FUNCTION__, urb->status); 398 dbg("%s - nonzero write bulk status received: %d", __FUNCTION__, urb->status);
393 return; 399 return;