struct board_chan *bc; 
struct board_chan __iomem *bc; 
static void receive_data(struct channel *ch){ /* Begin receive_data */	unchar *rptr;	struct termios *ts = NULL;	struct tty_struct *tty;	struct board_chan *bc;	int dataToRead, wrapgap, bytesAvailable;	unsigned int tail, head;	unsigned int wrapmask;	int rc;	/* ---------------------------------------------------------------		This routine is called by doint when a receive data event 		has taken place.	------------------------------------------------------------------- */	globalwinon(ch);	if (ch->statusflags & RXSTOPPED)		return;	tty = ch->tty;	if (tty)		ts = tty->termios;	bc = ch->brdchan;	BUG_ON(!bc);	wrapmask = ch->rxbufsize - 1;	/* --------------------------------------------------------------------- 		Get the head and tail pointers to the receiver queue.  Wrap the 		head pointer if it has reached the end of the buffer.	------------------------------------------------------------------------ */	head = readw(&bc->rin);	head &= wrapmask;	tail = readw(&bc->rout) & wrapmask;	bytesAvailable = (head - tail) & wrapmask;	if (bytesAvailable == 0)		return;	/* ------------------------------------------------------------------	   If CREAD bit is off or device not open, set TX tail to head	--------------------------------------------------------------------- */	if (!tty || !ts || !(ts->c_cflag & CREAD))  {		bc->rout = head;		return;	}	if (tty->flip.count == TTY_FLIPBUF_SIZE) 		return;	if (readb(&bc->orun)) {		writeb(0, &bc->orun);		printk(KERN_WARNING "epca; overrun! DigiBoard device %s\n",tty->name);	}	rxwinon(ch);	rptr = tty->flip.char_buf_ptr;	rc = tty->flip.count;	while (bytesAvailable > 0)  { /* Begin while there is data on the card */		wrapgap = (head >= tail) ? head - tail : ch->rxbufsize - tail;		/* ---------------------------------------------------------------			Even if head has wrapped around only report the amount of			data to be equal to the size - tail.  Remember memcpy can't			automaticly wrap around the receive buffer.		----------------------------------------------------------------- */		dataToRead = (wrapgap < bytesAvailable) ? wrapgap : bytesAvailable;		/* --------------------------------------------------------------		   Make sure we don't overflow the buffer		----------------------------------------------------------------- */		if ((rc + dataToRead) > TTY_FLIPBUF_SIZE)			dataToRead = TTY_FLIPBUF_SIZE - rc;		if (dataToRead == 0)			break;		/* ---------------------------------------------------------------			Move data read from our card into the line disciplines buffer			for translation if necessary.		------------------------------------------------------------------ */		memcpy_fromio(rptr, ch->rxptr + tail, dataToRead);		rc   += dataToRead;		rptr += dataToRead;		tail = (tail + dataToRead) & wrapmask;		bytesAvailable -= dataToRead;	} /* End while there is data on the card */	tty->flip.count = rc;	tty->flip.char_buf_ptr = rptr;	globalwinon(ch);	writew(tail, &bc->rout);	/* Must be called with global data */	tty_schedule_flip(ch->tty); 	return;} /* End receive_data */
4520	/local/tlutelli/issta_data/temp/c/2005_temp/2005/4520/bc9a5154a24d16d41cc79dbf1442de34454bc7db/epca.c/buggy/drivers/char/epca.c