* space 
* space 
static int lan_saa9730_allocate_buffers(struct lan_saa9730_private *lp){	unsigned int mem_size;	void *Pa;	unsigned int i, j, RcvBufferSize, TxmBufferSize;	unsigned int buffer_start;	/* 	 * Allocate all RX and TX packets in one chunk. 	 * The Rx and Tx packets must be PACKET_SIZE aligned.	 */	mem_size = ((LAN_SAA9730_RCV_Q_SIZE + LAN_SAA9730_TXM_Q_SIZE) *		    LAN_SAA9730_PACKET_SIZE * LAN_SAA9730_BUFFERS) +	    LAN_SAA9730_PACKET_SIZE;	buffer_start =	    (unsigned int) kmalloc(mem_size, GFP_DMA | GFP_KERNEL);	if (!buffer_start)		return -ENOMEM;	/* 	 * Set DMA buffer to kseg1 (uncached).	 * Make sure to flush before using it uncached.	 */	Pa = (void *) KSEG1ADDR((buffer_start + LAN_SAA9730_PACKET_SIZE) &				~(LAN_SAA9730_PACKET_SIZE - 1));	dma_cache_wback_inv((unsigned long) Pa, mem_size);	/* Initialize buffer space */	RcvBufferSize = LAN_SAA9730_PACKET_SIZE;	TxmBufferSize = LAN_SAA9730_PACKET_SIZE;	lp->DmaRcvPackets = LAN_SAA9730_RCV_Q_SIZE;	lp->DmaTxmPackets = LAN_SAA9730_TXM_Q_SIZE;	/* Init RX buffers */	for (i = 0; i < LAN_SAA9730_BUFFERS; i++) {		for (j = 0; j < LAN_SAA9730_RCV_Q_SIZE; j++) {			*(unsigned int *) Pa =			    cpu_to_le32(RXSF_READY <<					RX_STAT_CTL_OWNER_SHF);			lp->RcvBuffer[i][j] = (unsigned int) Pa;			Pa += RcvBufferSize;		}	}	/* Init TX buffers */	for (i = 0; i < LAN_SAA9730_BUFFERS; i++) {		for (j = 0; j < LAN_SAA9730_TXM_Q_SIZE; j++) {			*(unsigned int *) Pa =			    cpu_to_le32(TXSF_EMPTY <<					TX_STAT_CTL_OWNER_SHF);			lp->TxmBuffer[i][j] = (unsigned int) Pa;			Pa += TxmBufferSize;		}	}	/* 	 * Set rx buffer A and rx buffer B to point to the first two buffer 	 * spaces.	 */	OUTL(PHYSADDR(lp->RcvBuffer[0][0]),	     &lp->lan_saa9730_regs->RxBuffA);	OUTL(PHYSADDR(lp->RcvBuffer[1][0]),	     &lp->lan_saa9730_regs->RxBuffB);	/* Initialize Buffer Index */	lp->NextRcvPacketIndex = 0;	lp->NextRcvToUseIsA = 1;	/* Set current buffer index & next availble packet index */	lp->NextTxmPacketIndex = 0;	lp->NextTxmBufferIndex = 0;	lp->PendingTxmPacketIndex = 0;	lp->PendingTxmBufferIndex = 0;	/* 	 * Set txm_buf_a and txm_buf_b to point to the first two buffer	 * space 	 */	OUTL(PHYSADDR(lp->TxmBuffer[0][0]),	     &lp->lan_saa9730_regs->TxBuffA);	OUTL(PHYSADDR(lp->TxmBuffer[1][0]),	     &lp->lan_saa9730_regs->TxBuffB);	/* Set packet number */	OUTL((lp->DmaRcvPackets << PK_COUNT_RX_A_SHF) |	     (lp->DmaRcvPackets << PK_COUNT_RX_B_SHF) |	     (lp->DmaTxmPackets << PK_COUNT_TX_A_SHF) |	     (lp->DmaTxmPackets << PK_COUNT_TX_B_SHF),	     &lp->lan_saa9730_regs->PacketCount);	return 0;}
4520	/local/tlutelli/issta_data/temp/c/2005_temp/2005/4520/62ff0d0a0769f08806d3f50449a78f17420971e8/saa9730.c/buggy/drivers/net/saa9730.c