XilinxProcessorIPLib/drivers/axicdma/src/xaxicdma_bdring.c
LONG XAxiCdma_BdRingUnAlloc(XAxiCdma *InstancePtr, int NumBd,
			 XAxiCdma_Bd * BdSetPtr)
{
	XAxiCdma_Bd *TmpBd;

	if (NumBd <= 0) {

		xdbg_printf(XDBG_DEBUG_ERROR, "BdRingUnAlloc: negative BD number "
			"%d\r\n", NumBd);

		return XST_INVALID_PARAM;
	}

	/* Enough BDs in the preprocessing state for the request? */
	if (InstancePtr->PreBdCnt < NumBd) {
		return XST_FAILURE;
	}

	/* The last BD in the BD set must has the FreeBdHead as its next BD.
	 * Otherwise, this is not a valid operation.
	 */
	TmpBd = BdSetPtr;
	XAXICDMA_RING_SEEKAHEAD(InstancePtr, TmpBd, NumBd);

	if (TmpBd != InstancePtr->FreeBdHead) {
		return XST_FAILURE;
	}

	/* Set the return argument and move FreeBdHead backward */
	XAXICDMA_RING_SEEKBACK(InstancePtr, InstancePtr->FreeBdHead, NumBd);
	InstancePtr->FreeBdCnt += NumBd;
	InstancePtr->PreBdCnt -= NumBd;

	return XST_SUCCESS;
}
/*****************************************************************************/
/**
 * This function tries to free the number of BDs back to the ring.
 *
 * @param	InstancePtr is the driver instance we are working on
 * @param	NumBd is the number of BDs to return
 * @param	BdSetPtr is the set of BDs to be returned
 *
 * @return
 *			- XST_SUCCESS for success
 *			- XST_INVALID_PARAM if to free non-positive number of BDs
 *			- XST_FAILURE if BD ring management shows an error
 *
 * @note	None.
 *
 *****************************************************************************/
This function tries to free the number of BDs back to the ring.
@param       InstancePtr is the driver instance we are working on
@param       NumBd is the number of BDs to return
@param       BdSetPtr is the set of BDs to be returned

@return
- XST_SUCCESS for success
- XST_INVALID_PARAM if to free non-positive number of BDs
- XST_FAILURE if BD ring management shows an error

@note        None.
This function tries to free the number of BDs back to the ring . @param InstancePtr is the driver instance we are working on @param NumBd is the number of BDs to return @param BdSetPtr is the set of BDs to be returned @return - XST_SUCCESS for success - XST_INVALID_PARAM if to free non - positive number of BDs - XST_FAILURE if BD ring management shows an error @note None .
LONG XAxiCdma_BdRingUnAlloc(XAxiCdma *InstancePtr, int NumBd,
			 XAxiCdma_Bd * BdSetPtr)
{
	XAxiCdma_Bd *TmpBd;
	if (NumBd <= 0) {
		xdbg_printf(XDBG_DEBUG_ERROR, "BdRingUnAlloc: negative BD number "
			"%d\r\n", NumBd);
		return XST_INVALID_PARAM;
	}
	if (InstancePtr->PreBdCnt < NumBd) {
		return XST_FAILURE;
	}
	TmpBd = BdSetPtr;
	XAXICDMA_RING_SEEKAHEAD(InstancePtr, TmpBd, NumBd);
	if (TmpBd != InstancePtr->FreeBdHead) {
		return XST_FAILURE;
	}
	XAXICDMA_RING_SEEKBACK(InstancePtr, InstancePtr->FreeBdHead, NumBd);
	InstancePtr->FreeBdCnt += NumBd;
	InstancePtr->PreBdCnt -= NumBd;
	return XST_SUCCESS;
}
LONG XAxiCdma_BdRingUnAlloc ( XAxiCdma * InstancePtr , int NumBd , XAxiCdma_Bd * BdSetPtr ) { XAxiCdma_Bd * TmpBd ; if ( NumBd <= 0 ) { xdbg_printf ( XDBG_DEBUG_ERROR , " " " \r \n " , NumBd ) ; return XST_INVALID_PARAM ; } if ( InstancePtr -> PreBdCnt < NumBd ) { return XST_FAILURE ; } TmpBd = BdSetPtr ; XAXICDMA_RING_SEEKAHEAD ( InstancePtr , TmpBd , NumBd ) ; if ( TmpBd != InstancePtr -> FreeBdHead ) { return XST_FAILURE ; } XAXICDMA_RING_SEEKBACK ( InstancePtr , InstancePtr -> FreeBdHead , NumBd ) ; InstancePtr -> FreeBdCnt += NumBd ; InstancePtr -> PreBdCnt -= NumBd ; return XST_SUCCESS ; }
This function tries to free the number of BDs back to the ring.
This function tries to free the number of BDs back to the ring .
/* Enough BDs in the preprocessing state for the request? */ /* The last BD in the BD set must has the FreeBdHead as its next BD.
	 * Otherwise, this is not a valid operation.
	 */ /* Set the return argument and move FreeBdHead backward */