/* The first two bytes of every read packet are status */ if (urb->actual_length > 2) { usb_serial_debug_data(debug, &port->dev, __FUNCTION__, urb->actual_length, data); 
if (priv->rx_processed) { dbg("%s - already processed: %d bytes, %d remain", __FUNCTION__, priv->rx_processed, urb->actual_length - priv->rx_processed); 
static void ftdi_process_read (struct usb_serial_port *port){ /* ftdi_process_read */	struct urb *urb;	struct tty_struct *tty;	struct ftdi_private *priv;	char error_flag;       	unsigned char *data;	int i;	int result;	int need_flip;	int packet_offset;	dbg("%s - port %d", __FUNCTION__, port->number);	if (port->open_count <= 0)		return;	tty = port->tty;	if (!tty) {		dbg("%s - bad tty pointer - exiting",__FUNCTION__);		return;	}	priv = usb_get_serial_port_data(port);	if (!priv) {		dbg("%s - bad port private data pointer - exiting", __FUNCTION__);		return;	}	urb = port->read_urb;	if (!urb) {		dbg("%s - bad read_urb pointer - exiting", __FUNCTION__);		return;	}	data = urb->transfer_buffer;        /* The first two bytes of every read packet are status */	if (urb->actual_length > 2) {		usb_serial_debug_data(debug, &port->dev, __FUNCTION__, urb->actual_length, data);	} else {                dbg("Status only: %03oo %03oo",data[0],data[1]);        }	/* TO DO -- check for hung up line and handle appropriately: */	/*   send hangup  */	/* See acm.c - you do a tty_hangup  - eg tty_hangup(tty) */	/* if CD is dropped and the line is not CLOCAL then we should hangup */	need_flip = 0;	for (packet_offset=0; packet_offset < urb->actual_length; packet_offset += PKTSZ) {		/* Compare new line status to the old one, signal if different */		if (priv != NULL) {			char new_status = data[packet_offset+0] & FTDI_STATUS_B0_MASK;			if (new_status != priv->prev_status) {				priv->diff_status |= new_status ^ priv->prev_status;				wake_up_interruptible(&priv->delta_msr_wait);				priv->prev_status = new_status;			}		}		/* Handle errors and break */		error_flag = TTY_NORMAL;		/* Although the device uses a bitmask and hence can have multiple */		/* errors on a packet - the order here sets the priority the */		/* error is returned to the tty layer  */		if ( data[packet_offset+1] & FTDI_RS_OE ) {			error_flag = TTY_OVERRUN;			dbg("OVERRRUN error");		}		if ( data[packet_offset+1] & FTDI_RS_BI ) {			error_flag = TTY_BREAK;			dbg("BREAK received");		}		if ( data[packet_offset+1] & FTDI_RS_PE ) {			error_flag = TTY_PARITY;			dbg("PARITY error");		}		if ( data[packet_offset+1] & FTDI_RS_FE ) {			error_flag = TTY_FRAME;			dbg("FRAMING error");		}		if (urb->actual_length > packet_offset + 2) {			for (i = 2; (i < PKTSZ) && ((i+packet_offset) < urb->actual_length); ++i) {				/* have to make sure we don't overflow the buffer				  with tty_insert_flip_char's */				if(tty->flip.count >= TTY_FLIPBUF_SIZE) {					tty_flip_buffer_push(tty);				}				/* Note that the error flag is duplicated for 				   every character received since we don't know				   which character it applied to */				tty_insert_flip_char(tty, data[packet_offset+i], error_flag);			}			need_flip = 1;		}#ifdef NOT_CORRECT_BUT_KEEPING_IT_FOR_NOW		/* if a parity error is detected you get status packets forever		   until a character is sent without a parity error.		   This doesn't work well since the application receives a never		   ending stream of bad data - even though new data hasn't been sent.		   Therefore I (bill) have taken this out.		   However - this might make sense for framing errors and so on 		   so I am leaving the code in for now.		*/		else {			if (error_flag != TTY_NORMAL){				dbg("error_flag is not normal");				/* In this case it is just status - if that is an error send a bad character */				if(tty->flip.count >= TTY_FLIPBUF_SIZE) {					tty_flip_buffer_push(tty);				}				tty_insert_flip_char(tty, 0xff, error_flag);				need_flip = 1;			}		}#endif	} /* "for(packet_offset=0..." */	/* Low latency */	if (need_flip) {		tty_flip_buffer_push(tty);	}	/* if the port is closed stop trying to read */	if (port->open_count > 0){		/* Continue trying to always read  */		usb_fill_bulk_urb(port->read_urb, port->serial->dev, 			      usb_rcvbulkpipe(port->serial->dev, port->bulk_in_endpointAddress),			      port->read_urb->transfer_buffer, port->read_urb->transfer_buffer_length,			      ftdi_read_bulk_callback, port);		result = usb_submit_urb(port->read_urb, GFP_ATOMIC);		if (result)			err("%s - failed resubmitting read urb, error %d", __FUNCTION__, result);	}	return;} /* ftdi_process_read */
10457	/local/tlutelli/issta_data/temp/c/2005_temp/2005/10457/76854ceac3ef3408ab9a50a2521147fb14779f58/ftdi_sio.c/buggy/drivers/usb/serial/ftdi_sio.c