Commit b2c20d15 authored by H Hartley Sweeten's avatar H Hartley Sweeten Committed by Greg Kroah-Hartman

staging: comedi: adq12b: remove digital_state from private data

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: default avatarH Hartley Sweeten <hsweeten@visionengravers.com>
Reviewed-by: default avatarIan Abbott <abbotti@mev.co.uk>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent e49242a4
...@@ -119,7 +119,6 @@ struct adq12b_private { ...@@ -119,7 +119,6 @@ struct adq12b_private {
int differential; /* option 3 of comedi_config */ int differential; /* option 3 of comedi_config */
int last_channel; int last_channel;
int last_range; int last_range;
unsigned int digital_state;
}; };
/* /*
...@@ -186,23 +185,25 @@ static int adq12b_di_insn_bits(struct comedi_device *dev, ...@@ -186,23 +185,25 @@ static int adq12b_di_insn_bits(struct comedi_device *dev,
static int adq12b_do_insn_bits(struct comedi_device *dev, static int adq12b_do_insn_bits(struct comedi_device *dev,
struct comedi_subdevice *s, struct comedi_subdevice *s,
struct comedi_insn *insn, unsigned int *data) struct comedi_insn *insn,
unsigned int *data)
{ {
struct adq12b_private *devpriv = dev->private; unsigned int mask;
int channel; unsigned int chan;
unsigned int val;
for (channel = 0; channel < 8; channel++)
if (((data[0] >> channel) & 0x01) != 0) mask = comedi_dio_update_state(s, data);
outb((((data[1] >> channel) & 0x01) << 3) | channel, 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); 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]);
} }
data[1] = devpriv->digital_state; data[1] = s->state;
return insn->n; return insn->n;
} }
...@@ -223,7 +224,6 @@ static int adq12b_attach(struct comedi_device *dev, struct comedi_devconfig *it) ...@@ -223,7 +224,6 @@ static int adq12b_attach(struct comedi_device *dev, struct comedi_devconfig *it)
devpriv->unipolar = it->options[1]; devpriv->unipolar = it->options[1];
devpriv->differential = it->options[2]; devpriv->differential = it->options[2];
devpriv->digital_state = 0;
/* /*
* initialize channel and range to -1 so we make sure we * initialize channel and range to -1 so we make sure we
* always write at least once to the CTREG in the instruction * always write at least once to the CTREG in the instruction
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment