st_cpc_tty_area    *cpc_tty; 
st_cpc_tty_area *cpc_tty; 
void cpc_tty_receive(pc300dev_t *pc300dev){	st_cpc_tty_area    *cpc_tty; 	pc300ch_t *pc300chan = (pc300ch_t *)pc300dev->chan; 	pc300_t *card = (pc300_t *)pc300chan->card; 	int ch = pc300chan->channel; 	volatile pcsca_bd_t  __iomem * ptdescr; 	struct net_device_stats *stats = hdlc_stats(pc300dev->dev);	int rx_len, rx_aux; 	volatile unsigned char status; 	unsigned short first_bd = pc300chan->rx_first_bd;	st_cpc_rx_buf	*new=NULL;	unsigned char dsr_rx;	if (pc300dev->cpc_tty == NULL) { 		return; 	}	dsr_rx = cpc_readb(card->hw.scabase + DSR_RX(ch));	cpc_tty = (st_cpc_tty_area *)pc300dev->cpc_tty; 	while (1) { 		rx_len = 0;		ptdescr = (pcsca_bd_t  __iomem *)(card->hw.rambase + RX_BD_ADDR(ch, first_bd));		while ((status = cpc_readb(&ptdescr->status)) & DST_OSB) {			rx_len += cpc_readw(&ptdescr->len);			first_bd = (first_bd + 1) & (N_DMA_RX_BUF - 1);			if (status & DST_EOM) {				break;			}			ptdescr=(pcsca_bd_t __iomem *)(card->hw.rambase+cpc_readl(&ptdescr->next));		}					if (!rx_len) { 			if (dsr_rx & DSR_BOF) {				/* update EDA */ 				cpc_writel(card->hw.scabase + DRX_REG(EDAL, ch), 						RX_BD_ADDR(ch, pc300chan->rx_last_bd)); 			}			if (new) {				kfree(new);				new = NULL;			}			return; 		}				if (rx_len > CPC_TTY_MAX_MTU) { 			/* Free RX descriptors */ 			CPC_TTY_DBG("%s: frame size is invalid.\n",cpc_tty->name);			stats->rx_errors++; 			stats->rx_frame_errors++; 			cpc_tty_rx_disc_frame(pc300chan);			continue;		} 				new = (st_cpc_rx_buf *) kmalloc(rx_len + sizeof(st_cpc_rx_buf), GFP_ATOMIC);		if (new == 0) {			cpc_tty_rx_disc_frame(pc300chan);			continue;		}				/* dma buf read */ 		ptdescr = (pcsca_bd_t __iomem *)(card->hw.rambase + 				RX_BD_ADDR(ch, pc300chan->rx_first_bd)); 		rx_len = 0;	/* counter frame size */				while ((status = cpc_readb(&ptdescr->status)) & DST_OSB) {			rx_aux = cpc_readw(&ptdescr->len);			if ((status & (DST_OVR | DST_CRC | DST_RBIT |  DST_SHRT | DST_ABT))				|| (rx_aux > BD_DEF_LEN)) {				CPC_TTY_DBG("%s: reception error\n", cpc_tty->name);				stats->rx_errors++; 				if (status & DST_OVR) { 					stats->rx_fifo_errors++; 				}				if (status & DST_CRC) { 					stats->rx_crc_errors++; 				}				if ((status & (DST_RBIT | DST_SHRT | DST_ABT)) ||					(rx_aux > BD_DEF_LEN))	{ 					stats->rx_frame_errors++; 				} 				/* discard remainig descriptors used by the bad frame */ 				CPC_TTY_DBG("%s: reception error - discard descriptors",						cpc_tty->name);				cpc_tty_rx_disc_frame(pc300chan);				rx_len = 0;				kfree(new);				new = NULL;				break; /* read next frame - while(1) */			}			if (cpc_tty->state != CPC_TTY_ST_OPEN) {				/* Free RX descriptors */ 				cpc_tty_rx_disc_frame(pc300chan);				stats->rx_dropped++; 				rx_len = 0; 				kfree(new);				new = NULL;				break; /* read next frame - while(1) */			}			/* read the segment of the frame */			if (rx_aux != 0) {				memcpy_fromio((new->data + rx_len), 					(void __iomem *)(card->hw.rambase + 					 cpc_readl(&ptdescr->ptbuf)), rx_aux);				rx_len += rx_aux; 			}			cpc_writeb(&ptdescr->status,0); 			cpc_writeb(&ptdescr->len, 0); 			pc300chan->rx_first_bd = (pc300chan->rx_first_bd + 1) & 					(N_DMA_RX_BUF -1); 			if (status & DST_EOM)break;						ptdescr = (pcsca_bd_t __iomem *) (card->hw.rambase + 					cpc_readl(&ptdescr->next)); 		}		/* update pointer */ 		pc300chan->rx_last_bd = (pc300chan->rx_first_bd - 1) & 					(N_DMA_RX_BUF - 1) ; 		if (!(dsr_rx & DSR_BOF)) {			/* update EDA */ 			cpc_writel(card->hw.scabase + DRX_REG(EDAL, ch), 					RX_BD_ADDR(ch, pc300chan->rx_last_bd)); 		}		if (rx_len != 0) { 			stats->rx_bytes += rx_len; 					if (pc300dev->trace_on) { 				cpc_tty_trace(pc300dev, new->data,rx_len, 'R'); 			} 			new->size = rx_len;			new->next = NULL;			if (cpc_tty->buf_rx.first == 0) {				cpc_tty->buf_rx.first = new;				cpc_tty->buf_rx.last = new;			} else {				cpc_tty->buf_rx.last->next = new;				cpc_tty->buf_rx.last = new;			}			schedule_work(&(cpc_tty->tty_rx_work));			stats->rx_packets++;		}	} } 
4520	/local/tlutelli/issta_data/temp/c/2005_temp/2005/4520/6a5d362120a61a719095443194cc2d5e9a7027dd/pc300_tty.c/clean/drivers/net/wan/pc300_tty.c