/* Free the DMA program buffer that is pointed by the GeneratedDmaProg field of the command. */
int XDmaPs_FreeDmaProg(XDmaPs *InstPtr, unsigned int Channel, XDmaPs_Cmd *Cmd)
/* Free the DMA program buffer that is pointed by the GeneratedDmaProg field of the command. */
int XDmaPs_FreeDmaProg(XDmaPs *InstPtr, unsigned int Channel, XDmaPs_Cmd *Cmd)
{
	void *Buf;
	XDmaPs_ChannelData *ChanData;
	Xil_AssertNonvoid(InstPtr != NULL);
	Xil_AssertNonvoid(Cmd != NULL);
	if (Channel > XDMAPS_CHANNELS_PER_DEV)
		return XST_FAILURE;
	Buf = (void *)Cmd->GeneratedDmaProg;
	ChanData = InstPtr->Chans + Channel;
	if (Buf) {
		XDmaPs_BufPool_Free(ChanData->ProgBufPool, Buf);
		Cmd->GeneratedDmaProg = 0;
		Cmd->GeneratedDmaProgLength = 0;
	}
	return XST_SUCCESS;
}