For cmdtest, don't return 5 if chanlist_len == 0.
authorIan Abbott <abbotti@mev.co.uk>
Fri, 9 Nov 2007 15:19:36 +0000 (15:19 +0000)
committerIan Abbott <abbotti@mev.co.uk>
Fri, 9 Nov 2007 15:19:36 +0000 (15:19 +0000)
comedi/drivers/amplc_pci224.c

index 2a87ca12be27fdeaf46523bd772e49cf791636cc..d789525cad16bb3d93729f4d9f26a6e7fb98d92d 100644 (file)
@@ -961,51 +961,43 @@ pci224_ao_cmdtest(comedi_device * dev, comedi_subdevice * s, comedi_cmd * cmd)
 
        /* Step 5: check channel list. */
 
-       if (cmd->chanlist) {
-               if (cmd->chanlist_len > 0) {
-                       unsigned int range;
-                       enum { range_err = 1, dupchan_err = 2, };
-                       unsigned errors;
-                       unsigned int n;
-                       unsigned int ch;
+       if (cmd->chanlist && (cmd->chanlist_len > 0)) {
+               unsigned int range;
+               enum { range_err = 1, dupchan_err = 2, };
+               unsigned errors;
+               unsigned int n;
+               unsigned int ch;
 
-                       /*
-                        * Check all channels have the same range index.  Don't
-                        * care about analogue reference, as we can't configure
-                        * it.
-                        *
-                        * Check the list has no duplicate channels.
-                        */
-                       range = CR_RANGE(cmd->chanlist[0]);
-                       errors = 0;
-                       tmp = 0;
-                       for (n = 0; n < cmd->chanlist_len; n++) {
-                               ch = CR_CHAN(cmd->chanlist[n]);
-                               if (tmp & (1U << ch)) {
-                                       errors |= dupchan_err;
-                               }
-                               tmp |= (1U << ch);
-                               if (CR_RANGE(cmd->chanlist[n]) != range) {
-                                       errors |= range_err;
-                               }
+               /*
+                * Check all channels have the same range index.  Don't care
+                * about analogue reference, as we can't configure it.
+                *
+                * Check the list has no duplicate channels.
+                */
+               range = CR_RANGE(cmd->chanlist[0]);
+               errors = 0;
+               tmp = 0;
+               for (n = 0; n < cmd->chanlist_len; n++) {
+                       ch = CR_CHAN(cmd->chanlist[n]);
+                       if (tmp & (1U << ch)) {
+                               errors |= dupchan_err;
                        }
-                       if (errors) {
-                               if (errors & dupchan_err) {
-                                       comedi_error(dev,
-                                               "entries in chanlist must "
-                                               "contain no duplicate "
-                                               "channels\n");
-                               }
-                               if (errors & range_err) {
-                                       comedi_error(dev,
-                                               "entries in chanlist must "
-                                               "all have the same range "
-                                               "index\n");
-                               }
-                               err++;
+                       tmp |= (1U << ch);
+                       if (CR_RANGE(cmd->chanlist[n]) != range) {
+                               errors |= range_err;
+                       }
+               }
+               if (errors) {
+                       if (errors & dupchan_err) {
+                               comedi_error(dev,
+                                       "entries in chanlist must contain no "
+                                       "duplicate channels\n");
+                       }
+                       if (errors & range_err) {
+                               comedi_error(dev,
+                                       "entries in chanlist must all have "
+                                       "the same range index\n");
                        }
-               } else {
-                       /* cmd->chanlist_len == 0 */
                        err++;
                }
        }