]> pilppa.org Git - linux-2.6-omap-h63xx.git/blobdiff - drivers/dma/dmaengine.c
Merge commit 'v2.6.29-rc4' into x86/cleanups
[linux-2.6-omap-h63xx.git] / drivers / dma / dmaengine.c
index dd43410c10193e920f1adfbcf96257b0c0502c50..a58993011edb4bc369a39b6caed0a93f62dc44a8 100644 (file)
@@ -318,7 +318,7 @@ static int __init dma_channel_table_init(void)
 
        return err;
 }
-subsys_initcall(dma_channel_table_init);
+arch_initcall(dma_channel_table_init);
 
 /**
  * dma_find_channel - find a channel to carry out the operation
@@ -329,9 +329,6 @@ struct dma_chan *dma_find_channel(enum dma_transaction_type tx_type)
        struct dma_chan *chan;
        int cpu;
 
-       WARN_ONCE(dmaengine_ref_count == 0,
-                 "client called %s without a reference", __func__);
-
        cpu = get_cpu();
        chan = per_cpu_ptr(channel_table[tx_type], cpu)->chan;
        put_cpu();
@@ -348,9 +345,6 @@ void dma_issue_pending_all(void)
        struct dma_device *device;
        struct dma_chan *chan;
 
-       WARN_ONCE(dmaengine_ref_count == 0,
-                 "client called %s without a reference", __func__);
-
        rcu_read_lock();
        list_for_each_entry_rcu(device, &dma_device_list, global_node) {
                if (dma_has_cap(DMA_PRIVATE, device->cap_mask))
@@ -454,10 +448,10 @@ static void dma_channel_rebalance(void)
                }
 }
 
-static struct dma_chan *private_candidate(dma_cap_mask_t *mask, struct dma_device *dev)
+static struct dma_chan *private_candidate(dma_cap_mask_t *mask, struct dma_device *dev,
+                                         dma_filter_fn fn, void *fn_param)
 {
        struct dma_chan *chan;
-       struct dma_chan *ret = NULL;
 
        if (!__dma_device_satisfies_mask(dev, mask)) {
                pr_debug("%s: wrong capabilities\n", __func__);
@@ -479,11 +473,15 @@ static struct dma_chan *private_candidate(dma_cap_mask_t *mask, struct dma_devic
                                 __func__, dma_chan_name(chan));
                        continue;
                }
-               ret = chan;
-               break;
+               if (fn && !fn(chan, fn_param)) {
+                       pr_debug("%s: %s filter said false\n",
+                                __func__, dma_chan_name(chan));
+                       continue;
+               }
+               return chan;
        }
 
-       return ret;
+       return NULL;
 }
 
 /**
@@ -496,22 +494,13 @@ struct dma_chan *__dma_request_channel(dma_cap_mask_t *mask, dma_filter_fn fn, v
 {
        struct dma_device *device, *_d;
        struct dma_chan *chan = NULL;
-       bool ack;
        int err;
 
        /* Find a channel */
        mutex_lock(&dma_list_mutex);
        list_for_each_entry_safe(device, _d, &dma_device_list, global_node) {
-               chan = private_candidate(mask, device);
-               if (!chan)
-                       continue;
-
-               if (fn)
-                       ack = fn(chan, fn_param);
-               else
-                       ack = true;
-
-               if (ack) {
+               chan = private_candidate(mask, device, fn, fn_param);
+               if (chan) {
                        /* Found a suitable channel, try to grab, prep, and
                         * return it.  We first set DMA_PRIVATE to disable
                         * balance_ref_count as this channel will not be
@@ -529,10 +518,8 @@ struct dma_chan *__dma_request_channel(dma_cap_mask_t *mask, dma_filter_fn fn, v
                                       dma_chan_name(chan), err);
                        else
                                break;
-               } else
-                       pr_debug("%s: %s filter said false\n",
-                                __func__, dma_chan_name(chan));
-               chan = NULL;
+                       chan = NULL;
+               }
        }
        mutex_unlock(&dma_list_mutex);
 
@@ -968,6 +955,8 @@ void dma_run_dependencies(struct dma_async_tx_descriptor *tx)
        if (!dep)
                return;
 
+       /* we'll submit tx->next now, so clear the link */
+       tx->next = NULL;
        chan = dep->chan;
 
        /* keep submitting up until a channel switch is detected
@@ -997,6 +986,6 @@ static int __init dma_bus_init(void)
        mutex_init(&dma_list_mutex);
        return class_register(&dma_devclass);
 }
-subsys_initcall(dma_bus_init);
+arch_initcall(dma_bus_init);