XilinxProcessorIPLib/drivers/axidma/src/xaxidma_bdring.c
int XAxiDma_BdRingFree(XAxiDma_BdRing * RingPtr, int NumBd,
		      XAxiDma_Bd * BdSetPtr)
{
	if (NumBd < 0) {

		xdbg_printf(XDBG_DEBUG_ERROR,
		    "BdRingFree: negative BDs %d\r\n", NumBd);

		return XST_INVALID_PARAM;
	}

	/* If the BD Set to free is empty, do nothing
	 */
	if (NumBd == 0) {
		return XST_SUCCESS;
	}

	/* Make sure we are in sync with XAxiDma_BdRingFromHw() */
	if ((RingPtr->PostCnt < NumBd) || (RingPtr->PostHead != BdSetPtr)) {

		xdbg_printf(XDBG_DEBUG_ERROR, "BdRingFree: Error free BDs: "
		"post count %d to free %d, PostHead %x to free ptr %x\r\n",
			RingPtr->PostCnt, NumBd,
			(UINTPTR)RingPtr->PostHead,
			(UINTPTR)BdSetPtr);

		return XST_DMA_SG_LIST_ERROR;
	}

	/* Update pointers and counters */
	RingPtr->FreeCnt += NumBd;
	RingPtr->PostCnt -= NumBd;
	XAXIDMA_RING_SEEKAHEAD(RingPtr, RingPtr->PostHead, NumBd);

	return XST_SUCCESS;
}
/*****************************************************************************/
/**
 * Frees a set of BDs that had been previously retrieved with
 * XAxiDma_BdRingFromHw().
 *
 * @param	RingPtr is a pointer to the descriptor ring instance to be
 *		worked on.
 * @param	NumBd is the number of BDs to free.
 * @param	BdSetPtr is the head of a list of BDs returned by
 *		XAxiDma_BdRingFromHw().
 *
 * @return
 *		- XST_SUCCESS if the set of BDs was freed.
 *		- XST_INVALID_PARAM if NumBd is negative
 *		- XST_DMA_SG_LIST_ERROR if this function was called out of
 *		sequence with XAxiDma_BdRingFromHw().
 *
 * @note	This function should not be preempted by another XAxiDma
 *		function call that modifies the BD space. It is the caller's
 *		responsibility to ensure mutual exclusion.
 *
 *		This function can be used only when DMA is in SG mode
 *
 *****************************************************************************/
Frees a set of BDs that had been previously retrieved with
XAxiDma_BdRingFromHw().

@param       RingPtr is a pointer to the descriptor ring instance to be
worked on.
@param       NumBd is the number of BDs to free.
@param       BdSetPtr is the head of a list of BDs returned by
XAxiDma_BdRingFromHw().

@return
- XST_SUCCESS if the set of BDs was freed.
- XST_INVALID_PARAM if NumBd is negative
- XST_DMA_SG_LIST_ERROR if this function was called out of
sequence with XAxiDma_BdRingFromHw().

@note        This function should not be preempted by another XAxiDma
function call that modifies the BD space. It is the caller's
responsibility to ensure mutual exclusion.

This function can be used only when DMA is in SG mode
Frees a set of BDs that had been previously retrieved with XAxiDma_BdRingFromHw () . @param RingPtr is a pointer to the descriptor ring instance to be worked on . @param NumBd is the number of BDs to free . @param BdSetPtr is the head of a list of BDs returned by XAxiDma_BdRingFromHw () . @return - XST_SUCCESS if the set of BDs was freed . - XST_INVALID_PARAM if NumBd is negative - XST_DMA_SG_LIST_ERROR if this function was called out of sequence with XAxiDma_BdRingFromHw () . @note This function should not be preempted by another XAxiDma function call that modifies the BD space . It is the caller ' s responsibility to ensure mutual exclusion . This function can be used only when DMA is in SG mode
int XAxiDma_BdRingFree(XAxiDma_BdRing * RingPtr, int NumBd,
		      XAxiDma_Bd * BdSetPtr)
{
	if (NumBd < 0) {
		xdbg_printf(XDBG_DEBUG_ERROR,
		    "BdRingFree: negative BDs %d\r\n", NumBd);
		return XST_INVALID_PARAM;
	}
	if (NumBd == 0) {
		return XST_SUCCESS;
	}
	if ((RingPtr->PostCnt < NumBd) || (RingPtr->PostHead != BdSetPtr)) {
		xdbg_printf(XDBG_DEBUG_ERROR, "BdRingFree: Error free BDs: "
		"post count %d to free %d, PostHead %x to free ptr %x\r\n",
			RingPtr->PostCnt, NumBd,
			(UINTPTR)RingPtr->PostHead,
			(UINTPTR)BdSetPtr);
		return XST_DMA_SG_LIST_ERROR;
	}
	RingPtr->FreeCnt += NumBd;
	RingPtr->PostCnt -= NumBd;
	XAXIDMA_RING_SEEKAHEAD(RingPtr, RingPtr->PostHead, NumBd);
	return XST_SUCCESS;
}
int XAxiDma_BdRingFree ( XAxiDma_BdRing * RingPtr , int NumBd , XAxiDma_Bd * BdSetPtr ) { if ( NumBd < 0 ) { xdbg_printf ( XDBG_DEBUG_ERROR , " \r \n " , NumBd ) ; return XST_INVALID_PARAM ; } if ( NumBd == 0 ) { return XST_SUCCESS ; } if ( ( RingPtr -> PostCnt < NumBd ) || ( RingPtr -> PostHead != BdSetPtr ) ) { xdbg_printf ( XDBG_DEBUG_ERROR , " " " \r \n " , RingPtr -> PostCnt , NumBd , ( UINTPTR ) RingPtr -> PostHead , ( UINTPTR ) BdSetPtr ) ; return XST_DMA_SG_LIST_ERROR ; } RingPtr -> FreeCnt += NumBd ; RingPtr -> PostCnt -= NumBd ; XAXIDMA_RING_SEEKAHEAD ( RingPtr , RingPtr -> PostHead , NumBd ) ; return XST_SUCCESS ; }
Frees a set of BDs that had been previously retrieved with
 XAxiDma_BdRingFromHw().
Frees a set of BDs that had been previously retrieved with XAxiDma_BdRingFromHw () .
/* If the BD Set to free is empty, do nothing
	 */ /* Make sure we are in sync with XAxiDma_BdRingFromHw() */ /* Update pointers and counters */