/* Search DMA channel context for specified DMA channel resource.  */
static hpm_dma_channel_context_t * dma_manager_search_channel_context(const hpm_dma_resource_t *resource)
/* Search DMA channel context for specified DMA channel resource.  */
static hpm_dma_channel_context_t * dma_manager_search_channel_context(const hpm_dma_resource_t *resource)
{
    hpm_dma_channel_context_t *channel_ctx = NULL;
    if ((resource != NULL) && (resource->channel < DMA_SOC_CHANNEL_NUM)) {
        uint32_t instance;
        uint32_t channel;
        bool has_found = false;
        for (instance = 0; instance < DMA_SOC_MAX_COUNT; instance++) {
            if (resource->base == HPM_DMA_MGR->dma_instance[instance].base) {
                has_found = true;
                break;
            }
        }
        channel = resource->channel;
        if (has_found) {
            channel_ctx = &HPM_DMA_MGR->channels[instance][channel];
        }
    }
    return channel_ctx;
}