Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 18c93c36 authored by H Hartley Sweeten's avatar H Hartley Sweeten Committed by Greg Kroah-Hartman
Browse files

staging: comedi: skel: use comedi_dio_update_state()



Convert this driver to use the comedi_dio_update_state() helper
function.

Tidy up the comments to reflect the new code.

Signed-off-by: default avatarH Hartley Sweeten <hsweeten@visionengravers.com>
Reviewed-by: default avatarIan Abbott <abbotti@mev.co.uk>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent 05e60b13
Loading
Loading
Loading
Loading
+30 −16
Original line number Original line Diff line number Diff line
@@ -332,29 +332,43 @@ static int skel_ao_rinsn(struct comedi_device *dev, struct comedi_subdevice *s,
	return i;
	return i;
}
}


/* DIO devices are slightly special.  Although it is possible to
/*
 * DIO devices are slightly special. Although it is possible to
 * implement the insn_read/insn_write interface, it is much more
 * implement the insn_read/insn_write interface, it is much more
 * useful to applications if you implement the insn_bits interface.
 * useful to applications if you implement the insn_bits interface.
 * This allows packed reading/writing of the DIO channels. The
 * This allows packed reading/writing of the DIO channels. The
 * comedi core can convert between insn_bits and insn_read/write */
 * comedi core can convert between insn_bits and insn_read/write.
 */
static int skel_dio_insn_bits(struct comedi_device *dev,
static int skel_dio_insn_bits(struct comedi_device *dev,
			      struct comedi_subdevice *s,
			      struct comedi_subdevice *s,
			      struct comedi_insn *insn, unsigned int *data)
			      struct comedi_insn *insn,
			      unsigned int *data)
{
{
	/* The insn data is a mask in data[0] and the new data
	/*
	 * in data[1], each channel cooresponding to a bit. */
	 * The insn data is a mask in data[0] and the new data
	if (data[0]) {
	 * in data[1], each channel cooresponding to a bit.
		s->state &= ~data[0];
	 *
		s->state |= data[0] & data[1];
	 * The core provided comedi_dio_update_state() function can
	 * be used to handle the internal state update to DIO subdevices
	 * with <= 32 channels. This function will return '0' if the
	 * state does not change or the mask of the channels that need
	 * to be updated.
	 */
	if (comedi_dio_update_state(s, data)) {
		/* Write out the new digital output lines */
		/* Write out the new digital output lines */
		/* outw(s->state, dev->iobase + SKEL_DIO); */
		/* outw(s->state, dev->iobase + SKEL_DIO); */
	}
	}


	/* on return, data[1] contains the value of the digital
	/*
	 * input and output lines. */
	 * On return, data[1] contains the value of the digital
	 * input and output lines.
	 */
	/* data[1] = inw(dev->iobase + SKEL_DIO); */
	/* data[1] = inw(dev->iobase + SKEL_DIO); */
	/* or we could just return the software copy of the output values if

	 * it was a purely digital output subdevice */
	/*
	 * Or we could just return the software copy of the output
	 * values if it was a purely digital output subdevice.
	 */
	/* data[1] = s->state; */
	/* data[1] = s->state; */


	return insn->n;
	return insn->n;