Merge tag 'staging-5.2-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh...
[sfrench/cifs-2.6.git] / drivers / staging / comedi / drivers / ni_tio.c
index c1131a1622c019677a20d12739314c5565d6d0d4..b264db32a41170233a478c7f041f9f2974aaab43 100644 (file)
@@ -1681,9 +1681,11 @@ int ni_tio_insn_write(struct comedi_device *dev,
        unsigned int cidx = counter->counter_index;
        unsigned int chip = counter->chip_index;
        unsigned int load_reg;
+       unsigned int load_val;
 
        if (insn->n < 1)
                return 0;
+       load_val = data[insn->n - 1];
        switch (channel) {
        case 0:
                /*
@@ -1696,7 +1698,7 @@ int ni_tio_insn_write(struct comedi_device *dev,
                 * load register is already selected.
                 */
                load_reg = ni_tio_next_load_register(counter);
-               ni_tio_write(counter, data[0], load_reg);
+               ni_tio_write(counter, load_val, load_reg);
                ni_tio_set_bits_transient(counter, NITIO_CMD_REG(cidx),
                                          0, 0, GI_LOAD);
                /* restore load reg */
@@ -1704,17 +1706,17 @@ int ni_tio_insn_write(struct comedi_device *dev,
                             load_reg);
                break;
        case 1:
-               counter_dev->regs[chip][NITIO_LOADA_REG(cidx)] = data[0];
-               ni_tio_write(counter, data[0], NITIO_LOADA_REG(cidx));
+               counter_dev->regs[chip][NITIO_LOADA_REG(cidx)] = load_val;
+               ni_tio_write(counter, load_val, NITIO_LOADA_REG(cidx));
                break;
        case 2:
-               counter_dev->regs[chip][NITIO_LOADB_REG(cidx)] = data[0];
-               ni_tio_write(counter, data[0], NITIO_LOADB_REG(cidx));
+               counter_dev->regs[chip][NITIO_LOADB_REG(cidx)] = load_val;
+               ni_tio_write(counter, load_val, NITIO_LOADB_REG(cidx));
                break;
        default:
                return -EINVAL;
        }
-       return 0;
+       return insn->n;
 }
 EXPORT_SYMBOL_GPL(ni_tio_insn_write);