if (port->write_urb->status == -EINPROGRESS) { 
spin_lock(&port->lock); if (port->write_urb_busy) { spin_unlock(&port->lock); 
static int cyberjack_write (struct usb_serial_port *port, const unsigned char *buf, int count){	struct usb_serial *serial = port->serial;	struct cyberjack_private *priv = usb_get_serial_port_data(port);	unsigned long flags;	int result;	int wrexpected;	dbg("%s - port %d", __FUNCTION__, port->number);	if (count == 0) {		dbg("%s - write request of 0 bytes", __FUNCTION__);		return (0);	}	if (port->write_urb->status == -EINPROGRESS) {		dbg("%s - already writing", __FUNCTION__);		return (0);	}	spin_lock_irqsave(&priv->lock, flags);	if( (count+priv->wrfilled)>sizeof(priv->wrbuf) ) {		/* To much data for buffer. Reset buffer. */		priv->wrfilled=0;		spin_unlock_irqrestore(&priv->lock, flags);		return (0);	}	/* Copy data */	memcpy (priv->wrbuf+priv->wrfilled, buf, count);	usb_serial_debug_data(debug, &port->dev, __FUNCTION__, count,		priv->wrbuf+priv->wrfilled);	priv->wrfilled += count;	if( priv->wrfilled >= 3 ) {		wrexpected = ((int)priv->wrbuf[2]<<8)+priv->wrbuf[1]+3;		dbg("%s - expected data: %d", __FUNCTION__, wrexpected);	} else {		wrexpected = sizeof(priv->wrbuf);	}	if( priv->wrfilled >= wrexpected ) {		/* We have enough data to begin transmission */		int length;		dbg("%s - transmitting data (frame 1)", __FUNCTION__);		length = (wrexpected > port->bulk_out_size) ? port->bulk_out_size : wrexpected;		memcpy (port->write_urb->transfer_buffer, priv->wrbuf, length );		priv->wrsent=length;		/* set up our urb */		usb_fill_bulk_urb(port->write_urb, serial->dev, 			      usb_sndbulkpipe(serial->dev, port->bulk_out_endpointAddress),			      port->write_urb->transfer_buffer, length,			      ((serial->type->write_bulk_callback) ? 			       serial->type->write_bulk_callback : 			       cyberjack_write_bulk_callback), 			      port);		/* send the data out the bulk port */		result = usb_submit_urb(port->write_urb, GFP_ATOMIC);		if (result) {			err("%s - failed submitting write urb, error %d", __FUNCTION__, result);			/* Throw away data. No better idea what to do with it. */			priv->wrfilled=0;			priv->wrsent=0;			spin_unlock_irqrestore(&priv->lock, flags);			return 0;		}		dbg("%s - priv->wrsent=%d", __FUNCTION__,priv->wrsent);		dbg("%s - priv->wrfilled=%d", __FUNCTION__,priv->wrfilled);		if( priv->wrsent>=priv->wrfilled ) {			dbg("%s - buffer cleaned", __FUNCTION__);			memset( priv->wrbuf, 0, sizeof(priv->wrbuf) );			priv->wrfilled=0;			priv->wrsent=0;		}	}	spin_unlock_irqrestore(&priv->lock, flags);	return (count);} 
4520	/local/tlutelli/issta_data/temp/c/2005_temp/2005/4520/507ca9bc0476662f3463888d583864834eab1e11/cyberjack.c/buggy/drivers/usb/serial/cyberjack.c