Commit 004f614e authored by Jon Hunter's avatar Jon Hunter Committed by Vinod Koul

dmaengine: tegra-apb: Remove duplicated residue calculation

The calculation of the DMA residue for the Tegra APB DMA is duplicated
in two places in the tegra_dma_tx_status() function. Remove this
duplicated code by moving calculation to the end of the function and
only calculating if we found a valid descriptor.
Signed-off-by: default avatarJon Hunter <jonathanh@nvidia.com>
Signed-off-by: default avatarVinod Koul <vinod.koul@intel.com>
parent 019bfcc6
...@@ -819,13 +819,8 @@ static enum dma_status tegra_dma_tx_status(struct dma_chan *dc, ...@@ -819,13 +819,8 @@ static enum dma_status tegra_dma_tx_status(struct dma_chan *dc,
/* Check on wait_ack desc status */ /* Check on wait_ack desc status */
list_for_each_entry(dma_desc, &tdc->free_dma_desc, node) { list_for_each_entry(dma_desc, &tdc->free_dma_desc, node) {
if (dma_desc->txd.cookie == cookie) { if (dma_desc->txd.cookie == cookie) {
residual = dma_desc->bytes_requested -
(dma_desc->bytes_transferred %
dma_desc->bytes_requested);
dma_set_residue(txstate, residual);
ret = dma_desc->dma_status; ret = dma_desc->dma_status;
spin_unlock_irqrestore(&tdc->lock, flags); goto found;
return ret;
} }
} }
...@@ -833,17 +828,22 @@ static enum dma_status tegra_dma_tx_status(struct dma_chan *dc, ...@@ -833,17 +828,22 @@ static enum dma_status tegra_dma_tx_status(struct dma_chan *dc,
list_for_each_entry(sg_req, &tdc->pending_sg_req, node) { list_for_each_entry(sg_req, &tdc->pending_sg_req, node) {
dma_desc = sg_req->dma_desc; dma_desc = sg_req->dma_desc;
if (dma_desc->txd.cookie == cookie) { if (dma_desc->txd.cookie == cookie) {
ret = dma_desc->dma_status;
goto found;
}
}
dev_dbg(tdc2dev(tdc), "cookie %d not found\n", cookie);
dma_desc = NULL;
found:
if (dma_desc) {
residual = dma_desc->bytes_requested - residual = dma_desc->bytes_requested -
(dma_desc->bytes_transferred % (dma_desc->bytes_transferred %
dma_desc->bytes_requested); dma_desc->bytes_requested);
dma_set_residue(txstate, residual); dma_set_residue(txstate, residual);
ret = dma_desc->dma_status;
spin_unlock_irqrestore(&tdc->lock, flags);
return ret;
}
} }
dev_dbg(tdc2dev(tdc), "cookie %d not found\n", cookie);
spin_unlock_irqrestore(&tdc->lock, flags); spin_unlock_irqrestore(&tdc->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