Merge branch 'printk-cleanups'
[cascardo/linux.git] / drivers / dma / ste_dma40.c
index a4f965f..8684d11 100644 (file)
@@ -874,7 +874,7 @@ static void d40_log_lli_to_lcxa(struct d40_chan *chan, struct d40_desc *desc)
        }
 
        if (curr_lcla < 0)
-               goto out;
+               goto set_current;
 
        for (; lli_current < lli_len; lli_current++) {
                unsigned int lcla_offset = chan->phy_chan->num * 1024 +
@@ -925,8 +925,7 @@ static void d40_log_lli_to_lcxa(struct d40_chan *chan, struct d40_desc *desc)
                        break;
                }
        }
-
-out:
+ set_current:
        desc->lli_current = lli_current;
 }
 
@@ -941,15 +940,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)
 {
-       struct d40_desc *d;
-
-       if (list_empty(&d40c->active))
-               return NULL;
-
-       d = list_first_entry(&d40c->active,
-                            struct d40_desc,
-                            node);
-       return d;
+       return list_first_entry_or_null(&d40c->active, struct d40_desc, node);
 }
 
 /* remove desc from current queue and add it to the pending_queue */
@@ -962,36 +953,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)
 {
-       struct d40_desc *d;
-
-       if (list_empty(&d40c->pending_queue))
-               return NULL;
-
-       d = list_first_entry(&d40c->pending_queue,
-                            struct d40_desc,
-                            node);
-       return d;
+       return list_first_entry_or_null(&d40c->pending_queue, struct d40_desc,
+                                       node);
 }
 
 static struct d40_desc *d40_first_queued(struct d40_chan *d40c)
 {
-       struct d40_desc *d;
-
-       if (list_empty(&d40c->queue))
-               return NULL;
-
-       d = list_first_entry(&d40c->queue,
-                            struct d40_desc,
-                            node);
-       return d;
+       return list_first_entry_or_null(&d40c->queue, struct d40_desc, node);
 }
 
 static struct d40_desc *d40_first_done(struct d40_chan *d40c)
 {
-       if (list_empty(&d40c->done))
-               return NULL;
-
-       return list_first_entry(&d40c->done, struct d40_desc, node);
+       return list_first_entry_or_null(&d40c->done, struct d40_desc, node);
 }
 
 static int d40_psize_2_burst_size(bool is_log, int psize)
@@ -1083,7 +1056,7 @@ static int __d40_execute_command_phy(struct d40_chan *d40c,
                        D40_CHAN_POS(d40c->phy_chan->num);
 
                if (status == D40_DMA_SUSPENDED || status == D40_DMA_STOP)
-                       goto done;
+                       goto unlock;
        }
 
        wmask = 0xffffffff & ~(D40_CHAN_POS_MASK(d40c->phy_chan->num));
@@ -1119,7 +1092,7 @@ static int __d40_execute_command_phy(struct d40_chan *d40c,
                }
 
        }
-done:
+ unlock:
        spin_unlock_irqrestore(&d40c->base->execmd_lock, flags);
        return ret;
 }
@@ -1596,8 +1569,7 @@ static void dma_tasklet(unsigned long data)
        struct d40_desc *d40d;
        unsigned long flags;
        bool callback_active;
-       dma_async_tx_callback callback;
-       void *callback_param;
+       struct dmaengine_desc_callback cb;
 
        spin_lock_irqsave(&d40c->lock, flags);
 
@@ -1607,7 +1579,7 @@ static void dma_tasklet(unsigned long data)
                /* Check if we have reached here for cyclic job */
                d40d = d40_first_active_get(d40c);
                if (d40d == NULL || !d40d->cyclic)
-                       goto err;
+                       goto check_pending_tx;
        }
 
        if (!d40d->cyclic)
@@ -1624,8 +1596,7 @@ static void dma_tasklet(unsigned long data)
 
        /* Callback to client */
        callback_active = !!(d40d->txd.flags & DMA_PREP_INTERRUPT);
-       callback = d40d->txd.callback;
-       callback_param = d40d->txd.callback_param;
+       dmaengine_desc_get_callback(&d40d->txd, &cb);
 
        if (!d40d->cyclic) {
                if (async_tx_test_ack(&d40d->txd)) {
@@ -1646,12 +1617,11 @@ static void dma_tasklet(unsigned long data)
 
        spin_unlock_irqrestore(&d40c->lock, flags);
 
-       if (callback_active && callback)
-               callback(callback_param);
+       if (callback_active)
+               dmaengine_desc_callback_invoke(&cb, NULL);
 
        return;
-
-err:
+ check_pending_tx:
        /* Rescue manouver if receiving double interrupts */
        if (d40c->pending_tx > 0)
                d40c->pending_tx--;
@@ -1780,42 +1750,40 @@ static bool d40_alloc_mask_set(struct d40_phy_res *phy,
                    phy->allocated_dst == D40_ALLOC_FREE) {
                        phy->allocated_dst = D40_ALLOC_PHY;
                        phy->allocated_src = D40_ALLOC_PHY;
-                       goto found;
+                       goto found_unlock;
                } else
-                       goto not_found;
+                       goto not_found_unlock;
        }
 
        /* Logical channel */
        if (is_src) {
                if (phy->allocated_src == D40_ALLOC_PHY)
-                       goto not_found;
+                       goto not_found_unlock;
 
                if (phy->allocated_src == D40_ALLOC_FREE)
                        phy->allocated_src = D40_ALLOC_LOG_FREE;
 
                if (!(phy->allocated_src & BIT(log_event_line))) {
                        phy->allocated_src |= BIT(log_event_line);
-                       goto found;
+                       goto found_unlock;
                } else
-                       goto not_found;
+                       goto not_found_unlock;
        } else {
                if (phy->allocated_dst == D40_ALLOC_PHY)
-                       goto not_found;
+                       goto not_found_unlock;
 
                if (phy->allocated_dst == D40_ALLOC_FREE)
                        phy->allocated_dst = D40_ALLOC_LOG_FREE;
 
                if (!(phy->allocated_dst & BIT(log_event_line))) {
                        phy->allocated_dst |= BIT(log_event_line);
-                       goto found;
-               } else
-                       goto not_found;
+                       goto found_unlock;
+               }
        }
-
-not_found:
+ not_found_unlock:
        spin_unlock_irqrestore(&phy->lock, flags);
        return false;
-found:
+ found_unlock:
        spin_unlock_irqrestore(&phy->lock, flags);
        return true;
 }