diff options
| author | Claudiu Beznea <claudiu.beznea.uj@bp.renesas.com> | 2026-05-26 11:46:55 +0300 |
|---|---|---|
| committer | Vinod Koul <vkoul@kernel.org> | 2026-06-04 20:58:31 +0530 |
| commit | 89975baaa9ea2490b75d69842561a32ca888b7e5 (patch) | |
| tree | 438f96be09939919e7e96e502492b054d6a2530c | |
| parent | 5fbf3a2a3b96ef5810e6e0fbc601f82067629bc5 (diff) | |
| download | linux-89975baaa9ea2490b75d69842561a32ca888b7e5.tar.gz linux-89975baaa9ea2490b75d69842561a32ca888b7e5.zip | |
dmaengine: sh: rz-dmac: Use list_first_entry_or_null()
Use list_first_entry_or_null() instead of open-coding it with a
list_empty() check and list_first_entry(). This simplifies the code.
Reviewed-by: Frank Li <Frank.Li@nxp.com>
Tested-by: John Madieu <john.madieu.xa@bp.renesas.com>
Signed-off-by: Claudiu Beznea <claudiu.beznea.uj@bp.renesas.com>
Tested-by: Tommaso Merciai <tommaso.merciai.xr@bp.renesas.com>
Link: https://patch.msgid.link/20260526084710.3491480-4-claudiu.beznea@kernel.org
Signed-off-by: Vinod Koul <vkoul@kernel.org>
| -rw-r--r-- | drivers/dma/sh/rz-dmac.c | 10 |
1 files changed, 4 insertions, 6 deletions
diff --git a/drivers/dma/sh/rz-dmac.c b/drivers/dma/sh/rz-dmac.c index 6d80cb668957..1717b407ab9e 100644 --- a/drivers/dma/sh/rz-dmac.c +++ b/drivers/dma/sh/rz-dmac.c @@ -503,11 +503,10 @@ rz_dmac_prep_dma_memcpy(struct dma_chan *chan, dma_addr_t dest, dma_addr_t src, __func__, channel->index, &src, &dest, len); scoped_guard(spinlock_irqsave, &channel->vc.lock) { - if (list_empty(&channel->ld_free)) + desc = list_first_entry_or_null(&channel->ld_free, struct rz_dmac_desc, node); + if (!desc) return NULL; - desc = list_first_entry(&channel->ld_free, struct rz_dmac_desc, node); - desc->type = RZ_DMAC_DESC_MEMCPY; desc->src = src; desc->dest = dest; @@ -533,11 +532,10 @@ rz_dmac_prep_slave_sg(struct dma_chan *chan, struct scatterlist *sgl, int i = 0; scoped_guard(spinlock_irqsave, &channel->vc.lock) { - if (list_empty(&channel->ld_free)) + desc = list_first_entry_or_null(&channel->ld_free, struct rz_dmac_desc, node); + if (!desc) return NULL; - desc = list_first_entry(&channel->ld_free, struct rz_dmac_desc, node); - for_each_sg(sgl, sg, sg_len, i) dma_length += sg_dma_len(sg); |
