Skip to content

Commit 6a911d8

Browse files
bigguinessgregkh
authored andcommitted
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 <[email protected]> Cc: Ian Abbott <[email protected]> Signed-off-by: Greg Kroah-Hartman <[email protected]>
1 parent 62100fe commit 6a911d8

File tree

1 file changed

+17
-9
lines changed

1 file changed

+17
-9
lines changed

drivers/staging/comedi/drivers/quatech_daqp_cs.c

Lines changed: 17 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -686,20 +686,28 @@ static int daqp_di_insn_bits(struct comedi_device *dev,
686686
return insn->n;
687687
}
688688

689-
/* Digital output routine */
690-
691-
static int daqp_do_insn_write(struct comedi_device *dev,
692-
struct comedi_subdevice *s,
693-
struct comedi_insn *insn, unsigned int *data)
689+
static int daqp_do_insn_bits(struct comedi_device *dev,
690+
struct comedi_subdevice *s,
691+
struct comedi_insn *insn,
692+
unsigned int *data)
694693
{
695694
struct daqp_private *devpriv = dev->private;
695+
unsigned int mask = data[0];
696+
unsigned int bits = data[1];
696697

697698
if (devpriv->stop)
698699
return -EIO;
699700

700-
outw(data[0] & 0xf, dev->iobase + DAQP_DIGITAL_IO);
701+
if (mask) {
702+
s->state &= ~mask;
703+
s->state |= (bits & mask);
701704

702-
return 1;
705+
outb(s->state, dev->iobase + DAQP_DIGITAL_IO);
706+
}
707+
708+
data[1] = s->state;
709+
710+
return insn->n;
703711
}
704712

705713
static int daqp_auto_attach(struct comedi_device *dev,
@@ -764,8 +772,8 @@ static int daqp_auto_attach(struct comedi_device *dev,
764772
s->type = COMEDI_SUBD_DO;
765773
s->subdev_flags = SDF_WRITEABLE;
766774
s->n_chan = 1;
767-
s->len_chanlist = 1;
768-
s->insn_write = daqp_do_insn_write;
775+
s->maxdata = 1;
776+
s->insn_bits = daqp_do_insn_bits;
769777

770778
return 0;
771779
}

0 commit comments

Comments
 (0)