When the transfer is complete, it is important to free the transfer descriptor. This is done with the function dma_free_descriptor() (for STLinux-2.2) or dma_params_free() (for STLinux-2.3):
/* STLinux-2.2 */ int dma_free_descriptor(struct stm_dma_params *params); /*STLinux-2.3 */ int dma_params_free(struct stm_dma_params *params);
where params is a pointer to the stm_dma_params structure for the transfer. The function frees all the allocated node memory and resets the structures parameters. The structure can be re-initialized for a new transfer, or it can be discarded.
A channel that has been reserved must be freed with it is no longer required. This is done with the function free_dma():
void free_dma(unsigned int chan);
where chan is the channel to be freed. If the channel is idle, it is freed at once; if the channel is busy, the function stops the channel first and then frees it.