Skip to content

Commit

Permalink
DMAENGINE: extend the control command to include an arg
Browse files Browse the repository at this point in the history
This adds an argument to the DMAengine control function, so that
we can later provide control commands that need some external data
passed in through an argument akin to the ioctl() operation
prototype.

[[email protected]: fix up some missed conversions]
Signed-off-by: Linus Walleij <[email protected]>
Signed-off-by: Dan Williams <[email protected]>
  • Loading branch information
Linus Walleij authored and djbw committed May 17, 2010
1 parent 4aed79b commit 0582763
Show file tree
Hide file tree
Showing 14 changed files with 32 additions and 21 deletions.
3 changes: 2 additions & 1 deletion drivers/dma/at_hdmac.c
Original file line number Diff line number Diff line change
Expand Up @@ -759,7 +759,8 @@ atc_prep_slave_sg(struct dma_chan *chan, struct scatterlist *sgl,
return NULL;
}

static int atc_control(struct dma_chan *chan, enum dma_ctrl_cmd cmd)
static int atc_control(struct dma_chan *chan, enum dma_ctrl_cmd cmd,
unsigned long arg)
{
struct at_dma_chan *atchan = to_at_dma_chan(chan);
struct at_dma *atdma = to_at_dma(chan->device);
Expand Down
5 changes: 3 additions & 2 deletions drivers/dma/coh901318.c
Original file line number Diff line number Diff line change
Expand Up @@ -942,7 +942,7 @@ coh901318_free_chan_resources(struct dma_chan *chan)

spin_unlock_irqrestore(&cohc->lock, flags);

chan->device->device_control(chan, DMA_TERMINATE_ALL);
chan->device->device_control(chan, DMA_TERMINATE_ALL, 0);
}


Expand Down Expand Up @@ -1176,7 +1176,8 @@ coh901318_issue_pending(struct dma_chan *chan)
}

static int
coh901318_control(struct dma_chan *chan, enum dma_ctrl_cmd cmd)
coh901318_control(struct dma_chan *chan, enum dma_ctrl_cmd cmd,
unsigned long arg)
{
unsigned long flags;
struct coh901318_chan *cohc = to_coh901318_chan(chan);
Expand Down
3 changes: 2 additions & 1 deletion drivers/dma/dw_dmac.c
Original file line number Diff line number Diff line change
Expand Up @@ -781,7 +781,8 @@ dwc_prep_slave_sg(struct dma_chan *chan, struct scatterlist *sgl,
return NULL;
}

static int dwc_control(struct dma_chan *chan, enum dma_ctrl_cmd cmd)
static int dwc_control(struct dma_chan *chan, enum dma_ctrl_cmd cmd,
unsigned long arg)
{
struct dw_dma_chan *dwc = to_dw_dma_chan(chan);
struct dw_dma *dw = to_dw_dma(chan->device);
Expand Down
2 changes: 1 addition & 1 deletion drivers/dma/fsldma.c
Original file line number Diff line number Diff line change
Expand Up @@ -775,7 +775,7 @@ static struct dma_async_tx_descriptor *fsl_dma_prep_slave_sg(
}

static int fsl_dma_device_control(struct dma_chan *dchan,
enum dma_ctrl_cmd cmd)
enum dma_ctrl_cmd cmd, unsigned long arg)
{
struct fsldma_chan *chan;
unsigned long flags;
Expand Down
12 changes: 7 additions & 5 deletions drivers/dma/ipu/ipu_idmac.c
Original file line number Diff line number Diff line change
Expand Up @@ -1472,7 +1472,8 @@ static void idmac_issue_pending(struct dma_chan *chan)
*/
}

static int __idmac_control(struct dma_chan *chan, enum dma_ctrl_cmd cmd)
static int __idmac_control(struct dma_chan *chan, enum dma_ctrl_cmd cmd,
unsigned long arg)
{
struct idmac_channel *ichan = to_idmac_chan(chan);
struct idmac *idmac = to_idmac(chan->device);
Expand Down Expand Up @@ -1513,14 +1514,15 @@ static int __idmac_control(struct dma_chan *chan, enum dma_ctrl_cmd cmd)
return 0;
}

static int idmac_control(struct dma_chan *chan, enum dma_ctrl_cmd cmd)
static int idmac_control(struct dma_chan *chan, enum dma_ctrl_cmd cmd,
unsigned long arg)
{
struct idmac_channel *ichan = to_idmac_chan(chan);
int ret;

mutex_lock(&ichan->chan_mutex);

ret = __idmac_control(chan, cmd);
ret = __idmac_control(chan, cmd, arg);

mutex_unlock(&ichan->chan_mutex);

Expand Down Expand Up @@ -1616,7 +1618,7 @@ static void idmac_free_chan_resources(struct dma_chan *chan)

mutex_lock(&ichan->chan_mutex);

__idmac_control(chan, DMA_TERMINATE_ALL);
__idmac_control(chan, DMA_TERMINATE_ALL, 0);

if (ichan->status > IPU_CHANNEL_FREE) {
#ifdef DEBUG
Expand Down Expand Up @@ -1709,7 +1711,7 @@ static void __exit ipu_idmac_exit(struct ipu *ipu)
for (i = 0; i < IPU_CHANNELS_NUM; i++) {
struct idmac_channel *ichan = ipu->channel + i;

idmac_control(&ichan->dma_chan, DMA_TERMINATE_ALL);
idmac_control(&ichan->dma_chan, DMA_TERMINATE_ALL, 0);
idmac_prep_slave_sg(&ichan->dma_chan, NULL, 0, DMA_NONE, 0);
}

Expand Down
3 changes: 2 additions & 1 deletion drivers/dma/shdma.c
Original file line number Diff line number Diff line change
Expand Up @@ -580,7 +580,8 @@ static struct dma_async_tx_descriptor *sh_dmae_prep_slave_sg(
direction, flags);
}

static int sh_dmae_control(struct dma_chan *chan, enum dma_ctrl_cmd cmd)
static int sh_dmae_control(struct dma_chan *chan, enum dma_ctrl_cmd cmd,
unsigned long arg)
{
struct sh_dmae_chan *sh_chan = to_sh_chan(chan);

Expand Down
3 changes: 2 additions & 1 deletion drivers/dma/ste_dma40.c
Original file line number Diff line number Diff line change
Expand Up @@ -2065,7 +2065,8 @@ static void d40_issue_pending(struct dma_chan *chan)
spin_unlock_irqrestore(&d40c->lock, flags);
}

static int d40_control(struct dma_chan *chan, enum dma_ctrl_cmd cmd)
static int d40_control(struct dma_chan *chan, enum dma_ctrl_cmd cmd,
unsigned long arg)
{
unsigned long flags;
struct d40_chan *d40c = container_of(chan, struct d40_chan, chan);
Expand Down
3 changes: 2 additions & 1 deletion drivers/dma/timb_dma.c
Original file line number Diff line number Diff line change
Expand Up @@ -611,7 +611,8 @@ static struct dma_async_tx_descriptor *td_prep_slave_sg(struct dma_chan *chan,
return &td_desc->txd;
}

static int td_control(struct dma_chan *chan, enum dma_ctrl_cmd cmd)
static int td_control(struct dma_chan *chan, enum dma_ctrl_cmd cmd,
unsigned long arg)
{
struct timb_dma_chan *td_chan =
container_of(chan, struct timb_dma_chan, chan);
Expand Down
3 changes: 2 additions & 1 deletion drivers/dma/txx9dmac.c
Original file line number Diff line number Diff line change
Expand Up @@ -938,7 +938,8 @@ txx9dmac_prep_slave_sg(struct dma_chan *chan, struct scatterlist *sgl,
return &first->txd;
}

static int txx9dmac_control(struct dma_chan *chan, enum dma_ctrl_cmd cmd)
static int txx9dmac_control(struct dma_chan *chan, enum dma_ctrl_cmd cmd,
unsigned long arg)
{
struct txx9dmac_chan *dc = to_txx9dmac_chan(chan);
struct txx9dmac_desc *desc, *_desc;
Expand Down
2 changes: 1 addition & 1 deletion drivers/mmc/host/atmel-mci.c
Original file line number Diff line number Diff line change
Expand Up @@ -578,7 +578,7 @@ static void atmci_stop_dma(struct atmel_mci *host)
struct dma_chan *chan = host->data_chan;

if (chan) {
chan->device->device_control(chan, DMA_TERMINATE_ALL);
chan->device->device_control(chan, DMA_TERMINATE_ALL, 0);
atmci_dma_cleanup(host);
} else {
/* Data transfer was stopped by the interrupt handler */
Expand Down
2 changes: 1 addition & 1 deletion drivers/serial/sh-sci.c
Original file line number Diff line number Diff line change
Expand Up @@ -1087,7 +1087,7 @@ static void work_fn_rx(struct work_struct *work)
unsigned long flags;
int count;

chan->device->device_control(chan, DMA_TERMINATE_ALL);
chan->device->device_control(chan, DMA_TERMINATE_ALL, 0);
dev_dbg(port->dev, "Read %u bytes with cookie %d\n",
sh_desc->partial, sh_desc->cookie);

Expand Down
2 changes: 1 addition & 1 deletion drivers/video/mx3fb.c
Original file line number Diff line number Diff line change
Expand Up @@ -388,7 +388,7 @@ static void sdc_disable_channel(struct mx3fb_info *mx3_fbi)
spin_unlock_irqrestore(&mx3fb->lock, flags);

mx3_fbi->txd->chan->device->device_control(mx3_fbi->txd->chan,
DMA_TERMINATE_ALL);
DMA_TERMINATE_ALL, 0);
mx3_fbi->txd = NULL;
mx3_fbi->cookie = -EINVAL;
}
Expand Down
3 changes: 2 additions & 1 deletion include/linux/dmaengine.h
Original file line number Diff line number Diff line change
Expand Up @@ -347,7 +347,8 @@ struct dma_device {
struct dma_chan *chan, struct scatterlist *sgl,
unsigned int sg_len, enum dma_data_direction direction,
unsigned long flags);
int (*device_control)(struct dma_chan *chan, enum dma_ctrl_cmd cmd);
int (*device_control)(struct dma_chan *chan, enum dma_ctrl_cmd cmd,
unsigned long arg);

enum dma_status (*device_tx_status)(struct dma_chan *chan,
dma_cookie_t cookie,
Expand Down
7 changes: 4 additions & 3 deletions sound/soc/txx9/txx9aclc.c
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ static void txx9aclc_dma_tasklet(unsigned long data)
void __iomem *base = drvdata->base;

spin_unlock_irqrestore(&dmadata->dma_lock, flags);
chan->device->device_control(chan, DMA_TERMINATE_ALL);
chan->device->device_control(chan, DMA_TERMINATE_ALL, 0);
/* first time */
for (i = 0; i < NR_DMA_CHAIN; i++) {
desc = txx9aclc_dma_submit(dmadata,
Expand Down Expand Up @@ -267,7 +267,7 @@ static int txx9aclc_pcm_close(struct snd_pcm_substream *substream)
struct dma_chan *chan = dmadata->dma_chan;

dmadata->frag_count = -1;
chan->device->device_control(chan, DMA_TERMINATE_ALL);
chan->device->device_control(chan, DMA_TERMINATE_ALL, 0);
return 0;
}

Expand Down Expand Up @@ -396,7 +396,8 @@ static int txx9aclc_pcm_remove(struct platform_device *pdev)
struct dma_chan *chan = dmadata->dma_chan;
if (chan) {
dmadata->frag_count = -1;
chan->device->device_control(chan, DMA_TERMINATE_ALL);
chan->device->device_control(chan,
DMA_TERMINATE_ALL, 0);
dma_release_channel(chan);
}
dev->dmadata[i].dma_chan = NULL;
Expand Down

0 comments on commit 0582763

Please sign in to comment.