/* A partial UnAlloc must include the last BD in the list that was Alloc'd. */
LONG XEmacPs_BdRingUnAlloc(XEmacPs_BdRing *RingPtr, u32 NumBd, XEmacPs_Bd *BdSetPtr)
/* A partial UnAlloc must include the last BD in the list that was Alloc'd. */
LONG XEmacPs_BdRingUnAlloc(XEmacPs_BdRing *RingPtr, u32 NumBd, XEmacPs_Bd *BdSetPtr)
{
    LONG Status;
    (void) BdSetPtr;
    Xil_AssertNonvoid(RingPtr != NULL);
    Xil_AssertNonvoid(BdSetPtr != NULL);
    if (RingPtr->PreCnt < NumBd) {
        Status = (LONG)(XST_FAILURE);
    } else {
        XEMACPS_RING_SEEKBACK(RingPtr, (RingPtr->FreeHead), NumBd);
    RingPtr->FreeCnt += NumBd;
    RingPtr->PreCnt -= NumBd;
        Status = (LONG)(XST_SUCCESS);
    }
    return Status;
}