staging: comedi: adq12b: remove digital_state from private data
authorH Hartley Sweeten <hsweeten@visionengravers.com>
Fri, 30 Aug 2013 18:08:31 +0000 (11:08 -0700)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Tue, 17 Sep 2013 14:47:41 +0000 (07:47 -0700)
Use the subdevice 'state' variable instead of carrying the state of
the output channels in the private data.

Use comedi_dio_update_state() to handle the boilerplate code to update
the subdevice s->state.

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

index cdf5ba26c5904fdd93db071dc59c51addca83f7a..8150a67cd1fbf99927db2220dbb40bb0847c46b1 100644 (file)
@@ -119,7 +119,6 @@ struct adq12b_private {
        int differential;       /* option 3 of comedi_config */
        int last_channel;
        int last_range;
-       unsigned int digital_state;
 };
 
 /*
@@ -186,23 +185,25 @@ static int adq12b_di_insn_bits(struct comedi_device *dev,
 
 static int adq12b_do_insn_bits(struct comedi_device *dev,
                               struct comedi_subdevice *s,
-                              struct comedi_insn *insn, unsigned int *data)
+                              struct comedi_insn *insn,
+                              unsigned int *data)
 {
-       struct adq12b_private *devpriv = dev->private;
-       int channel;
-
-       for (channel = 0; channel < 8; channel++)
-               if (((data[0] >> channel) & 0x01) != 0)
-                       outb((((data[1] >> channel) & 0x01) << 3) | channel,
-                            dev->iobase + ADQ12B_OUTBR);
-
-       /* store information to retrieve when asked for reading */
-       if (data[0]) {
-               devpriv->digital_state &= ~data[0];
-               devpriv->digital_state |= (data[0] & data[1]);
+       unsigned int mask;
+       unsigned int chan;
+       unsigned int val;
+
+       mask = comedi_dio_update_state(s, data);
+       if (mask) {
+               for (chan = 0; chan < 8; chan++) {
+                       if ((mask >> chan) & 0x01) {
+                               val = (s->state >> chan) & 0x01;
+                               outb((val << 3) | chan,
+                                    dev->iobase + ADQ12B_OUTBR);
+                       }
+               }
        }
 
-       data[1] = devpriv->digital_state;
+       data[1] = s->state;
 
        return insn->n;
 }
@@ -223,7 +224,6 @@ static int adq12b_attach(struct comedi_device *dev, struct comedi_devconfig *it)
 
        devpriv->unipolar = it->options[1];
        devpriv->differential = it->options[2];
-       devpriv->digital_state = 0;
        /*
         * initialize channel and range to -1 so we make sure we
         * always write at least once to the CTREG in the instruction
This page took 0.027264 seconds and 5 git commands to generate.