aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/usb/serial/cyberjack.c
diff options
context:
space:
mode:
authorGreg Kroah-Hartman <gregkh@suse.de>2005-04-23 15:49:16 -0400
committerGreg Kroah-Hartman <gregkh@suse.de>2005-06-27 17:43:47 -0400
commit507ca9bc0476662f3463888d583864834eab1e11 (patch)
tree421a373de235fcb4cb46a4723a1e9f00a71f709a /drivers/usb/serial/cyberjack.c
parentf4df0e334a9fc731689e8ba4f42a0d72a7491348 (diff)
[PATCH] USB: add ability for usb-serial drivers to determine if their write urb is currently being used.
This removes a lot of racy and buggy code by trying to check the status of the urb. Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
Diffstat (limited to 'drivers/usb/serial/cyberjack.c')
-rw-r--r--drivers/usb/serial/cyberjack.c19
1 files changed, 10 insertions, 9 deletions
diff --git a/drivers/usb/serial/cyberjack.c b/drivers/usb/serial/cyberjack.c
index 46a204cd40e1..b5b431067b08 100644
--- a/drivers/usb/serial/cyberjack.c
+++ b/drivers/usb/serial/cyberjack.c
@@ -213,10 +213,14 @@ static int cyberjack_write (struct usb_serial_port *port, const unsigned char *b
213 return (0); 213 return (0);
214 } 214 }
215 215
216 if (port->write_urb->status == -EINPROGRESS) { 216 spin_lock(&port->lock);
217 if (port->write_urb_busy) {
218 spin_unlock(&port->lock);
217 dbg("%s - already writing", __FUNCTION__); 219 dbg("%s - already writing", __FUNCTION__);
218 return (0); 220 return 0;
219 } 221 }
222 port->write_urb_busy = 1;
223 spin_unlock(&port->lock);
220 224
221 spin_lock_irqsave(&priv->lock, flags); 225 spin_lock_irqsave(&priv->lock, flags);
222 226
@@ -224,6 +228,7 @@ static int cyberjack_write (struct usb_serial_port *port, const unsigned char *b
224 /* To much data for buffer. Reset buffer. */ 228 /* To much data for buffer. Reset buffer. */
225 priv->wrfilled=0; 229 priv->wrfilled=0;
226 spin_unlock_irqrestore(&priv->lock, flags); 230 spin_unlock_irqrestore(&priv->lock, flags);
231 port->write_urb_busy = 0;
227 return (0); 232 return (0);
228 } 233 }
229 234
@@ -268,6 +273,7 @@ static int cyberjack_write (struct usb_serial_port *port, const unsigned char *b
268 priv->wrfilled=0; 273 priv->wrfilled=0;
269 priv->wrsent=0; 274 priv->wrsent=0;
270 spin_unlock_irqrestore(&priv->lock, flags); 275 spin_unlock_irqrestore(&priv->lock, flags);
276 port->write_urb_busy = 0;
271 return 0; 277 return 0;
272 } 278 }
273 279
@@ -412,7 +418,8 @@ static void cyberjack_write_bulk_callback (struct urb *urb, struct pt_regs *regs
412 struct cyberjack_private *priv = usb_get_serial_port_data(port); 418 struct cyberjack_private *priv = usb_get_serial_port_data(port);
413 419
414 dbg("%s - port %d", __FUNCTION__, port->number); 420 dbg("%s - port %d", __FUNCTION__, port->number);
415 421
422 port->write_urb_busy = 0;
416 if (urb->status) { 423 if (urb->status) {
417 dbg("%s - nonzero write bulk status received: %d", __FUNCTION__, urb->status); 424 dbg("%s - nonzero write bulk status received: %d", __FUNCTION__, urb->status);
418 return; 425 return;
@@ -424,12 +431,6 @@ static void cyberjack_write_bulk_callback (struct urb *urb, struct pt_regs *regs
424 if( priv->wrfilled ) { 431 if( priv->wrfilled ) {
425 int length, blksize, result; 432 int length, blksize, result;
426 433
427 if (port->write_urb->status == -EINPROGRESS) {
428 dbg("%s - already writing", __FUNCTION__);
429 spin_unlock(&priv->lock);
430 return;
431 }
432
433 dbg("%s - transmitting data (frame n)", __FUNCTION__); 434 dbg("%s - transmitting data (frame n)", __FUNCTION__);
434 435
435 length = ((priv->wrfilled - priv->wrsent) > port->bulk_out_size) ? 436 length = ((priv->wrfilled - priv->wrsent) > port->bulk_out_size) ?