[PATCH 46/51 v2] staging: comedi: ni_labpc: cleanup trigger setting in labpc_ai_cmd()

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



The (*do_cmdtest) already validated the cmd sources so the default
cases in the switch() statements can never happen.

Preclear to trigger bits and change the switch() statements to simple
if() tests to set the bits.

Signed-off-by: H Hartley Sweeten <hsweeten@xxxxxxxxxxxxxxxxxxx>
Cc: Ian Abbott <abbotti@xxxxxxxxx>
Cc: Greg Kroah-Hartman <gregkh@xxxxxxxxxxxxxxxxxxx>
---
 drivers/staging/comedi/drivers/ni_labpc.c | 35 ++++++++-----------------------
 1 file changed, 9 insertions(+), 26 deletions(-)

diff --git a/drivers/staging/comedi/drivers/ni_labpc.c b/drivers/staging/comedi/drivers/ni_labpc.c
index 244b3e5..f612875 100644
--- a/drivers/staging/comedi/drivers/ni_labpc.c
+++ b/drivers/staging/comedi/drivers/ni_labpc.c
@@ -1054,38 +1054,21 @@ static int labpc_ai_cmd(struct comedi_device *dev, struct comedi_subdevice *s)
 
 	/*  startup acquisition */
 
-	/*  cmd2 reg */
-	/*  use 2 cascaded counters for pacing */
 	spin_lock_irqsave(&dev->spinlock, flags);
+
+	/* use 2 cascaded counters for pacing */
 	devpriv->cmd2 |= CMD2_TBSEL;
-	switch (cmd->start_src) {
-	case TRIG_EXT:
+
+	devpriv->cmd2 &= ~(CMD2_SWTRIG | CMD2_HWTRIG | CMD2_PRETRIG);
+	if (cmd->start_src == TRIG_EXT)
 		devpriv->cmd2 |= CMD2_HWTRIG;
-		devpriv->cmd2 &= ~(CMD2_PRETRIG | CMD2_SWTRIG);
-		break;
-	case TRIG_NOW:
+	else
 		devpriv->cmd2 |= CMD2_SWTRIG;
-		devpriv->cmd2 &= ~(CMD2_PRETRIG | CMD2_HWTRIG);
-		break;
-	default:
-		comedi_error(dev, "bug with start_src");
-		spin_unlock_irqrestore(&dev->spinlock, flags);
-		return -1;
-		break;
-	}
-	switch (cmd->stop_src) {
-	case TRIG_EXT:
+	if (cmd->stop_src == TRIG_EXT)
 		devpriv->cmd2 |= (CMD2_HWTRIG | CMD2_PRETRIG);
-		break;
-	case TRIG_COUNT:
-	case TRIG_NONE:
-		break;
-	default:
-		comedi_error(dev, "bug with stop_src");
-		spin_unlock_irqrestore(&dev->spinlock, flags);
-		return -1;
-	}
+
 	devpriv->write_byte(devpriv->cmd2, dev->iobase + CMD2_REG);
+
 	spin_unlock_irqrestore(&dev->spinlock, flags);
 
 	return 0;
-- 
1.8.1.4

_______________________________________________
devel mailing list
devel@xxxxxxxxxxxxxxxxxxxxxx
http://driverdev.linuxdriverproject.org/mailman/listinfo/devel

[Index of Archives]     [Linux Driver Backports]     [DMA Engine]     [Linux GPIO]     [Linux SPI]     [Video for Linux]     [Linux USB Devel]     [Linux Coverity]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [Yosemite Backpacking]
  Powered by Linux