[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>
This commit is contained in:
@@ -213,10 +213,14 @@ static int cyberjack_write (struct usb_serial_port *port, const unsigned char *b
|
||||
return (0);
|
||||
}
|
||||
|
||||
if (port->write_urb->status == -EINPROGRESS) {
|
||||
spin_lock(&port->lock);
|
||||
if (port->write_urb_busy) {
|
||||
spin_unlock(&port->lock);
|
||||
dbg("%s - already writing", __FUNCTION__);
|
||||
return (0);
|
||||
return 0;
|
||||
}
|
||||
port->write_urb_busy = 1;
|
||||
spin_unlock(&port->lock);
|
||||
|
||||
spin_lock_irqsave(&priv->lock, flags);
|
||||
|
||||
@@ -224,6 +228,7 @@ static int cyberjack_write (struct usb_serial_port *port, const unsigned char *b
|
||||
/* To much data for buffer. Reset buffer. */
|
||||
priv->wrfilled=0;
|
||||
spin_unlock_irqrestore(&priv->lock, flags);
|
||||
port->write_urb_busy = 0;
|
||||
return (0);
|
||||
}
|
||||
|
||||
@@ -268,6 +273,7 @@ static int cyberjack_write (struct usb_serial_port *port, const unsigned char *b
|
||||
priv->wrfilled=0;
|
||||
priv->wrsent=0;
|
||||
spin_unlock_irqrestore(&priv->lock, flags);
|
||||
port->write_urb_busy = 0;
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -412,7 +418,8 @@ static void cyberjack_write_bulk_callback (struct urb *urb, struct pt_regs *regs
|
||||
struct cyberjack_private *priv = usb_get_serial_port_data(port);
|
||||
|
||||
dbg("%s - port %d", __FUNCTION__, port->number);
|
||||
|
||||
|
||||
port->write_urb_busy = 0;
|
||||
if (urb->status) {
|
||||
dbg("%s - nonzero write bulk status received: %d", __FUNCTION__, urb->status);
|
||||
return;
|
||||
@@ -424,12 +431,6 @@ static void cyberjack_write_bulk_callback (struct urb *urb, struct pt_regs *regs
|
||||
if( priv->wrfilled ) {
|
||||
int length, blksize, result;
|
||||
|
||||
if (port->write_urb->status == -EINPROGRESS) {
|
||||
dbg("%s - already writing", __FUNCTION__);
|
||||
spin_unlock(&priv->lock);
|
||||
return;
|
||||
}
|
||||
|
||||
dbg("%s - transmitting data (frame n)", __FUNCTION__);
|
||||
|
||||
length = ((priv->wrfilled - priv->wrsent) > port->bulk_out_size) ?
|
||||
|
Reference in New Issue
Block a user