Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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>

authored by

Masahiro Yamada and committed by
Vinod Koul
360af35b aa570be6

+13 -57
+4 -18
drivers/dma/coh901318.c
··· 1553 1553 static struct coh901318_desc * 1554 1554 coh901318_first_active_get(struct coh901318_chan *cohc) 1555 1555 { 1556 - struct coh901318_desc *d; 1557 - 1558 - if (list_empty(&cohc->active)) 1559 - return NULL; 1560 - 1561 - d = list_first_entry(&cohc->active, 1562 - struct coh901318_desc, 1563 - node); 1564 - return d; 1556 + return list_first_entry_or_null(&cohc->active, struct coh901318_desc, 1557 + node); 1565 1558 } 1566 1559 1567 1560 static void ··· 1572 1579 static struct coh901318_desc * 1573 1580 coh901318_first_queued(struct coh901318_chan *cohc) 1574 1581 { 1575 - struct coh901318_desc *d; 1576 - 1577 - if (list_empty(&cohc->queue)) 1578 - return NULL; 1579 - 1580 - d = list_first_entry(&cohc->queue, 1581 - struct coh901318_desc, 1582 - node); 1583 - return d; 1582 + return list_first_entry_or_null(&cohc->queue, struct coh901318_desc, 1583 + node); 1584 1584 } 1585 1585 1586 1586 static inline u32 coh901318_get_bytes_in_lli(struct coh901318_lli *in_lli)
+2 -4
drivers/dma/ep93xx_dma.c
··· 262 262 static struct ep93xx_dma_desc * 263 263 ep93xx_dma_get_active(struct ep93xx_dma_chan *edmac) 264 264 { 265 - if (list_empty(&edmac->active)) 266 - return NULL; 267 - 268 - return list_first_entry(&edmac->active, struct ep93xx_dma_desc, node); 265 + return list_first_entry_or_null(&edmac->active, 266 + struct ep93xx_dma_desc, node); 269 267 } 270 268 271 269 /**
+5 -31
drivers/dma/ste_dma40.c
··· 941 941 942 942 static struct d40_desc *d40_first_active_get(struct d40_chan *d40c) 943 943 { 944 - struct d40_desc *d; 945 - 946 - if (list_empty(&d40c->active)) 947 - return NULL; 948 - 949 - d = list_first_entry(&d40c->active, 950 - struct d40_desc, 951 - node); 952 - return d; 944 + return list_first_entry_or_null(&d40c->active, struct d40_desc, node); 953 945 } 954 946 955 947 /* remove desc from current queue and add it to the pending_queue */ ··· 954 962 955 963 static struct d40_desc *d40_first_pending(struct d40_chan *d40c) 956 964 { 957 - struct d40_desc *d; 958 - 959 - if (list_empty(&d40c->pending_queue)) 960 - return NULL; 961 - 962 - d = list_first_entry(&d40c->pending_queue, 963 - struct d40_desc, 964 - node); 965 - return d; 965 + return list_first_entry_or_null(&d40c->pending_queue, struct d40_desc, 966 + node); 966 967 } 967 968 968 969 static struct d40_desc *d40_first_queued(struct d40_chan *d40c) 969 970 { 970 - struct d40_desc *d; 971 - 972 - if (list_empty(&d40c->queue)) 973 - return NULL; 974 - 975 - d = list_first_entry(&d40c->queue, 976 - struct d40_desc, 977 - node); 978 - return d; 971 + return list_first_entry_or_null(&d40c->queue, struct d40_desc, node); 979 972 } 980 973 981 974 static struct d40_desc *d40_first_done(struct d40_chan *d40c) 982 975 { 983 - if (list_empty(&d40c->done)) 984 - return NULL; 985 - 986 - return list_first_entry(&d40c->done, struct d40_desc, node); 976 + return list_first_entry_or_null(&d40c->done, struct d40_desc, node); 987 977 } 988 978 989 979 static int d40_psize_2_burst_size(bool is_log, int psize)
+2 -4
drivers/dma/virt-dma.h
··· 123 123 */ 124 124 static inline struct virt_dma_desc *vchan_next_desc(struct virt_dma_chan *vc) 125 125 { 126 - if (list_empty(&vc->desc_issued)) 127 - return NULL; 128 - 129 - return list_first_entry(&vc->desc_issued, struct virt_dma_desc, node); 126 + return list_first_entry_or_null(&vc->desc_issued, 127 + struct virt_dma_desc, node); 130 128 } 131 129 132 130 /**