made chanlist cmdtests return 5
authorFrank Mori Hess <fmhess@speakeasy.net>
Fri, 20 Jul 2001 18:40:17 +0000 (18:40 +0000)
committerFrank Mori Hess <fmhess@speakeasy.net>
Fri, 20 Jul 2001 18:40:17 +0000 (18:40 +0000)
comedi/drivers/cb_pcidas.c
comedi/drivers/das16m1.c
comedi/drivers/das1800.c
comedi/drivers/das800.c

index b9282b196c4461f0ba383f26dea0c32f1eb6e7b9..231e952738535abd2ac05efc599a43a3529560b7 100644 (file)
@@ -729,26 +729,6 @@ static int cb_pcidas_ai_cmdtest(comedi_device *dev,comedi_subdevice *s,
                }
        }
 
-       // check channel/gain list against card's limitations
-       if(cmd->chanlist)
-       {
-               gain = CR_RANGE(cmd->chanlist[0]);
-               start_chan = CR_CHAN(cmd->chanlist[0]);
-               for(i = 1; i < cmd->chanlist_len; i++)
-               {
-                       if(CR_CHAN(cmd->chanlist[i]) != (start_chan + i) % s->n_chan)
-                       {
-                               comedi_error(dev, "entries in chanlist must be consecutive channels, counting upwards\n");
-                               err++;
-                       }
-                       if(CR_RANGE(cmd->chanlist[i]) != gain)
-                       {
-                               comedi_error(dev, "entries in chanlist must all have the same gain\n");
-                               err++;
-                       }
-               }
-       }
-
        if(err)return 3;
 
        /* step 4: fix up any arguments */
@@ -780,6 +760,28 @@ static int cb_pcidas_ai_cmdtest(comedi_device *dev,comedi_subdevice *s,
 
        if(err) return 4;
 
+       // check channel/gain list against card's limitations
+       if(cmd->chanlist)
+       {
+               gain = CR_RANGE(cmd->chanlist[0]);
+               start_chan = CR_CHAN(cmd->chanlist[0]);
+               for(i = 1; i < cmd->chanlist_len; i++)
+               {
+                       if(CR_CHAN(cmd->chanlist[i]) != (start_chan + i) % s->n_chan)
+                       {
+                               comedi_error(dev, "entries in chanlist must be consecutive channels, counting upwards\n");
+                               err++;
+                       }
+                       if(CR_RANGE(cmd->chanlist[i]) != gain)
+                       {
+                               comedi_error(dev, "entries in chanlist must all have the same gain\n");
+                               err++;
+                       }
+               }
+       }
+
+       if(err) return 5;
+
        return 0;
 }
 
index f7487fe8ccf4d90d9b0f35b0cad5619e1773657f..2cc53c45d32f2924f5a1f45dcb8511e6efa91730 100644 (file)
@@ -178,27 +178,6 @@ static int das16m1_cmd_test(comedi_device *dev,comedi_subdevice *s, comedi_cmd *
 {
        unsigned int err=0, tmp, i;
 
-       // check chanlist against board's peculiarities
-       if(cmd->chanlist && cmd->chanlist_len > 1)
-       {
-               for(i = 0; i < cmd->chanlist_len; i++)
-               {
-                       // even/odd channels must go into even/odd queue addresses
-                       if((i % 2) != (CR_CHAN(cmd->chanlist[i]) % 2))
-                       {
-                               comedi_error(dev, "bad chanlist:\n"
-                                       " even/odd channels must go have even/odd chanlist indices");
-                               err++;
-                       }
-               }
-               if((cmd->chanlist_len % 2) != 0)
-               {
-                       comedi_error(dev, "chanlist must be of even length or length 1");
-                       err++;
-               }
-       }
-       if(err) return -EINVAL;
-
        /* make sure triggers are valid */
        tmp=cmd->start_src;
        cmd->start_src &= TRIG_NOW | TRIG_EXT;
@@ -285,6 +264,28 @@ static int das16m1_cmd_test(comedi_device *dev,comedi_subdevice *s, comedi_cmd *
 
        if(err) return 4;
 
+       // check chanlist against board's peculiarities
+       if(cmd->chanlist && cmd->chanlist_len > 1)
+       {
+               for(i = 0; i < cmd->chanlist_len; i++)
+               {
+                       // even/odd channels must go into even/odd queue addresses
+                       if((i % 2) != (CR_CHAN(cmd->chanlist[i]) % 2))
+                       {
+                               comedi_error(dev, "bad chanlist:\n"
+                                       " even/odd channels must go have even/odd chanlist indices");
+                               err++;
+                       }
+               }
+               if((cmd->chanlist_len % 2) != 0)
+               {
+                       comedi_error(dev, "chanlist must be of even length or length 1");
+                       err++;
+               }
+       }
+
+       if(err) return 5;
+
        return 0;
 }
 
index 01a51f6fb1c2a1da00039218c7d09f7022032b95..154e3654d86a4b4fd58aafcf009ea8c45a5b8eaf 100644 (file)
@@ -1160,21 +1160,6 @@ static int das1800_ai_do_cmdtest(comedi_device *dev,comedi_subdevice *s,comedi_c
                err++;
        }
 
-       // make sure user is not trying to mix unipolar and bipolar ranges
-       if(cmd->chanlist)
-       {
-               unipolar = CR_RANGE(cmd->chanlist[0]) & UNIPOLAR;
-               for(i = 1; i < cmd->chanlist_len; i++)
-               {
-                       if(unipolar != (CR_RANGE(cmd->chanlist[i]) & UNIPOLAR))
-                       {
-                               comedi_error(dev, "unipolar and bipolar ranges cannot be mixed in the chanlist");
-                               err++;
-                               break;
-                       }
-               }
-       }
-
        switch(cmd->stop_src)
        {
                case TRIG_EXT:
@@ -1242,6 +1227,23 @@ static int das1800_ai_do_cmdtest(comedi_device *dev,comedi_subdevice *s,comedi_c
 
        if(err) return 4;
 
+       // make sure user is not trying to mix unipolar and bipolar ranges
+       if(cmd->chanlist)
+       {
+               unipolar = CR_RANGE(cmd->chanlist[0]) & UNIPOLAR;
+               for(i = 1; i < cmd->chanlist_len; i++)
+               {
+                       if(unipolar != (CR_RANGE(cmd->chanlist[i]) & UNIPOLAR))
+                       {
+                               comedi_error(dev, "unipolar and bipolar ranges cannot be mixed in the chanlist");
+                               err++;
+                               break;
+                       }
+               }
+       }
+
+       if(err) return 5;
+
        return 0;
 }
 
index f85770e60ef27f804e64835e1f426ba3a25e08f5..7e565f1ba15bd251d414b35a1fa68b703341d1c8 100644 (file)
@@ -688,6 +688,21 @@ static int das800_ai_do_cmdtest(comedi_device *dev,comedi_subdevice *s,comedi_cm
                        err++;
                }
        }
+
+       if(err)return 3;
+
+       /* step 4: fix up any arguments */
+
+       if(cmd->convert_src == TRIG_TIMER)
+       {
+               tmp = cmd->convert_arg;
+               /* calculate counter values that give desired timing */
+               i8253_cascade_ns_to_timer_2div(TIMER_BASE, &(devpriv->divisor1), &(devpriv->divisor2), &(cmd->convert_arg), cmd->flags & TRIG_ROUND_MASK);
+               if(tmp != cmd->convert_arg) err++;
+       }
+
+       if(err)return 4;
+
        // check channel/gain list against card's limitations
        if(cmd->chanlist)
        {
@@ -708,19 +723,7 @@ static int das800_ai_do_cmdtest(comedi_device *dev,comedi_subdevice *s,comedi_cm
                }
        }
 
-       if(err)return 3;
-
-       /* step 4: fix up any arguments */
-
-       if(cmd->convert_src == TRIG_TIMER)
-       {
-               tmp = cmd->convert_arg;
-               /* calculate counter values that give desired timing */
-               i8253_cascade_ns_to_timer_2div(TIMER_BASE, &(devpriv->divisor1), &(devpriv->divisor2), &(cmd->convert_arg), cmd->flags & TRIG_ROUND_MASK);
-               if(tmp != cmd->convert_arg) err++;
-       }
-
-       if(err)return 4;
+       if(err)return 5;
 
        return 0;
 }