ipq806x: enable PM support
[librecmc/librecmc.git] / target / linux / ipq806x / patches-3.18 / 152-dmaengine-Make-channel-allocation-callbacks-optional.patch
1 From c4b54a648e682f678c338619df848233a6babc46 Mon Sep 17 00:00:00 2001
2 From: Maxime Ripard <maxime.ripard@free-electrons.com>
3 Date: Mon, 17 Nov 2014 14:41:59 +0100
4 Subject: [PATCH] dmaengine: Make channel allocation callbacks optional
5
6 Nowadays, some drivers don't have anything in there channel allocation
7 callbacks anymore.
8
9 Remove the BUG_ON if those callbacks aren't implemented, in order to allow
10 drivers to not implement them.
11
12 Signed-off-by: Maxime Ripard <maxime.ripard@free-electrons.com>
13 Acked-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
14 Signed-off-by: Vinod Koul <vinod.koul@intel.com>
15 ---
16  drivers/dma/dmaengine.c | 18 +++++++++++-------
17  1 file changed, 11 insertions(+), 7 deletions(-)
18
19 --- a/drivers/dma/dmaengine.c
20 +++ b/drivers/dma/dmaengine.c
21 @@ -235,9 +235,11 @@ static int dma_chan_get(struct dma_chan
22                 return -ENODEV;
23  
24         /* allocate upon first client reference */
25 -       ret = chan->device->device_alloc_chan_resources(chan);
26 -       if (ret < 0)
27 -               goto err_out;
28 +       if (chan->device->device_alloc_chan_resources) {
29 +               ret = chan->device->device_alloc_chan_resources(chan);
30 +               if (ret < 0)
31 +                       goto err_out;
32 +       }
33  
34         if (!dma_has_cap(DMA_PRIVATE, chan->device->cap_mask))
35                 balance_ref_count(chan);
36 @@ -259,11 +261,15 @@ err_out:
37   */
38  static void dma_chan_put(struct dma_chan *chan)
39  {
40 +       /* This channel is not in use, bail out */
41         if (!chan->client_count)
42 -               return; /* this channel failed alloc_chan_resources */
43 +               return;
44 +
45         chan->client_count--;
46         module_put(dma_chan_to_owner(chan));
47 -       if (chan->client_count == 0)
48 +
49 +       /* This channel is not in use anymore, free it */
50 +       if (!chan->client_count && chan->device->device_free_chan_resources)
51                 chan->device->device_free_chan_resources(chan);
52  }
53  
54 @@ -817,8 +823,6 @@ int dma_async_device_register(struct dma
55         BUG_ON(dma_has_cap(DMA_INTERLEAVE, device->cap_mask) &&
56                 !device->device_prep_interleaved_dma);
57  
58 -       BUG_ON(!device->device_alloc_chan_resources);
59 -       BUG_ON(!device->device_free_chan_resources);
60         BUG_ON(!device->device_tx_status);
61         BUG_ON(!device->device_issue_pending);
62         BUG_ON(!device->dev);