diff options
author | Masahiro Yamada <yamada.masahiro@socionext.com> | 2016-09-12 14:08:17 -0400 |
---|---|---|
committer | Vinod Koul <vinod.koul@intel.com> | 2016-09-14 09:40:46 -0400 |
commit | 360af35b08da9def3be8b67398f4e0f90c292e37 (patch) | |
tree | 8afea3d372107ddc4f45b4c903fad056f58a0626 | |
parent | aa570be6de67f3772cc850a7bfbe659214aa9ee4 (diff) |
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>
-rw-r--r-- | drivers/dma/coh901318.c | 22 | ||||
-rw-r--r-- | drivers/dma/ep93xx_dma.c | 6 | ||||
-rw-r--r-- | drivers/dma/ste_dma40.c | 36 | ||||
-rw-r--r-- | drivers/dma/virt-dma.h | 6 |
4 files changed, 13 insertions, 57 deletions
diff --git a/drivers/dma/coh901318.c b/drivers/dma/coh901318.c index e4acd63e42aa..a373ecacfaba 100644 --- a/drivers/dma/coh901318.c +++ b/drivers/dma/coh901318.c | |||
@@ -1553,15 +1553,8 @@ coh901318_desc_submit(struct coh901318_chan *cohc, struct coh901318_desc *desc) | |||
1553 | static struct coh901318_desc * | 1553 | static struct coh901318_desc * |
1554 | coh901318_first_active_get(struct coh901318_chan *cohc) | 1554 | coh901318_first_active_get(struct coh901318_chan *cohc) |
1555 | { | 1555 | { |
1556 | struct coh901318_desc *d; | 1556 | return list_first_entry_or_null(&cohc->active, struct coh901318_desc, |
1557 | 1557 | node); | |
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; | ||
1565 | } | 1558 | } |
1566 | 1559 | ||
1567 | static void | 1560 | static void |
@@ -1579,15 +1572,8 @@ coh901318_desc_queue(struct coh901318_chan *cohc, struct coh901318_desc *desc) | |||
1579 | static struct coh901318_desc * | 1572 | static struct coh901318_desc * |
1580 | coh901318_first_queued(struct coh901318_chan *cohc) | 1573 | coh901318_first_queued(struct coh901318_chan *cohc) |
1581 | { | 1574 | { |
1582 | struct coh901318_desc *d; | 1575 | return list_first_entry_or_null(&cohc->queue, struct coh901318_desc, |
1583 | 1576 | node); | |
1584 | if (list_empty(&cohc->queue)) | ||
1585 | return NULL; | ||
1586 | |||
1587 | d = list_first_entry(&cohc->queue, | ||
1588 | struct coh901318_desc, | ||
1589 | node); | ||
1590 | return d; | ||
1591 | } | 1577 | } |
1592 | 1578 | ||
1593 | static inline u32 coh901318_get_bytes_in_lli(struct coh901318_lli *in_lli) | 1579 | static inline u32 coh901318_get_bytes_in_lli(struct coh901318_lli *in_lli) |
diff --git a/drivers/dma/ep93xx_dma.c b/drivers/dma/ep93xx_dma.c index 21f08cc3352b..2ffaca25267e 100644 --- a/drivers/dma/ep93xx_dma.c +++ b/drivers/dma/ep93xx_dma.c | |||
@@ -262,10 +262,8 @@ static void ep93xx_dma_set_active(struct ep93xx_dma_chan *edmac, | |||
262 | static struct ep93xx_dma_desc * | 262 | static struct ep93xx_dma_desc * |
263 | ep93xx_dma_get_active(struct ep93xx_dma_chan *edmac) | 263 | ep93xx_dma_get_active(struct ep93xx_dma_chan *edmac) |
264 | { | 264 | { |
265 | if (list_empty(&edmac->active)) | 265 | return list_first_entry_or_null(&edmac->active, |
266 | return NULL; | 266 | struct ep93xx_dma_desc, node); |
267 | |||
268 | return list_first_entry(&edmac->active, struct ep93xx_dma_desc, node); | ||
269 | } | 267 | } |
270 | 268 | ||
271 | /** | 269 | /** |
diff --git a/drivers/dma/ste_dma40.c b/drivers/dma/ste_dma40.c index 8b18e44a02d5..e43d2bbfd122 100644 --- a/drivers/dma/ste_dma40.c +++ b/drivers/dma/ste_dma40.c | |||
@@ -941,15 +941,7 @@ static void d40_desc_load(struct d40_chan *d40c, struct d40_desc *d40d) | |||
941 | 941 | ||
942 | static struct d40_desc *d40_first_active_get(struct d40_chan *d40c) | 942 | static struct d40_desc *d40_first_active_get(struct d40_chan *d40c) |
943 | { | 943 | { |
944 | struct d40_desc *d; | 944 | return list_first_entry_or_null(&d40c->active, struct d40_desc, node); |
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; | ||
953 | } | 945 | } |
954 | 946 | ||
955 | /* remove desc from current queue and add it to the pending_queue */ | 947 | /* 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) | |||
962 | 954 | ||
963 | static struct d40_desc *d40_first_pending(struct d40_chan *d40c) | 955 | static struct d40_desc *d40_first_pending(struct d40_chan *d40c) |
964 | { | 956 | { |
965 | struct d40_desc *d; | 957 | return list_first_entry_or_null(&d40c->pending_queue, struct d40_desc, |
966 | 958 | node); | |
967 | if (list_empty(&d40c->pending_queue)) | ||
968 | return NULL; | ||
969 | |||
970 | d = list_first_entry(&d40c->pending_queue, | ||
971 | struct d40_desc, | ||
972 | node); | ||
973 | return d; | ||
974 | } | 959 | } |
975 | 960 | ||
976 | static struct d40_desc *d40_first_queued(struct d40_chan *d40c) | 961 | static struct d40_desc *d40_first_queued(struct d40_chan *d40c) |
977 | { | 962 | { |
978 | struct d40_desc *d; | 963 | return list_first_entry_or_null(&d40c->queue, struct d40_desc, node); |
979 | |||
980 | if (list_empty(&d40c->queue)) | ||
981 | return NULL; | ||
982 | |||
983 | d = list_first_entry(&d40c->queue, | ||
984 | struct d40_desc, | ||
985 | node); | ||
986 | return d; | ||
987 | } | 964 | } |
988 | 965 | ||
989 | static struct d40_desc *d40_first_done(struct d40_chan *d40c) | 966 | static struct d40_desc *d40_first_done(struct d40_chan *d40c) |
990 | { | 967 | { |
991 | if (list_empty(&d40c->done)) | 968 | return list_first_entry_or_null(&d40c->done, struct d40_desc, node); |
992 | return NULL; | ||
993 | |||
994 | return list_first_entry(&d40c->done, struct d40_desc, node); | ||
995 | } | 969 | } |
996 | 970 | ||
997 | static int d40_psize_2_burst_size(bool is_log, int psize) | 971 | static int d40_psize_2_burst_size(bool is_log, int psize) |
diff --git a/drivers/dma/virt-dma.h b/drivers/dma/virt-dma.h index d9731ca5e262..a030ae7b1df2 100644 --- a/drivers/dma/virt-dma.h +++ b/drivers/dma/virt-dma.h | |||
@@ -123,10 +123,8 @@ static inline void vchan_cyclic_callback(struct virt_dma_desc *vd) | |||
123 | */ | 123 | */ |
124 | static inline struct virt_dma_desc *vchan_next_desc(struct virt_dma_chan *vc) | 124 | static inline struct virt_dma_desc *vchan_next_desc(struct virt_dma_chan *vc) |
125 | { | 125 | { |
126 | if (list_empty(&vc->desc_issued)) | 126 | return list_first_entry_or_null(&vc->desc_issued, |
127 | return NULL; | 127 | struct virt_dma_desc, node); |
128 | |||
129 | return list_first_entry(&vc->desc_issued, struct virt_dma_desc, node); | ||
130 | } | 128 | } |
131 | 129 | ||
132 | /** | 130 | /** |