Re: [PATCH] staging: comedi: drivers: use comedi_fc.h cmdtest helpers

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

 



On 2012-09-25 03:42, H Hartley Sweeten wrote:
diff --git a/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3200.c b/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3200.c
index f6f5092..9110fc9 100644
--- a/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3200.c
+++ b/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3200.c
@@ -2560,7 +2560,6 @@ int i_APCI3200_CommandTestAnalogInput(struct comedi_device *dev, struct comedi_s
  {

         int err = 0;
-       int tmp;                /*  divisor1,divisor2; */
         unsigned int ui_ConvertTime = 0;
         unsigned int ui_ConvertTimeBase = 0;
         unsigned int ui_DelayTime = 0;
@@ -2571,41 +2570,32 @@ int i_APCI3200_CommandTestAnalogInput(struct comedi_device *dev, struct comedi_s
         int i_Cpt = 0;
         double d_ConversionTimeForAllChannels = 0.0;
         double d_SCANTimeNewUnit = 0.0;
-       /*  step 1: make sure trigger sources are trivially valid */
-
-       tmp = cmd->start_src;
-       cmd->start_src &= TRIG_NOW | TRIG_EXT;
-       if (!cmd->start_src || tmp != cmd->start_src)
-               err++;
-       tmp = cmd->scan_begin_src;
-       cmd->scan_begin_src &= TRIG_TIMER | TRIG_FOLLOW;
-       if (!cmd->scan_begin_src || tmp != cmd->scan_begin_src)
-               err++;
-       tmp = cmd->convert_src;
-       cmd->convert_src &= TRIG_TIMER;
-       if (!cmd->convert_src || tmp != cmd->convert_src)
-               err++;
-       tmp = cmd->scan_end_src;
-       cmd->scan_end_src &= TRIG_COUNT;
-       if (!cmd->scan_end_src || tmp != cmd->scan_end_src)
-               err++;
-       tmp = cmd->stop_src;
-       cmd->stop_src &= TRIG_COUNT | TRIG_NONE;
-       if (!cmd->stop_src || tmp != cmd->stop_src)
-               err++;
-       /* if(i_InterruptFlag==0) */
-       if (s_BoardInfos[dev->minor].i_InterruptFlag == 0) {
-               err++;
-               /*           printk("\nThe interrupt should be enabled\n"); */
-       }
+
+       /* Step 1 : check if triggers are trivially valid */
+
+       err |= cfc_check_trigger_src(&cmd->start_src, TRIG_NOW | TRIG_EXT);
+       err |= cfc_check_trigger_src(&cmd->scan_begin_src,
+                                       TRIG_TIMER | TRIG_FOLLOW);
+       err |= cfc_check_trigger_src(&cmd->convert_src, TRIG_TIMER);
+       err |= cfc_check_trigger_src(&cmd->scan_end_src, TRIG_COUNT);
+       err |= cfc_check_trigger_src(&cmd->stop_src, TRIG_COUNT | TRIG_NONE);
+
+       if (s_BoardInfos[dev->minor].i_InterruptFlag == 0)
+               err |= -ENIVAL;
+

I assume you mean

		err |= -EINVAL;

although it looks a little odd. We only care if it's non-zero or not, so a simple assignment would work just as well.

--
-=( Ian Abbott @ MEV Ltd.    E-mail: <abbotti@xxxxxxxxx>        )=-
-=( Tel: +44 (0)161 477 1898   FAX: +44 (0)161 718 3587         )=-
_______________________________________________
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