From: H Hartley Sweeten Date: Tue, 9 Sep 2014 20:05:53 +0000 (-0700) Subject: staging: comedi: adl_pci9118: clarify async command start X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=e7d2191b0ba09e070c1417fc8af73c3c5cd744f7;p=GitHub%2Fmoto-9609%2Fandroid_kernel_motorola_exynos9610.git staging: comedi: adl_pci9118: clarify async command start The async command can start immediately (TRIG_NOW), from an internal trigger (TRIG_INT), or from an external trigger (TRIG_EXT). Currently the start of the command is scattered in the DMA and non-DMA helper functions. Consolidate the start of the async command at the end of the (*do_cmd) function. For aesthetics, use the 'cmd->start_src' directly instead of the 'ai12_startstop' in the private data to determine how to start the command. This also fixes a minor bug where the external trigger gets enabled for a start_src == TRIG_INT. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- diff --git a/drivers/staging/comedi/drivers/adl_pci9118.c b/drivers/staging/comedi/drivers/adl_pci9118.c index cf7bd2fbdb15..127799788c89 100644 --- a/drivers/staging/comedi/drivers/adl_pci9118.c +++ b/drivers/staging/comedi/drivers/adl_pci9118.c @@ -142,7 +142,6 @@ #define START_AI_EXT 0x01 /* start measure on external trigger */ #define STOP_AI_EXT 0x02 /* stop measure on external trigger */ -#define START_AI_INT 0x04 /* start measure on internal trigger */ #define STOP_AI_INT 0x08 /* stop measure on internal trigger */ #define PCI9118_HALF_FIFO_SZ (1024 / 2) @@ -790,15 +789,12 @@ static int pci9118_ai_inttrig(struct comedi_device *dev, struct comedi_subdevice *s, unsigned int trig_num) { - struct pci9118_private *devpriv = dev->private; struct comedi_cmd *cmd = &s->async->cmd; if (trig_num != cmd->start_arg) return -EINVAL; - devpriv->ai12_startstop &= ~START_AI_INT; s->async->inttrig = NULL; - pci9118_ai_cmd_start(dev); return 1; @@ -1112,9 +1108,6 @@ static int pci9118_ai_docmd_sampl(struct comedi_device *dev, return -EIO; } - if (devpriv->ai12_startstop) - pci9118_exttrg_enable(dev, true); - if ((devpriv->ai_do == 1) || (devpriv->ai_do == 2)) devpriv->int_ctrl |= PCI9118_INT_CTRL_TIMER; @@ -1122,9 +1115,6 @@ static int pci9118_ai_docmd_sampl(struct comedi_device *dev, pci9118_amcc_int_ena(dev, true); - if (!(devpriv->ai12_startstop & (START_AI_EXT | START_AI_INT))) - pci9118_ai_cmd_start(dev); - return 0; } @@ -1166,15 +1156,9 @@ static int pci9118_ai_docmd_dma(struct comedi_device *dev, return -EIO; } - if (devpriv->ai12_startstop) - pci9118_exttrg_enable(dev, true); - outl(0x02000000 | AINT_WRITE_COMPL, devpriv->iobase_a + AMCC_OP_REG_INTCSR); - if (!(devpriv->ai12_startstop & (START_AI_EXT | START_AI_INT))) - pci9118_ai_cmd_start(dev); - return 0; } @@ -1197,10 +1181,6 @@ static int pci9118_ai_cmd(struct comedi_device *dev, struct comedi_subdevice *s) devpriv->ai_neverending = 1; devpriv->ai12_startstop |= STOP_AI_EXT; } - if (cmd->start_src == TRIG_INT) { - devpriv->ai12_startstop |= START_AI_INT; - s->async->inttrig = pci9118_ai_inttrig; - } if (cmd->stop_src == TRIG_NONE) devpriv->ai_neverending = 1; if (cmd->stop_src == TRIG_COUNT) @@ -1358,8 +1338,20 @@ static int pci9118_ai_cmd(struct comedi_device *dev, struct comedi_subdevice *s) ret = pci9118_ai_docmd_dma(dev, s); else ret = pci9118_ai_docmd_sampl(dev, s); + if (ret) + return ret; + + /* start async command now or wait for internal trigger */ + if (cmd->start_src == TRIG_NOW) + pci9118_ai_cmd_start(dev); + else if (cmd->start_src == TRIG_INT) + s->async->inttrig = pci9118_ai_inttrig; - return ret; + /* enable external trigger for command start/stop */ + if (cmd->start_src == TRIG_EXT || cmd->stop_src == TRIG_EXT) + pci9118_exttrg_enable(dev, true); + + return 0; } static int pci9118_ai_eoc(struct comedi_device *dev,