/* Frees a set of BDs that had been previously retrieved with XEmacPs_BdRingFromHw(). */
LONG XEmacPs_BdRingFree(XEmacPs_BdRing *RingPtr, u32 NumBd, XEmacPs_Bd *BdSetPtr)
/* Frees a set of BDs that had been previously retrieved with XEmacPs_BdRingFromHw(). */
LONG XEmacPs_BdRingFree(XEmacPs_BdRing *RingPtr, u32 NumBd, XEmacPs_Bd *BdSetPtr)
{
	LONG Status;
	if (0x00000000U == NumBd){
		Status = (LONG)(XST_SUCCESS);
	} else {
	if ((RingPtr->PostCnt < NumBd) || (RingPtr->PostHead != BdSetPtr)) {
			Status = (LONG)(XST_DMA_SG_LIST_ERROR);
		} else {
	RingPtr->FreeCnt += NumBd;
	RingPtr->PostCnt -= NumBd;
	XEMACPS_RING_SEEKAHEAD(RingPtr, RingPtr->PostHead, NumBd);
			Status = (LONG)(XST_SUCCESS);
		}
	}
	return Status;
}