summaryrefslogtreecommitdiff
path: root/drivers/staging/comedi/drivers/dt9812.c
diff options
context:
space:
mode:
authorH Hartley Sweeten <hsweeten@visionengravers.com>2013-05-14 14:32:42 -0700
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2013-05-16 16:26:02 -0700
commit36c973d0896a5319cf3089c20e8d9881bc60297e (patch)
treeeb1b12d147510d6d685880c91a696635e2a989be /drivers/staging/comedi/drivers/dt9812.c
parente81eaba6c425a5d06623e5ad93cb7b3c096e8d5c (diff)
staging: comedi: dt9812: convert digital out subdevice to (*insn_bits)
Currently the (*insn_write) function for the digital output subdevice only sets the state for a single channel. It's more efficent to use the (*insn_bits) function and allow setting the state for all the channels. The comedi core can use the (*insn_bits) to emulate the (*insn_write) if needed. Also, use the subdevice 'state' variable to hold the current state of the channels instead of 'do_shadow' in the private data. 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>
Diffstat (limited to 'drivers/staging/comedi/drivers/dt9812.c')
-rw-r--r--drivers/staging/comedi/drivers/dt9812.c45
1 files changed, 15 insertions, 30 deletions
diff --git a/drivers/staging/comedi/drivers/dt9812.c b/drivers/staging/comedi/drivers/dt9812.c
index 4fd15162f4b6..7f6d43a33de3 100644
--- a/drivers/staging/comedi/drivers/dt9812.c
+++ b/drivers/staging/comedi/drivers/dt9812.c
@@ -265,7 +265,6 @@ struct dt9812_private {
} cmd_wr, cmd_rd;
u16 device;
u16 ao_shadow[2];
- u8 do_shadow;
};
static int dt9812_read_info(struct comedi_device *dev,
@@ -390,23 +389,11 @@ static int dt9812_digital_out(struct comedi_device *dev, u8 bits)
down(&devpriv->sem);
ret = dt9812_write_multiple_registers(dev, 1, reg, value);
- devpriv->do_shadow = bits;
up(&devpriv->sem);
return ret;
}
-static int dt9812_digital_out_shadow(struct comedi_device *dev, u8 *bits)
-{
- struct dt9812_private *devpriv = dev->private;
-
- down(&devpriv->sem);
- *bits = devpriv->do_shadow;
- up(&devpriv->sem);
-
- return 0;
-}
-
static void dt9812_configure_mux(struct comedi_device *dev,
struct dt9812_rmw_byte *rmw, int channel)
{
@@ -624,24 +611,24 @@ static int dt9812_di_insn_bits(struct comedi_device *dev,
return insn->n;
}
-static int dt9812_do_winsn(struct comedi_device *dev,
- struct comedi_subdevice *s, struct comedi_insn *insn,
- unsigned int *data)
+static int dt9812_do_insn_bits(struct comedi_device *dev,
+ struct comedi_subdevice *s,
+ struct comedi_insn *insn,
+ unsigned int *data)
{
- unsigned int channel = CR_CHAN(insn->chanspec);
- int n;
- u8 bits = 0;
+ unsigned int mask = data[0];
+ unsigned int bits = data[1];
- dt9812_digital_out_shadow(dev, &bits);
- for (n = 0; n < insn->n; n++) {
- u8 mask = 1 << channel;
+ if (mask) {
+ s->state &= ~mask;
+ s->state |= (bits & mask);
- bits &= ~mask;
- if (data[n])
- bits |= mask;
+ dt9812_digital_out(dev, s->state);
}
- dt9812_digital_out(dev, bits);
- return n;
+
+ data[1] = s->state;
+
+ return insn->n;
}
static int dt9812_ai_rinsn(struct comedi_device *dev,
@@ -849,9 +836,7 @@ static int dt9812_auto_attach(struct comedi_device *dev,
s->n_chan = 8;
s->maxdata = 1;
s->range_table = &range_digital;
- s->insn_write = dt9812_do_winsn;
-
- devpriv->do_shadow = 0;
+ s->insn_bits = dt9812_do_insn_bits;
/* Analog Input subdevice */
s = &dev->subdevices[2];