staging: comedi: ni_labpc: return error from labpc_counter_set_mode()
authorH Hartley Sweeten <hsweeten@visionengravers.com>
Fri, 22 Mar 2013 16:54:41 +0000 (09:54 -0700)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Mon, 25 Mar 2013 18:42:59 +0000 (11:42 -0700)
Make sure labpc_counter_set_mode() was successfull and return any
errno back to the caller.

For the if/else conditions that either load the counter of just set
the mode, use a common error patch to check for the error.

Signed-off-by: H Hartley Sweeten <hsweeten@visionengravers.com>
Cc: Ian Abbott <abbotti@mev.co.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/staging/comedi/drivers/ni_labpc.c

index 5782b019697dc3cc32f5ed1174f15632aecd143e..350ba0454bd6c0435fa27081ef5fb9fd87bd4347 100644 (file)
@@ -472,8 +472,10 @@ static int labpc_ai_insn_read(struct comedi_device *dev,
        devpriv->write_byte(devpriv->cmd4, dev->iobase + CMD4_REG);
 
        /* initialize pacer counter to prevent any problems */
-       labpc_counter_set_mode(dev, dev->iobase + COUNTER_A_BASE_REG,
-                              0, I8254_MODE2);
+       ret = labpc_counter_set_mode(dev, dev->iobase + COUNTER_A_BASE_REG,
+                                    0, I8254_MODE2);
+       if (ret)
+               return ret;
 
        labpc_clear_adc_fifo(dev);
 
@@ -901,14 +903,15 @@ static int labpc_ai_cmd(struct comedi_device *dev, struct comedi_subdevice *s)
                 */
                ret = labpc_counter_load(dev, dev->iobase + COUNTER_A_BASE_REG,
                                         1, 3, I8254_MODE0);
-               if (ret < 0) {
-                       comedi_error(dev, "error loading counter a1");
-                       return -1;
-               }
        } else  {
                /* just put counter a1 in mode 0 to set its output low */
-               labpc_counter_set_mode(dev, dev->iobase + COUNTER_A_BASE_REG,
-                                      1, I8254_MODE0);
+               ret = labpc_counter_set_mode(dev,
+                                            dev->iobase + COUNTER_A_BASE_REG,
+                                            1, I8254_MODE0);
+       }
+       if (ret) {
+               comedi_error(dev, "error loading counter a1");
+               return ret;
        }
 
 #ifdef CONFIG_ISA_DMA_API
@@ -972,14 +975,15 @@ static int labpc_ai_cmd(struct comedi_device *dev, struct comedi_subdevice *s)
                /*  load counter a0 in mode 2 */
                ret = labpc_counter_load(dev, dev->iobase + COUNTER_A_BASE_REG,
                                         0, devpriv->divisor_a0, I8254_MODE2);
-               if (ret < 0) {
-                       comedi_error(dev, "error loading counter a0");
-                       return -1;
-               }
        } else {
                /* initialize pacer counter to prevent any problems */
-               labpc_counter_set_mode(dev, dev->iobase + COUNTER_A_BASE_REG,
-                                      0, I8254_MODE2);
+               ret = labpc_counter_set_mode(dev,
+                                            dev->iobase + COUNTER_A_BASE_REG,
+                                            0, I8254_MODE2);
+       }
+       if (ret) {
+               comedi_error(dev, "error loading counter a0");
+               return ret;
        }
 
        /*  set up scan pacing */