152-dmaengine-Make-channel-allocation-callbacks-optional.patch 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  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. Nowadays, some drivers don't have anything in there channel allocation
  6. callbacks anymore.
  7. Remove the BUG_ON if those callbacks aren't implemented, in order to allow
  8. drivers to not implement them.
  9. Signed-off-by: Maxime Ripard <maxime.ripard@free-electrons.com>
  10. Acked-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
  11. Signed-off-by: Vinod Koul <vinod.koul@intel.com>
  12. ---
  13. drivers/dma/dmaengine.c | 18 +++++++++++-------
  14. 1 file changed, 11 insertions(+), 7 deletions(-)
  15. --- a/drivers/dma/dmaengine.c
  16. +++ b/drivers/dma/dmaengine.c
  17. @@ -235,9 +235,11 @@ static int dma_chan_get(struct dma_chan
  18. return -ENODEV;
  19. /* allocate upon first client reference */
  20. - ret = chan->device->device_alloc_chan_resources(chan);
  21. - if (ret < 0)
  22. - goto err_out;
  23. + if (chan->device->device_alloc_chan_resources) {
  24. + ret = chan->device->device_alloc_chan_resources(chan);
  25. + if (ret < 0)
  26. + goto err_out;
  27. + }
  28. if (!dma_has_cap(DMA_PRIVATE, chan->device->cap_mask))
  29. balance_ref_count(chan);
  30. @@ -259,11 +261,15 @@ err_out:
  31. */
  32. static void dma_chan_put(struct dma_chan *chan)
  33. {
  34. + /* This channel is not in use, bail out */
  35. if (!chan->client_count)
  36. - return; /* this channel failed alloc_chan_resources */
  37. + return;
  38. +
  39. chan->client_count--;
  40. module_put(dma_chan_to_owner(chan));
  41. - if (chan->client_count == 0)
  42. +
  43. + /* This channel is not in use anymore, free it */
  44. + if (!chan->client_count && chan->device->device_free_chan_resources)
  45. chan->device->device_free_chan_resources(chan);
  46. }
  47. @@ -817,8 +823,6 @@ int dma_async_device_register(struct dma
  48. BUG_ON(dma_has_cap(DMA_INTERLEAVE, device->cap_mask) &&
  49. !device->device_prep_interleaved_dma);
  50. - BUG_ON(!device->device_alloc_chan_resources);
  51. - BUG_ON(!device->device_free_chan_resources);
  52. BUG_ON(!device->device_tx_status);
  53. BUG_ON(!device->device_issue_pending);
  54. BUG_ON(!device->dev);