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

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: default avatarH Hartley Sweeten <hsweeten@visionengravers.com>
Cc: Ian Abbott <abbotti@mev.co.uk>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent 62100fef
......@@ -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,
static int daqp_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 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;
}
......
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