diff options
author | Maxime Ripard <maxime.ripard@free-electrons.com> | 2014-11-17 08:41:59 -0500 |
---|---|---|
committer | Vinod Koul <vinod.koul@intel.com> | 2014-12-22 01:58:55 -0500 |
commit | c4b54a648e682f678c338619df848233a6babc46 (patch) | |
tree | 232c90d21a2f954908c5d8e0121c9a61445f6d73 /drivers/dma/dmaengine.c | |
parent | d2f4f99db3e9ec8b063cf2e45704e2bb95428317 (diff) |
dmaengine: Make channel allocation callbacks optional
Nowadays, some drivers don't have anything in there channel allocation
callbacks anymore.
Remove the BUG_ON if those callbacks aren't implemented, in order to allow
drivers to not implement them.
Signed-off-by: Maxime Ripard <maxime.ripard@free-electrons.com>
Acked-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Vinod Koul <vinod.koul@intel.com>
Diffstat (limited to 'drivers/dma/dmaengine.c')
-rw-r--r-- | drivers/dma/dmaengine.c | 18 |
1 files changed, 11 insertions, 7 deletions
diff --git a/drivers/dma/dmaengine.c b/drivers/dma/dmaengine.c index a5da0e147560..b7f09f63a160 100644 --- a/drivers/dma/dmaengine.c +++ b/drivers/dma/dmaengine.c | |||
@@ -235,9 +235,11 @@ static int dma_chan_get(struct dma_chan *chan) | |||
235 | return -ENODEV; | 235 | return -ENODEV; |
236 | 236 | ||
237 | /* allocate upon first client reference */ | 237 | /* allocate upon first client reference */ |
238 | ret = chan->device->device_alloc_chan_resources(chan); | 238 | if (chan->device->device_alloc_chan_resources) { |
239 | if (ret < 0) | 239 | ret = chan->device->device_alloc_chan_resources(chan); |
240 | goto err_out; | 240 | if (ret < 0) |
241 | goto err_out; | ||
242 | } | ||
241 | 243 | ||
242 | if (!dma_has_cap(DMA_PRIVATE, chan->device->cap_mask)) | 244 | if (!dma_has_cap(DMA_PRIVATE, chan->device->cap_mask)) |
243 | balance_ref_count(chan); | 245 | balance_ref_count(chan); |
@@ -259,11 +261,15 @@ err_out: | |||
259 | */ | 261 | */ |
260 | static void dma_chan_put(struct dma_chan *chan) | 262 | static void dma_chan_put(struct dma_chan *chan) |
261 | { | 263 | { |
264 | /* This channel is not in use, bail out */ | ||
262 | if (!chan->client_count) | 265 | if (!chan->client_count) |
263 | return; /* this channel failed alloc_chan_resources */ | 266 | return; |
267 | |||
264 | chan->client_count--; | 268 | chan->client_count--; |
265 | module_put(dma_chan_to_owner(chan)); | 269 | module_put(dma_chan_to_owner(chan)); |
266 | if (chan->client_count == 0) | 270 | |
271 | /* This channel is not in use anymore, free it */ | ||
272 | if (!chan->client_count && chan->device->device_free_chan_resources) | ||
267 | chan->device->device_free_chan_resources(chan); | 273 | chan->device->device_free_chan_resources(chan); |
268 | } | 274 | } |
269 | 275 | ||
@@ -818,8 +824,6 @@ int dma_async_device_register(struct dma_device *device) | |||
818 | BUG_ON(dma_has_cap(DMA_INTERLEAVE, device->cap_mask) && | 824 | BUG_ON(dma_has_cap(DMA_INTERLEAVE, device->cap_mask) && |
819 | !device->device_prep_interleaved_dma); | 825 | !device->device_prep_interleaved_dma); |
820 | 826 | ||
821 | BUG_ON(!device->device_alloc_chan_resources); | ||
822 | BUG_ON(!device->device_free_chan_resources); | ||
823 | BUG_ON(!device->device_tx_status); | 827 | BUG_ON(!device->device_tx_status); |
824 | BUG_ON(!device->device_issue_pending); | 828 | BUG_ON(!device->device_issue_pending); |
825 | BUG_ON(!device->dev); | 829 | BUG_ON(!device->dev); |