mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git
synced 2024-10-01 06:33:07 +00:00
dmaengine: cleanup with list_first_entry_or_null()
The combo of list_empty() check and return list_first_entry() can be replaced with list_first_entry_or_null(). Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com> Acked-by: Linus Walleij <linus.walleij@linaro.org> Signed-off-by: Vinod Koul <vinod.koul@intel.com>
This commit is contained in:
parent
aa570be6de
commit
360af35b08
4 changed files with 13 additions and 57 deletions
|
@ -1553,15 +1553,8 @@ coh901318_desc_submit(struct coh901318_chan *cohc, struct coh901318_desc *desc)
|
||||||
static struct coh901318_desc *
|
static struct coh901318_desc *
|
||||||
coh901318_first_active_get(struct coh901318_chan *cohc)
|
coh901318_first_active_get(struct coh901318_chan *cohc)
|
||||||
{
|
{
|
||||||
struct coh901318_desc *d;
|
return list_first_entry_or_null(&cohc->active, struct coh901318_desc,
|
||||||
|
node);
|
||||||
if (list_empty(&cohc->active))
|
|
||||||
return NULL;
|
|
||||||
|
|
||||||
d = list_first_entry(&cohc->active,
|
|
||||||
struct coh901318_desc,
|
|
||||||
node);
|
|
||||||
return d;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
@ -1579,15 +1572,8 @@ coh901318_desc_queue(struct coh901318_chan *cohc, struct coh901318_desc *desc)
|
||||||
static struct coh901318_desc *
|
static struct coh901318_desc *
|
||||||
coh901318_first_queued(struct coh901318_chan *cohc)
|
coh901318_first_queued(struct coh901318_chan *cohc)
|
||||||
{
|
{
|
||||||
struct coh901318_desc *d;
|
return list_first_entry_or_null(&cohc->queue, struct coh901318_desc,
|
||||||
|
node);
|
||||||
if (list_empty(&cohc->queue))
|
|
||||||
return NULL;
|
|
||||||
|
|
||||||
d = list_first_entry(&cohc->queue,
|
|
||||||
struct coh901318_desc,
|
|
||||||
node);
|
|
||||||
return d;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline u32 coh901318_get_bytes_in_lli(struct coh901318_lli *in_lli)
|
static inline u32 coh901318_get_bytes_in_lli(struct coh901318_lli *in_lli)
|
||||||
|
|
|
@ -262,10 +262,8 @@ static void ep93xx_dma_set_active(struct ep93xx_dma_chan *edmac,
|
||||||
static struct ep93xx_dma_desc *
|
static struct ep93xx_dma_desc *
|
||||||
ep93xx_dma_get_active(struct ep93xx_dma_chan *edmac)
|
ep93xx_dma_get_active(struct ep93xx_dma_chan *edmac)
|
||||||
{
|
{
|
||||||
if (list_empty(&edmac->active))
|
return list_first_entry_or_null(&edmac->active,
|
||||||
return NULL;
|
struct ep93xx_dma_desc, node);
|
||||||
|
|
||||||
return list_first_entry(&edmac->active, struct ep93xx_dma_desc, node);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -941,15 +941,7 @@ static void d40_desc_load(struct d40_chan *d40c, struct d40_desc *d40d)
|
||||||
|
|
||||||
static struct d40_desc *d40_first_active_get(struct d40_chan *d40c)
|
static struct d40_desc *d40_first_active_get(struct d40_chan *d40c)
|
||||||
{
|
{
|
||||||
struct d40_desc *d;
|
return list_first_entry_or_null(&d40c->active, struct d40_desc, node);
|
||||||
|
|
||||||
if (list_empty(&d40c->active))
|
|
||||||
return NULL;
|
|
||||||
|
|
||||||
d = list_first_entry(&d40c->active,
|
|
||||||
struct d40_desc,
|
|
||||||
node);
|
|
||||||
return d;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* remove desc from current queue and add it to the pending_queue */
|
/* remove desc from current queue and add it to the pending_queue */
|
||||||
|
@ -962,36 +954,18 @@ static void d40_desc_queue(struct d40_chan *d40c, struct d40_desc *desc)
|
||||||
|
|
||||||
static struct d40_desc *d40_first_pending(struct d40_chan *d40c)
|
static struct d40_desc *d40_first_pending(struct d40_chan *d40c)
|
||||||
{
|
{
|
||||||
struct d40_desc *d;
|
return list_first_entry_or_null(&d40c->pending_queue, struct d40_desc,
|
||||||
|
node);
|
||||||
if (list_empty(&d40c->pending_queue))
|
|
||||||
return NULL;
|
|
||||||
|
|
||||||
d = list_first_entry(&d40c->pending_queue,
|
|
||||||
struct d40_desc,
|
|
||||||
node);
|
|
||||||
return d;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static struct d40_desc *d40_first_queued(struct d40_chan *d40c)
|
static struct d40_desc *d40_first_queued(struct d40_chan *d40c)
|
||||||
{
|
{
|
||||||
struct d40_desc *d;
|
return list_first_entry_or_null(&d40c->queue, struct d40_desc, node);
|
||||||
|
|
||||||
if (list_empty(&d40c->queue))
|
|
||||||
return NULL;
|
|
||||||
|
|
||||||
d = list_first_entry(&d40c->queue,
|
|
||||||
struct d40_desc,
|
|
||||||
node);
|
|
||||||
return d;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static struct d40_desc *d40_first_done(struct d40_chan *d40c)
|
static struct d40_desc *d40_first_done(struct d40_chan *d40c)
|
||||||
{
|
{
|
||||||
if (list_empty(&d40c->done))
|
return list_first_entry_or_null(&d40c->done, struct d40_desc, node);
|
||||||
return NULL;
|
|
||||||
|
|
||||||
return list_first_entry(&d40c->done, struct d40_desc, node);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static int d40_psize_2_burst_size(bool is_log, int psize)
|
static int d40_psize_2_burst_size(bool is_log, int psize)
|
||||||
|
|
|
@ -123,10 +123,8 @@ static inline void vchan_cyclic_callback(struct virt_dma_desc *vd)
|
||||||
*/
|
*/
|
||||||
static inline struct virt_dma_desc *vchan_next_desc(struct virt_dma_chan *vc)
|
static inline struct virt_dma_desc *vchan_next_desc(struct virt_dma_chan *vc)
|
||||||
{
|
{
|
||||||
if (list_empty(&vc->desc_issued))
|
return list_first_entry_or_null(&vc->desc_issued,
|
||||||
return NULL;
|
struct virt_dma_desc, node);
|
||||||
|
|
||||||
return list_first_entry(&vc->desc_issued, struct virt_dma_desc, node);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
Loading…
Reference in a new issue