aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/dma
diff options
context:
space:
mode:
authorLars-Peter Clausen <lars@metafoo.de>2014-01-11 14:08:39 -0500
committerVinod Koul <vinod.koul@intel.com>2014-01-20 03:20:49 -0500
commit70cbb163de1c6de239375b967caf372a98fae935 (patch)
treecdbd3ca9e589a289ef358f3df060f6a36d1361a7 /drivers/dma
parent04abf5daf7df852566e5a4782d5954daa40e2542 (diff)
dma: pl330: Use dma_get_slave_channel() in the of xlate callback
Currently the driver uses dma_request_channel() with a custom filter function to find the requested channel. This will loop over all available channels until the one we want has been found, but we already know which channel we want to request, so we can dma_get_slave_channel(). This also makes the code a bit shorter cleaner. Signed-off-by: Lars-Peter Clausen <lars@metafoo.de> Signed-off-by: Vinod Koul <vinod.koul@intel.com>
Diffstat (limited to 'drivers/dma')
-rw-r--r--drivers/dma/pl330.c35
1 files changed, 8 insertions, 27 deletions
diff --git a/drivers/dma/pl330.c b/drivers/dma/pl330.c
index 8e018a221f19..5b2ba38b903f 100644
--- a/drivers/dma/pl330.c
+++ b/drivers/dma/pl330.c
@@ -589,6 +589,7 @@ struct dma_pl330_dmac {
589 spinlock_t pool_lock; 589 spinlock_t pool_lock;
590 590
591 /* Peripheral channels connected to this DMAC */ 591 /* Peripheral channels connected to this DMAC */
592 unsigned int num_peripherals;
592 struct dma_pl330_chan *peripherals; /* keep at end */ 593 struct dma_pl330_chan *peripherals; /* keep at end */
593}; 594};
594 595
@@ -611,11 +612,6 @@ struct dma_pl330_desc {
611 struct dma_pl330_chan *pchan; 612 struct dma_pl330_chan *pchan;
612}; 613};
613 614
614struct dma_pl330_filter_args {
615 struct dma_pl330_dmac *pdmac;
616 unsigned int chan_id;
617};
618
619static inline void _callback(struct pl330_req *r, enum pl330_op_err err) 615static inline void _callback(struct pl330_req *r, enum pl330_op_err err)
620{ 616{
621 if (r && r->xfer_cb) 617 if (r && r->xfer_cb)
@@ -2303,16 +2299,6 @@ static void dma_pl330_rqcb(void *token, enum pl330_op_err err)
2303 tasklet_schedule(&pch->task); 2299 tasklet_schedule(&pch->task);
2304} 2300}
2305 2301
2306static bool pl330_dt_filter(struct dma_chan *chan, void *param)
2307{
2308 struct dma_pl330_filter_args *fargs = param;
2309
2310 if (chan->device != &fargs->pdmac->ddma)
2311 return false;
2312
2313 return (chan->chan_id == fargs->chan_id);
2314}
2315
2316bool pl330_filter(struct dma_chan *chan, void *param) 2302bool pl330_filter(struct dma_chan *chan, void *param)
2317{ 2303{
2318 u8 *peri_id; 2304 u8 *peri_id;
@@ -2330,23 +2316,16 @@ static struct dma_chan *of_dma_pl330_xlate(struct of_phandle_args *dma_spec,
2330{ 2316{
2331 int count = dma_spec->args_count; 2317 int count = dma_spec->args_count;
2332 struct dma_pl330_dmac *pdmac = ofdma->of_dma_data; 2318 struct dma_pl330_dmac *pdmac = ofdma->of_dma_data;
2333 struct dma_pl330_filter_args fargs; 2319 unsigned int chan_id;
2334 dma_cap_mask_t cap;
2335
2336 if (!pdmac)
2337 return NULL;
2338 2320
2339 if (count != 1) 2321 if (count != 1)
2340 return NULL; 2322 return NULL;
2341 2323
2342 fargs.pdmac = pdmac; 2324 chan_id = dma_spec->args[0];
2343 fargs.chan_id = dma_spec->args[0]; 2325 if (chan_id >= pdmac->num_peripherals)
2344 2326 return NULL;
2345 dma_cap_zero(cap);
2346 dma_cap_set(DMA_SLAVE, cap);
2347 dma_cap_set(DMA_CYCLIC, cap);
2348 2327
2349 return dma_request_channel(cap, pl330_dt_filter, &fargs); 2328 return dma_get_slave_channel(&pdmac->peripherals[chan_id].chan);
2350} 2329}
2351 2330
2352static int pl330_alloc_chan_resources(struct dma_chan *chan) 2331static int pl330_alloc_chan_resources(struct dma_chan *chan)
@@ -2980,6 +2959,8 @@ pl330_probe(struct amba_device *adev, const struct amba_id *id)
2980 else 2959 else
2981 num_chan = max_t(int, pi->pcfg.num_peri, pi->pcfg.num_chan); 2960 num_chan = max_t(int, pi->pcfg.num_peri, pi->pcfg.num_chan);
2982 2961
2962 pdmac->num_peripherals = num_chan;
2963
2983 pdmac->peripherals = kzalloc(num_chan * sizeof(*pch), GFP_KERNEL); 2964 pdmac->peripherals = kzalloc(num_chan * sizeof(*pch), GFP_KERNEL);
2984 if (!pdmac->peripherals) { 2965 if (!pdmac->peripherals) {
2985 ret = -ENOMEM; 2966 ret = -ENOMEM;