diff options
Diffstat (limited to 'drivers/dma/pl330.c')
-rw-r--r-- | drivers/dma/pl330.c | 35 |
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 | ||
614 | struct dma_pl330_filter_args { | ||
615 | struct dma_pl330_dmac *pdmac; | ||
616 | unsigned int chan_id; | ||
617 | }; | ||
618 | |||
619 | static inline void _callback(struct pl330_req *r, enum pl330_op_err err) | 615 | static 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 | ||
2306 | static 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 | |||
2316 | bool pl330_filter(struct dma_chan *chan, void *param) | 2302 | bool 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 | ||
2352 | static int pl330_alloc_chan_resources(struct dma_chan *chan) | 2331 | static 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; |