summaryrefslogtreecommitdiffstats
path: root/drivers/staging/comedi
diff options
context:
space:
mode:
authorH Hartley Sweeten <hsweeten@visionengravers.com>2013-02-04 16:44:17 -0700
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2013-02-05 11:18:58 -0800
commit6a911d8aa54bc79256e766580a19bbd91e76d48f (patch)
treee33dbecd43f57a65d58065711145bd550bba598d /drivers/staging/comedi
parent62100fefbc4f7f45149df1f537de17b4acf01391 (diff)
downloadop-kernel-dev-6a911d8aa54bc79256e766580a19bbd91e76d48f.zip
op-kernel-dev-6a911d8aa54bc79256e766580a19bbd91e76d48f.tar.gz
staging: comedi: quatech_daqp_cs: use (*insn_bits) for digital outputs
Change the subdevice operation used to write the digital outputs from a (*insn_write) to a (*insn_bits) function. The (*insn_write) functions are expected to write 'insn->n' number of samples. The (*insn_bits) functions just write a single sample (insn->n = 1). Change the return from '1' to 'insn->n' to clarify what the return is. Using an (*insn_bits) function to write the digital outputs also allows the user to read the current state of the output channels. Fix the io operation used to update the digital outputs. The register is only 8-bits and should by updated with an outb() not an outw(). Also, set the 'maxdata' for the subdevice. For digital io this value should be '1' (digital io can only be 1 or 0). Remove the setting of the len_chanlist for the subdevice. This variable only has meaning for subdevices that support asynchronous commands. The comedi core will initialize it appropriately during the postconfig. 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')
-rw-r--r--drivers/staging/comedi/drivers/quatech_daqp_cs.c26
1 files changed, 17 insertions, 9 deletions
diff --git a/drivers/staging/comedi/drivers/quatech_daqp_cs.c b/drivers/staging/comedi/drivers/quatech_daqp_cs.c
index dbb8593..f111042 100644
--- a/drivers/staging/comedi/drivers/quatech_daqp_cs.c
+++ b/drivers/staging/comedi/drivers/quatech_daqp_cs.c
@@ -686,20 +686,28 @@ static int daqp_di_insn_bits(struct comedi_device *dev,
return insn->n;
}
-/* Digital output routine */
-
-static int daqp_do_insn_write(struct comedi_device *dev,
- struct comedi_subdevice *s,
- struct comedi_insn *insn, unsigned int *data)
+static int daqp_do_insn_bits(struct comedi_device *dev,
+ struct comedi_subdevice *s,
+ struct comedi_insn *insn,
+ unsigned int *data)
{
struct daqp_private *devpriv = dev->private;
+ unsigned int mask = data[0];
+ unsigned int bits = data[1];
if (devpriv->stop)
return -EIO;
- outw(data[0] & 0xf, dev->iobase + DAQP_DIGITAL_IO);
+ if (mask) {
+ s->state &= ~mask;
+ s->state |= (bits & mask);
- return 1;
+ outb(s->state, dev->iobase + DAQP_DIGITAL_IO);
+ }
+
+ data[1] = s->state;
+
+ return insn->n;
}
static int daqp_auto_attach(struct comedi_device *dev,
@@ -764,8 +772,8 @@ static int daqp_auto_attach(struct comedi_device *dev,
s->type = COMEDI_SUBD_DO;
s->subdev_flags = SDF_WRITEABLE;
s->n_chan = 1;
- s->len_chanlist = 1;
- s->insn_write = daqp_do_insn_write;
+ s->maxdata = 1;
+ s->insn_bits = daqp_do_insn_bits;
return 0;
}
OpenPOWER on IntegriCloud