/* Free an allocated DMA resource. 
This function will free an allocated DMA resource. */
enum status_code dma_free(struct dma_resource *resource)
/* Free an allocated DMA resource. 
This function will free an allocated DMA resource. */
enum status_code dma_free(struct dma_resource *resource)
{
	if (dma_get_job_status(resource) == STATUS_BUSY) {
		return STATUS_BUSY;
	}
	if (!(_dma_inst.allocated_channels & (1 << resource->channel_id))) {
		return STATUS_ERR_NOT_INITIALIZED;
	}
	_dma_release_channel(resource->channel_id);
	_dma_active_resource[resource->channel_id] = NULL;
	return STATUS_OK;
}