pci_unmap_single(tp->pdev, rpl->DMABuff, tp->MaxPacketSize, PCI_DMA_TODEVICE); 
dma_unmap_single(tp->pdev, rpl->DMABuff, tp->MaxPacketSize, DMA_TO_DEVICE); 
static void tms380tr_rcv_status_irq(struct net_device *dev){	struct net_local *tp = netdev_priv(dev);	unsigned char *ReceiveDataPtr;	struct sk_buff *skb;	unsigned int Length, Length2;	RPL *rpl;	RPL *SaveHead;	dma_addr_t dmabuf;	/* NOTE: At this point the SSB from RECEIVE STATUS is no longer	 * available, because the CLEAR SSB command has already been issued.	 *	 * Process all complete receives.	 */	for(;;)	{		rpl = tp->RplHead;		if(rpl->Status & RX_VALID)			break;		/* RPL still in use by adapter */		/* Forward RPLHead pointer to next list. */		SaveHead = tp->RplHead;		tp->RplHead = rpl->NextRPLPtr;		/* Get the frame size (Byte swap for Intel).		 * Do this early (see workaround comment below)		 */		Length = be16_to_cpu((unsigned short)rpl->FrameSize);		/* Check if the Frame_Start, Frame_End and		 * Frame_Complete bits are set.		 */		if((rpl->Status & VALID_SINGLE_BUFFER_FRAME)			== VALID_SINGLE_BUFFER_FRAME)		{			ReceiveDataPtr = rpl->MData;			/* Workaround for delayed write of FrameSize on ISA			 * (FrameSize is false but valid-bit is reset)			 * Frame size is set to zero when the RPL is freed.			 * Length2 is there because there have also been			 * cases where the FrameSize was partially written			 */			Length2 = be16_to_cpu((unsigned short)rpl->FrameSize);			if(Length == 0 || Length != Length2)			{				tp->RplHead = SaveHead;				break;	/* Return to tms380tr_interrupt */			}			tms380tr_update_rcv_stats(tp,ReceiveDataPtr,Length);			  			if(tms380tr_debug > 3)				printk(KERN_DEBUG "%s: Packet Length %04X (%d)\n",					dev->name, Length, Length);			  			/* Indicate the received frame to system the			 * adapter does the Source-Routing padding for 			 * us. See: OpenOptions in tms380tr_init_opb()			 */			skb = rpl->Skb;			if(rpl->SkbStat == SKB_UNAVAILABLE)			{				/* Try again to allocate skb */				skb = dev_alloc_skb(tp->MaxPacketSize);				if(skb == NULL)				{					/* Update Stats ?? */				}				else				{					skb->dev	= dev;					skb_put(skb, tp->MaxPacketSize);					rpl->SkbStat 	= SKB_DATA_COPY;					ReceiveDataPtr 	= rpl->MData;				}			}			if(skb && (rpl->SkbStat == SKB_DATA_COPY				|| rpl->SkbStat == SKB_DMA_DIRECT))			{				if(rpl->SkbStat == SKB_DATA_COPY)					memcpy(skb->data, ReceiveDataPtr, Length);				/* Deliver frame to system */				rpl->Skb = NULL;				skb_trim(skb,Length);				skb->protocol = tr_type_trans(skb,dev);				netif_rx(skb);				dev->last_rx = jiffies;			}		}		else	/* Invalid frame */		{			if(rpl->Skb != NULL)				dev_kfree_skb_irq(rpl->Skb);			/* Skip list. */			if(rpl->Status & RX_START_FRAME)				/* Frame start bit is set -> overflow. */				tp->MacStat.rx_errors++;		}		if (rpl->DMABuff)			pci_unmap_single(tp->pdev, rpl->DMABuff, tp->MaxPacketSize, PCI_DMA_TODEVICE);		rpl->DMABuff = 0;		/* Allocate new skb for rpl */		rpl->Skb = dev_alloc_skb(tp->MaxPacketSize);		/* skb == NULL ? then use local buffer */		if(rpl->Skb == NULL)		{			rpl->SkbStat = SKB_UNAVAILABLE;			rpl->FragList[0].DataAddr = htonl(((char *)tp->LocalRxBuffers[rpl->RPLIndex] - (char *)tp) + tp->dmabuffer);			rpl->MData = tp->LocalRxBuffers[rpl->RPLIndex];		}		else	/* skb != NULL */		{			rpl->Skb->dev = dev;			skb_put(rpl->Skb, tp->MaxPacketSize);			/* Data unreachable for DMA ? then use local buffer */			dmabuf = pci_map_single(tp->pdev, rpl->Skb->data, tp->MaxPacketSize, PCI_DMA_FROMDEVICE);			if(tp->dmalimit && (dmabuf + tp->MaxPacketSize > tp->dmalimit))			{				rpl->SkbStat = SKB_DATA_COPY;				rpl->FragList[0].DataAddr = htonl(((char *)tp->LocalRxBuffers[rpl->RPLIndex] - (char *)tp) + tp->dmabuffer);				rpl->MData = tp->LocalRxBuffers[rpl->RPLIndex];			}			else			{				/* DMA directly in skb->data */				rpl->SkbStat = SKB_DMA_DIRECT;				rpl->FragList[0].DataAddr = htonl(dmabuf);				rpl->MData = rpl->Skb->data;				rpl->DMABuff = dmabuf;			}		}		rpl->FragList[0].DataCount = cpu_to_be16((unsigned short)tp->MaxPacketSize);		rpl->FrameSize = 0;		/* Pass the last RPL back to the adapter */		tp->RplTail->FrameSize = 0;		/* Reset the CSTAT field in the list. */		tms380tr_write_rpl_status(tp->RplTail, RX_VALID | RX_FRAME_IRQ);		/* Current RPL becomes last one in list. */		tp->RplTail = tp->RplTail->NextRPLPtr;		/* Inform adapter about RPL valid. */		tms380tr_exec_sifcmd(dev, CMD_RX_VALID);	}	return;}
10457	/local/tlutelli/issta_data/temp/c/2005_temp/2005/10457/504ff16cecf2a788181eddc9d6e47d94ce50a9f6/tms380tr.c/clean/drivers/net/tokenring/tms380tr.c