Commit 68a7faa2 authored by Tomasz Figa's avatar Tomasz Figa Committed by Vinod Koul

dmaengine: PL08x: Refactor pl08x_getbytes_chan() to lower indentation

Further patch will introduce support for PL080S, which requires some
things to be done conditionally, thus increasing indentation level of
some functions even more.

This patch reduces indentation level of pl08x_getbytes_chan() function
by inverting several conditions and returning from function wherever
possible.
Signed-off-by: default avatarTomasz Figa <tomasz.figa@gmail.com>
Reviewed-by: default avatarLinus Walleij <linus.walleij@linaro.org>
Signed-off-by: default avatarVinod Koul <vinod.koul@intel.com>
parent 39ff8613
...@@ -469,27 +469,34 @@ static inline u32 get_bytes_in_cctl(u32 cctl) ...@@ -469,27 +469,34 @@ static inline u32 get_bytes_in_cctl(u32 cctl)
/* The channel should be paused when calling this */ /* The channel should be paused when calling this */
static u32 pl08x_getbytes_chan(struct pl08x_dma_chan *plchan) static u32 pl08x_getbytes_chan(struct pl08x_dma_chan *plchan)
{ {
struct pl08x_lli *llis_va;
struct pl08x_phy_chan *ch; struct pl08x_phy_chan *ch;
dma_addr_t llis_bus;
struct pl08x_txd *txd; struct pl08x_txd *txd;
size_t bytes = 0; size_t bytes;
int index;
u32 clli;
ch = plchan->phychan; ch = plchan->phychan;
txd = plchan->at; txd = plchan->at;
if (!ch || !txd)
return 0;
/* /*
* Follow the LLIs to get the number of remaining * Follow the LLIs to get the number of remaining
* bytes in the currently active transaction. * bytes in the currently active transaction.
*/ */
if (ch && txd) { clli = readl(ch->base + PL080_CH_LLI) & ~PL080_LLI_LM_AHB2;
u32 clli = readl(ch->base + PL080_CH_LLI) & ~PL080_LLI_LM_AHB2;
/* First get the remaining bytes in the active transfer */ /* First get the remaining bytes in the active transfer */
bytes = get_bytes_in_cctl(readl(ch->base + PL080_CH_CONTROL)); bytes = get_bytes_in_cctl(readl(ch->base + PL080_CH_CONTROL));
if (clli) { if (!clli)
struct pl08x_lli *llis_va = txd->llis_va; return bytes;
dma_addr_t llis_bus = txd->llis_bus;
int index; llis_va = txd->llis_va;
llis_bus = txd->llis_bus;
BUG_ON(clli < llis_bus || clli >= llis_bus + BUG_ON(clli < llis_bus || clli >= llis_bus +
sizeof(struct pl08x_lli) * MAX_NUM_TSFR_LLIS); sizeof(struct pl08x_lli) * MAX_NUM_TSFR_LLIS);
...@@ -509,8 +516,6 @@ static u32 pl08x_getbytes_chan(struct pl08x_dma_chan *plchan) ...@@ -509,8 +516,6 @@ static u32 pl08x_getbytes_chan(struct pl08x_dma_chan *plchan)
if (!llis_va[index].lli) if (!llis_va[index].lli)
break; break;
} }
}
}
return bytes; return bytes;
} }
......
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