/* fsl_dma_update_completed_cookie - Update the completed cookie. @fsl_chan : Freescale DMA channel  */
static void fsl_dma_update_completed_cookie(struct fsl_dma_chan *fsl_chan)
/* fsl_dma_update_completed_cookie - Update the completed cookie. @fsl_chan : Freescale DMA channel  */
static void fsl_dma_update_completed_cookie(struct fsl_dma_chan *fsl_chan)
{
	struct fsl_desc_sw *cur_desc, *desc;
	dma_addr_t ld_phy;
	ld_phy = get_cdar(fsl_chan) & FSL_DMA_NLDA_MASK;
	if (ld_phy) {
		cur_desc = NULL;
		list_for_each_entry(desc, &fsl_chan->ld_queue, node)
			if (desc->async_tx.phys == ld_phy) {
				cur_desc = desc;
				break;
			}
		if (cur_desc && cur_desc->async_tx.cookie) {
			if (dma_is_idle(fsl_chan))
				fsl_chan->completed_cookie =
					cur_desc->async_tx.cookie;
			else
				fsl_chan->completed_cookie =
					cur_desc->async_tx.cookie - 1;
		}
	}
}