staging: comedi: quatech_daqp_cs: use (*insn_bits) for digital outputs
authorH Hartley Sweeten <hsweeten@visionengravers.com>
Mon, 4 Feb 2013 23:44:17 +0000 (16:44 -0700)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Tue, 5 Feb 2013 19:18:58 +0000 (11:18 -0800)
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>
drivers/staging/comedi/drivers/quatech_daqp_cs.c

index dbb8593a8db84692d2ad740933165ff4e4433603..f11104252c9690f0a70351c924e5ad2aa3de3f18 100644 (file)
@@ -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;
 }
This page took 0.02588 seconds and 5 git commands to generate.