From eaca0032f1b5be78b0e8fe55934fd8db5d95d2d1 Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Tue, 29 Apr 2014 12:59:46 -0700 Subject: [PATCH] staging: comedi: addi_common.h: remove 'ui_AiNbrofScans' from private data This member of the private data is a copy of the cmd->stop_arg. Use that instead. Fix the b_AiContinuous check in apci3120_ai_cmd(). The (*do_cmdtest) validates that the cmd->stop_arg os >= 1 for TRIG_COUNT and 0 for TRIG_NONE. The correct test to set this flag is (cmd->stop_src == TRIG_NONE). Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- .../comedi/drivers/addi-data/addi_common.h | 1 - .../comedi/drivers/addi-data/hwdrv_apci3120.c | 22 ++++++++----------- 2 files changed, 9 insertions(+), 14 deletions(-) diff --git a/drivers/staging/comedi/drivers/addi-data/addi_common.h b/drivers/staging/comedi/drivers/addi-data/addi_common.h index a2208e7a3605..7471a0a9e13e 100644 --- a/drivers/staging/comedi/drivers/addi-data/addi_common.h +++ b/drivers/staging/comedi/drivers/addi-data/addi_common.h @@ -123,7 +123,6 @@ struct addi_private { unsigned int ui_AiNbrofChannels; /* how many channels is measured */ unsigned int ui_AiChannelList[32]; /* actual chanlist */ unsigned int ui_AiReadData[32]; - unsigned int ui_AiNbrofScans; /* number of scans to do */ unsigned short us_UseDma; /* To use Dma or not */ unsigned char b_DmaDoubleBuffer; /* we can use double buffering */ unsigned int ui_DmaActualBuffer; /* which buffer is used now */ diff --git a/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c b/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c index cd8e9335aa6e..e4b92767b8ad 100644 --- a/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c +++ b/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c @@ -891,7 +891,7 @@ static int apci3120_cyclic_ai(int mode, devpriv->ui_DmaActualBuffer = 0; /* value for timer2 minus -2 has to be done .....dunno y?? */ - ui_TimerValue2 = devpriv->ui_AiNbrofScans - 2; + ui_TimerValue2 = cmd->stop_arg - 2; ui_ConvertTiming = cmd->convert_arg; if (mode == 2) @@ -1130,11 +1130,12 @@ static int apci3120_cyclic_ai(int mode, * Must we fill full first buffer? And must we fill * full second buffer when first is once filled? */ - if (dmalen0 > (devpriv->ui_AiNbrofScans * scan_bytes)) { - dmalen0 = devpriv->ui_AiNbrofScans * scan_bytes; - } else if (dmalen1 > (devpriv->ui_AiNbrofScans * scan_bytes - dmalen0)) - dmalen1 = devpriv->ui_AiNbrofScans * - scan_bytes - dmalen0; + if (dmalen0 > (cmd->stop_arg * scan_bytes)) { + dmalen0 = cmd->stop_arg * scan_bytes; + } else if (dmalen1 > (cmd->stop_arg * scan_bytes - + dmalen0)) + dmalen1 = cmd->stop_arg * scan_bytes - + dmalen0; } if (cmd->flags & TRIG_WAKE_EOS) { @@ -1339,12 +1340,7 @@ static int apci3120_ai_cmd(struct comedi_device *dev, /* loading private structure with cmd structure inputs */ devpriv->ui_AiNbrofChannels = cmd->chanlist_len; - if (cmd->stop_src == TRIG_COUNT) - devpriv->ui_AiNbrofScans = cmd->stop_arg; - else - devpriv->ui_AiNbrofScans = 0; - - if ((devpriv->ui_AiNbrofScans == 0) || (devpriv->ui_AiNbrofScans == -1)) + if (cmd->stop_src == TRIG_NONE) devpriv->b_AiContinuous = 1; /* user want neverending analog acquisition */ /* stopped using cancel */ @@ -1486,7 +1482,7 @@ static void apci3120_interrupt_dma(int irq, void *d) } } if (!devpriv->b_AiContinuous) - if (devpriv->ui_AiActualScan >= devpriv->ui_AiNbrofScans) { + if (devpriv->ui_AiActualScan >= cmd->stop_arg) { /* all data sampled */ apci3120_cancel(dev, s); devpriv->b_AiCyclicAcquisition = APCI3120_DISABLE; -- 2.39.2