The ai (*do_cmd_test) validates the trigger sources in Step 2b to ensure that they are compatible. Save the 'ai_ctrl_mode' that will be used in the private data so that ai_prepare(), which is called by the ai (*do_cmd), does not have to recheck the sources in order to figure it out. Also, tidy up the stop trigger checks so that the ME4000_AI_CTRL_HF_IRQ bit is set in the common code path. Signed-off-by: H Hartley Sweeten <hsweeten@xxxxxxxxxxxxxxxxxxx> --- drivers/staging/comedi/drivers/me4000.c | 52 ++++++++++++--------------------- 1 file changed, 18 insertions(+), 34 deletions(-) diff --git a/drivers/staging/comedi/drivers/me4000.c b/drivers/staging/comedi/drivers/me4000.c index 610c923..9da09c4 100644 --- a/drivers/staging/comedi/drivers/me4000.c +++ b/drivers/staging/comedi/drivers/me4000.c @@ -163,6 +163,7 @@ broken. struct me4000_private { unsigned long plx_regbase; + unsigned int ai_ctrl_mode; unsigned int ai_init_ticks; unsigned int ai_scan_ticks; unsigned int ai_chan_ticks; @@ -674,59 +675,35 @@ static int ai_prepare(struct comedi_device *dev, struct comedi_subdevice *s, struct comedi_cmd *cmd) { - unsigned int tmp = 0; + struct me4000_private *devpriv = dev->private; + unsigned int ctrl; /* Write timer arguments */ ai_write_timer(dev); /* Reset control register */ - outl(tmp, dev->iobase + ME4000_AI_CTRL_REG); + outl(0, dev->iobase + ME4000_AI_CTRL_REG); /* Start sources */ - if ((cmd->start_src == TRIG_EXT && - cmd->scan_begin_src == TRIG_TIMER && - cmd->convert_src == TRIG_TIMER) || - (cmd->start_src == TRIG_EXT && - cmd->scan_begin_src == TRIG_FOLLOW && - cmd->convert_src == TRIG_TIMER)) { - tmp = ME4000_AI_CTRL_MODE_1 | - ME4000_AI_CTRL_CHANNEL_FIFO | - ME4000_AI_CTRL_DATA_FIFO; - } else if (cmd->start_src == TRIG_EXT && - cmd->scan_begin_src == TRIG_EXT && - cmd->convert_src == TRIG_TIMER) { - tmp = ME4000_AI_CTRL_MODE_2 | - ME4000_AI_CTRL_CHANNEL_FIFO | - ME4000_AI_CTRL_DATA_FIFO; - } else if (cmd->start_src == TRIG_EXT && - cmd->scan_begin_src == TRIG_EXT && - cmd->convert_src == TRIG_EXT) { - tmp = ME4000_AI_CTRL_MODE_0 | - ME4000_AI_CTRL_MODE_1 | - ME4000_AI_CTRL_CHANNEL_FIFO | - ME4000_AI_CTRL_DATA_FIFO; - } else { - tmp = ME4000_AI_CTRL_MODE_0 | - ME4000_AI_CTRL_CHANNEL_FIFO | - ME4000_AI_CTRL_DATA_FIFO; - } + ctrl = devpriv->ai_ctrl_mode | + ME4000_AI_CTRL_CHANNEL_FIFO | + ME4000_AI_CTRL_DATA_FIFO; /* Stop triggers */ if (cmd->stop_src == TRIG_COUNT) { outl(cmd->chanlist_len * cmd->stop_arg, dev->iobase + ME4000_AI_SAMPLE_COUNTER_REG); - tmp |= ME4000_AI_CTRL_HF_IRQ | ME4000_AI_CTRL_SC_IRQ; + ctrl |= ME4000_AI_CTRL_SC_IRQ; } else if (cmd->stop_src == TRIG_NONE && cmd->scan_end_src == TRIG_COUNT) { outl(cmd->scan_end_arg, dev->iobase + ME4000_AI_SAMPLE_COUNTER_REG); - tmp |= ME4000_AI_CTRL_HF_IRQ | ME4000_AI_CTRL_SC_IRQ; - } else { - tmp |= ME4000_AI_CTRL_HF_IRQ; + ctrl |= ME4000_AI_CTRL_SC_IRQ; } + ctrl |= ME4000_AI_CTRL_HF_IRQ; /* Write the setup to the control register */ - outl(tmp, dev->iobase + ME4000_AI_CTRL_REG); + outl(ctrl, dev->iobase + ME4000_AI_CTRL_REG); /* Write the channel list */ me4000_ai_write_chanlist(dev, s, cmd); @@ -790,21 +767,28 @@ static int me4000_ai_do_cmd_test(struct comedi_device *dev, if (cmd->start_src == TRIG_NOW && cmd->scan_begin_src == TRIG_TIMER && cmd->convert_src == TRIG_TIMER) { + devpriv->ai_ctrl_mode = ME4000_AI_CTRL_MODE_0; } else if (cmd->start_src == TRIG_NOW && cmd->scan_begin_src == TRIG_FOLLOW && cmd->convert_src == TRIG_TIMER) { + devpriv->ai_ctrl_mode = ME4000_AI_CTRL_MODE_0; } else if (cmd->start_src == TRIG_EXT && cmd->scan_begin_src == TRIG_TIMER && cmd->convert_src == TRIG_TIMER) { + devpriv->ai_ctrl_mode = ME4000_AI_CTRL_MODE_1; } else if (cmd->start_src == TRIG_EXT && cmd->scan_begin_src == TRIG_FOLLOW && cmd->convert_src == TRIG_TIMER) { + devpriv->ai_ctrl_mode = ME4000_AI_CTRL_MODE_1; } else if (cmd->start_src == TRIG_EXT && cmd->scan_begin_src == TRIG_EXT && cmd->convert_src == TRIG_TIMER) { + devpriv->ai_ctrl_mode = ME4000_AI_CTRL_MODE_2; } else if (cmd->start_src == TRIG_EXT && cmd->scan_begin_src == TRIG_EXT && cmd->convert_src == TRIG_EXT) { + devpriv->ai_ctrl_mode = ME4000_AI_CTRL_MODE_0 | + ME4000_AI_CTRL_MODE_1; } else { err |= -EINVAL; } -- 2.4.3 _______________________________________________ devel mailing list devel@xxxxxxxxxxxxxxxxxxxxxx http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel