ipq806x: ArcherC2600: devictree cleanup
[oweals/openwrt.git] / target / linux / apm821xx / patches-4.4 / 010-dmaengine-Add-transfer-termination-synchronization-s.patch
1 From 7bd903c5ca47fde5ad52370a47776491813c772e Mon Sep 17 00:00:00 2001
2 From: Peter Ujfalusi <peter.ujfalusi@ti.com>
3 Date: Mon, 14 Dec 2015 22:47:39 +0200
4 Subject: [PATCH 1/3] dmaengine: core: Move and merge the code paths using
5  private_candidate
6
7 Channel matching with private_candidate() is used in two paths, the error
8 checking is slightly different in them and they are duplicating code also.
9 Move the code under find_candidate() to provide consistent execution and
10 going to allow us to reuse this mode of channel lookup later.
11
12 Signed-off-by: Peter Ujfalusi <peter.ujfalusi@ti.com>
13 Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.com>
14 Reviewed-by: Arnd Bergmann <arnd@arndb.de>
15 Signed-off-by: Vinod Koul <vinod.koul@intel.com>
16 ---
17  drivers/dma/dmaengine.c | 81 +++++++++++++++++++++++++------------------------
18  1 file changed, 42 insertions(+), 39 deletions(-)
19
20 --- a/drivers/dma/dmaengine.c
21 +++ b/drivers/dma/dmaengine.c
22 @@ -542,6 +542,42 @@ static struct dma_chan *private_candidat
23         return NULL;
24  }
25  
26 +static struct dma_chan *find_candidate(struct dma_device *device,
27 +                                      const dma_cap_mask_t *mask,
28 +                                      dma_filter_fn fn, void *fn_param)
29 +{
30 +       struct dma_chan *chan = private_candidate(mask, device, fn, fn_param);
31 +       int err;
32 +
33 +       if (chan) {
34 +               /* Found a suitable channel, try to grab, prep, and return it.
35 +                * We first set DMA_PRIVATE to disable balance_ref_count as this
36 +                * channel will not be published in the general-purpose
37 +                * allocator
38 +                */
39 +               dma_cap_set(DMA_PRIVATE, device->cap_mask);
40 +               device->privatecnt++;
41 +               err = dma_chan_get(chan);
42 +
43 +               if (err) {
44 +                       if (err == -ENODEV) {
45 +                               pr_debug("%s: %s module removed\n", __func__,
46 +                                        dma_chan_name(chan));
47 +                               list_del_rcu(&device->global_node);
48 +                       } else
49 +                               pr_debug("%s: failed to get %s: (%d)\n",
50 +                                        __func__, dma_chan_name(chan), err);
51 +
52 +                       if (--device->privatecnt == 0)
53 +                               dma_cap_clear(DMA_PRIVATE, device->cap_mask);
54 +
55 +                       chan = ERR_PTR(err);
56 +               }
57 +       }
58 +
59 +       return chan ? chan : ERR_PTR(-EPROBE_DEFER);
60 +}
61 +
62  /**
63   * dma_get_slave_channel - try to get specific channel exclusively
64   * @chan: target channel
65 @@ -580,7 +616,6 @@ struct dma_chan *dma_get_any_slave_chann
66  {
67         dma_cap_mask_t mask;
68         struct dma_chan *chan;
69 -       int err;
70  
71         dma_cap_zero(mask);
72         dma_cap_set(DMA_SLAVE, mask);
73 @@ -588,23 +623,11 @@ struct dma_chan *dma_get_any_slave_chann
74         /* lock against __dma_request_channel */
75         mutex_lock(&dma_list_mutex);
76  
77 -       chan = private_candidate(&mask, device, NULL, NULL);
78 -       if (chan) {
79 -               dma_cap_set(DMA_PRIVATE, device->cap_mask);
80 -               device->privatecnt++;
81 -               err = dma_chan_get(chan);
82 -               if (err) {
83 -                       pr_debug("%s: failed to get %s: (%d)\n",
84 -                               __func__, dma_chan_name(chan), err);
85 -                       chan = NULL;
86 -                       if (--device->privatecnt == 0)
87 -                               dma_cap_clear(DMA_PRIVATE, device->cap_mask);
88 -               }
89 -       }
90 +       chan = find_candidate(device, &mask, NULL, NULL);
91  
92         mutex_unlock(&dma_list_mutex);
93  
94 -       return chan;
95 +       return IS_ERR(chan) ? NULL : chan;
96  }
97  EXPORT_SYMBOL_GPL(dma_get_any_slave_channel);
98  
99 @@ -621,35 +644,15 @@ struct dma_chan *__dma_request_channel(c
100  {
101         struct dma_device *device, *_d;
102         struct dma_chan *chan = NULL;
103 -       int err;
104  
105         /* Find a channel */
106         mutex_lock(&dma_list_mutex);
107         list_for_each_entry_safe(device, _d, &dma_device_list, global_node) {
108 -               chan = private_candidate(mask, device, fn, fn_param);
109 -               if (chan) {
110 -                       /* Found a suitable channel, try to grab, prep, and
111 -                        * return it.  We first set DMA_PRIVATE to disable
112 -                        * balance_ref_count as this channel will not be
113 -                        * published in the general-purpose allocator
114 -                        */
115 -                       dma_cap_set(DMA_PRIVATE, device->cap_mask);
116 -                       device->privatecnt++;
117 -                       err = dma_chan_get(chan);
118 +               chan = find_candidate(device, mask, fn, fn_param);
119 +               if (!IS_ERR(chan))
120 +                       break;
121  
122 -                       if (err == -ENODEV) {
123 -                               pr_debug("%s: %s module removed\n",
124 -                                        __func__, dma_chan_name(chan));
125 -                               list_del_rcu(&device->global_node);
126 -                       } else if (err)
127 -                               pr_debug("%s: failed to get %s: (%d)\n",
128 -                                        __func__, dma_chan_name(chan), err);
129 -                       else
130 -                               break;
131 -                       if (--device->privatecnt == 0)
132 -                               dma_cap_clear(DMA_PRIVATE, device->cap_mask);
133 -                       chan = NULL;
134 -               }
135 +               chan = NULL;
136         }
137         mutex_unlock(&dma_list_mutex);
138