Skip to content

Commit 28cbe5a

Browse files
ambarusvinodkoul
authored andcommitted
dmaengine: at_hdmac: Fix impossible condition
The iterator can not be greater than ATC_MAX_DSCR_TRIALS, as the for loop will stop when i == ATC_MAX_DSCR_TRIALS. While here, use the common "i" name for the iterator. Fixes: 93dce3a ("dmaengine: at_hdmac: fix residue computation") Signed-off-by: Tudor Ambarus <[email protected]> Cc: [email protected] Acked-by: Nicolas Ferre <[email protected]> Link: https://lore.kernel.org/r/[email protected] Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Vinod Koul <[email protected]>
1 parent 580ee84 commit 28cbe5a

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

drivers/dma/at_hdmac.c

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -318,7 +318,8 @@ static int atc_get_bytes_left(struct dma_chan *chan, dma_cookie_t cookie)
318318
struct at_desc *desc_first = atc_first_active(atchan);
319319
struct at_desc *desc;
320320
int ret;
321-
u32 ctrla, dscr, trials;
321+
u32 ctrla, dscr;
322+
unsigned int i;
322323

323324
/*
324325
* If the cookie doesn't match to the currently running transfer then
@@ -388,7 +389,7 @@ static int atc_get_bytes_left(struct dma_chan *chan, dma_cookie_t cookie)
388389
dscr = channel_readl(atchan, DSCR);
389390
rmb(); /* ensure DSCR is read before CTRLA */
390391
ctrla = channel_readl(atchan, CTRLA);
391-
for (trials = 0; trials < ATC_MAX_DSCR_TRIALS; ++trials) {
392+
for (i = 0; i < ATC_MAX_DSCR_TRIALS; ++i) {
392393
u32 new_dscr;
393394

394395
rmb(); /* ensure DSCR is read after CTRLA */
@@ -414,7 +415,7 @@ static int atc_get_bytes_left(struct dma_chan *chan, dma_cookie_t cookie)
414415
rmb(); /* ensure DSCR is read before CTRLA */
415416
ctrla = channel_readl(atchan, CTRLA);
416417
}
417-
if (unlikely(trials >= ATC_MAX_DSCR_TRIALS))
418+
if (unlikely(i == ATC_MAX_DSCR_TRIALS))
418419
return -ETIMEDOUT;
419420

420421
/* for the first descriptor we can be more accurate */

0 commit comments

Comments
 (0)