Commit aac86703 authored by Peter Ujfalusi's avatar Peter Ujfalusi Committed by Vinod Koul

dmaengine: ti: omap-dma: Readability cleanup in omap_dma_tx_status()

The tx_status is most likely going to be asked for the current transfer, so
check that first then try to fall back to lookup of non started transfers.

In this way the code is a bit more readable and in most cases we will avoid
to run vchan_find_desc() all the time.
Signed-off-by: default avatarPeter Ujfalusi <peter.ujfalusi@ti.com>
Link: https://lore.kernel.org/r/20190716082459.1222-2-peter.ujfalusi@ti.comSigned-off-by: default avatarVinod Koul <vkoul@kernel.org>
parent f4c255f1
...@@ -833,10 +833,8 @@ static enum dma_status omap_dma_tx_status(struct dma_chan *chan, ...@@ -833,10 +833,8 @@ static enum dma_status omap_dma_tx_status(struct dma_chan *chan,
return ret; return ret;
spin_lock_irqsave(&c->vc.lock, flags); spin_lock_irqsave(&c->vc.lock, flags);
vd = vchan_find_desc(&c->vc, cookie);
if (vd) { if (c->desc && c->desc->vd.tx.cookie == cookie) {
txstate->residue = omap_dma_desc_size(to_omap_dma_desc(&vd->tx));
} else if (c->desc && c->desc->vd.tx.cookie == cookie) {
struct omap_desc *d = c->desc; struct omap_desc *d = c->desc;
dma_addr_t pos; dma_addr_t pos;
...@@ -848,11 +846,15 @@ static enum dma_status omap_dma_tx_status(struct dma_chan *chan, ...@@ -848,11 +846,15 @@ static enum dma_status omap_dma_tx_status(struct dma_chan *chan,
pos = 0; pos = 0;
txstate->residue = omap_dma_desc_size_pos(d, pos); txstate->residue = omap_dma_desc_size_pos(d, pos);
} else if ((vd = vchan_find_desc(&c->vc, cookie))) {
txstate->residue = omap_dma_desc_size(to_omap_dma_desc(&vd->tx));
} else { } else {
txstate->residue = 0; txstate->residue = 0;
} }
if (ret == DMA_IN_PROGRESS && c->paused) if (ret == DMA_IN_PROGRESS && c->paused)
ret = DMA_PAUSED; ret = DMA_PAUSED;
spin_unlock_irqrestore(&c->vc.lock, flags); spin_unlock_irqrestore(&c->vc.lock, flags);
return ret; return ret;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment