Commit 65ad6060 authored by Lars-Peter Clausen's avatar Lars-Peter Clausen Committed by Vinod Koul

dmaengine: pl330: Change type pl330_chid from void * to struct pl330_thread *

The pl330_chid field of the dma_pl330_chan struct always holds a pointer to the
thread that is associated with the channel. Changing its type form void * to
struct pl330_thread makes things more type safe and removes the need for
unnecessary typecasts. While we are at it also rename the field from the cryptic
pl330_chid to thread.
Signed-off-by: default avatarLars-Peter Clausen <lars@metafoo.de>
Signed-off-by: default avatarVinod Koul <vinod.koul@intel.com>
parent 6079d38c
...@@ -495,10 +495,11 @@ struct dma_pl330_chan { ...@@ -495,10 +495,11 @@ struct dma_pl330_chan {
/* To protect channel manipulation */ /* To protect channel manipulation */
spinlock_t lock; spinlock_t lock;
/* Token of a hardware channel thread of PL330 DMAC /*
* NULL if the channel is available to be acquired. * Hardware channel thread of PL330 DMAC. NULL if the channel is
* available.
*/ */
void *pl330_chid; struct pl330_thread *thread;
/* For D-to-M and M-to-D channels */ /* For D-to-M and M-to-D channels */
int burst_sz; /* the peripheral fifo width */ int burst_sz; /* the peripheral fifo width */
...@@ -1439,9 +1440,8 @@ static inline bool _is_valid(u32 ccr) ...@@ -1439,9 +1440,8 @@ static inline bool _is_valid(u32 ccr)
* Client is not notified after each xfer unit, just once after all * Client is not notified after each xfer unit, just once after all
* xfer units are done or some error occurs. * xfer units are done or some error occurs.
*/ */
static int pl330_submit_req(void *ch_id, struct pl330_req *r) static int pl330_submit_req(struct pl330_thread *thrd, struct pl330_req *r)
{ {
struct pl330_thread *thrd = ch_id;
struct pl330_dmac *pl330; struct pl330_dmac *pl330;
struct pl330_info *pi; struct pl330_info *pi;
struct _xfer_spec xs; struct _xfer_spec xs;
...@@ -1719,9 +1719,8 @@ static int pl330_update(const struct pl330_info *pi) ...@@ -1719,9 +1719,8 @@ static int pl330_update(const struct pl330_info *pi)
return ret; return ret;
} }
static int pl330_chan_ctrl(void *ch_id, enum pl330_chan_op op) static int pl330_chan_ctrl(struct pl330_thread *thrd, enum pl330_chan_op op)
{ {
struct pl330_thread *thrd = ch_id;
struct pl330_dmac *pl330; struct pl330_dmac *pl330;
unsigned long flags; unsigned long flags;
int ret = 0, active; int ret = 0, active;
...@@ -1794,7 +1793,7 @@ static bool _chan_ns(const struct pl330_info *pi, int i) ...@@ -1794,7 +1793,7 @@ static bool _chan_ns(const struct pl330_info *pi, int i)
/* Upon success, returns IdentityToken for the /* Upon success, returns IdentityToken for the
* allocated channel, NULL otherwise. * allocated channel, NULL otherwise.
*/ */
static void *pl330_request_channel(const struct pl330_info *pi) static struct pl330_thread *pl330_request_channel(const struct pl330_info *pi)
{ {
struct pl330_thread *thrd = NULL; struct pl330_thread *thrd = NULL;
struct pl330_dmac *pl330; struct pl330_dmac *pl330;
...@@ -1848,9 +1847,8 @@ static inline void _free_event(struct pl330_thread *thrd, int ev) ...@@ -1848,9 +1847,8 @@ static inline void _free_event(struct pl330_thread *thrd, int ev)
pl330->events[ev] = -1; pl330->events[ev] = -1;
} }
static void pl330_release_channel(void *ch_id) static void pl330_release_channel(struct pl330_thread *thrd)
{ {
struct pl330_thread *thrd = ch_id;
struct pl330_dmac *pl330; struct pl330_dmac *pl330;
unsigned long flags; unsigned long flags;
...@@ -2077,7 +2075,7 @@ static int dmac_free_threads(struct pl330_dmac *pl330) ...@@ -2077,7 +2075,7 @@ static int dmac_free_threads(struct pl330_dmac *pl330)
/* Release Channel threads */ /* Release Channel threads */
for (i = 0; i < chans; i++) { for (i = 0; i < chans; i++) {
thrd = &pl330->channels[i]; thrd = &pl330->channels[i];
pl330_release_channel((void *)thrd); pl330_release_channel(thrd);
} }
/* Free memory */ /* Free memory */
...@@ -2146,8 +2144,7 @@ static inline void fill_queue(struct dma_pl330_chan *pch) ...@@ -2146,8 +2144,7 @@ static inline void fill_queue(struct dma_pl330_chan *pch)
if (desc->status == BUSY) if (desc->status == BUSY)
continue; continue;
ret = pl330_submit_req(pch->pl330_chid, ret = pl330_submit_req(pch->thread, &desc->req);
&desc->req);
if (!ret) { if (!ret) {
desc->status = BUSY; desc->status = BUSY;
} else if (ret == -EAGAIN) { } else if (ret == -EAGAIN) {
...@@ -2183,7 +2180,7 @@ static void pl330_tasklet(unsigned long data) ...@@ -2183,7 +2180,7 @@ static void pl330_tasklet(unsigned long data)
fill_queue(pch); fill_queue(pch);
/* Make sure the PL330 Channel thread is active */ /* Make sure the PL330 Channel thread is active */
pl330_chan_ctrl(pch->pl330_chid, PL330_OP_START); pl330_chan_ctrl(pch->thread, PL330_OP_START);
while (!list_empty(&pch->completed_list)) { while (!list_empty(&pch->completed_list)) {
dma_async_tx_callback callback; dma_async_tx_callback callback;
...@@ -2254,8 +2251,8 @@ static int pl330_alloc_chan_resources(struct dma_chan *chan) ...@@ -2254,8 +2251,8 @@ static int pl330_alloc_chan_resources(struct dma_chan *chan)
dma_cookie_init(chan); dma_cookie_init(chan);
pch->cyclic = false; pch->cyclic = false;
pch->pl330_chid = pl330_request_channel(&pdmac->pif); pch->thread = pl330_request_channel(&pdmac->pif);
if (!pch->pl330_chid) { if (!pch->thread) {
spin_unlock_irqrestore(&pch->lock, flags); spin_unlock_irqrestore(&pch->lock, flags);
return -ENOMEM; return -ENOMEM;
} }
...@@ -2281,7 +2278,7 @@ static int pl330_control(struct dma_chan *chan, enum dma_ctrl_cmd cmd, unsigned ...@@ -2281,7 +2278,7 @@ static int pl330_control(struct dma_chan *chan, enum dma_ctrl_cmd cmd, unsigned
spin_lock_irqsave(&pch->lock, flags); spin_lock_irqsave(&pch->lock, flags);
/* FLUSH the PL330 Channel thread */ /* FLUSH the PL330 Channel thread */
pl330_chan_ctrl(pch->pl330_chid, PL330_OP_FLUSH); pl330_chan_ctrl(pch->thread, PL330_OP_FLUSH);
/* Mark all desc done */ /* Mark all desc done */
list_for_each_entry(desc, &pch->submitted_list, node) { list_for_each_entry(desc, &pch->submitted_list, node) {
...@@ -2340,8 +2337,8 @@ static void pl330_free_chan_resources(struct dma_chan *chan) ...@@ -2340,8 +2337,8 @@ static void pl330_free_chan_resources(struct dma_chan *chan)
spin_lock_irqsave(&pch->lock, flags); spin_lock_irqsave(&pch->lock, flags);
pl330_release_channel(pch->pl330_chid); pl330_release_channel(pch->thread);
pch->pl330_chid = NULL; pch->thread = NULL;
if (pch->cyclic) if (pch->cyclic)
list_splice_tail_init(&pch->work_list, &pch->dmac->desc_pool); list_splice_tail_init(&pch->work_list, &pch->dmac->desc_pool);
...@@ -2887,7 +2884,7 @@ pl330_probe(struct amba_device *adev, const struct amba_id *id) ...@@ -2887,7 +2884,7 @@ pl330_probe(struct amba_device *adev, const struct amba_id *id)
INIT_LIST_HEAD(&pch->work_list); INIT_LIST_HEAD(&pch->work_list);
INIT_LIST_HEAD(&pch->completed_list); INIT_LIST_HEAD(&pch->completed_list);
spin_lock_init(&pch->lock); spin_lock_init(&pch->lock);
pch->pl330_chid = NULL; pch->thread = NULL;
pch->chan.device = pd; pch->chan.device = pd;
pch->dmac = pdmac; pch->dmac = pdmac;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment