Re: [PATCH 08/11] staging: comedi: drivers: more users of comedi_dio_insn_bits()

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 2013-08-28 21:30, H Hartley Sweeten wrote:
Convert a couple more comedi drivers to use comedi_dio_insn_bits() to
handle the boilerplate code to update the subdevice s->state.

Signed-off-by: H Hartley Sweeten <hsweeten@xxxxxxxxxxxxxxxxxxx>
Cc: Ian Abbott <abbotti@xxxxxxxxx>
Cc: Greg Kroah-Hartman <gregkh@xxxxxxxxxxxxxxxxxxx>
---
  .../staging/comedi/drivers/amplc_dio200_common.c   | 22 +++++++++-------------
  drivers/staging/comedi/drivers/cb_pcidas64.c       | 14 +++-----------
  drivers/staging/comedi/drivers/ni_mio_common.c     | 20 +++++++++-----------
  3 files changed, 21 insertions(+), 35 deletions(-)

diff --git a/drivers/staging/comedi/drivers/amplc_dio200_common.c b/drivers/staging/comedi/drivers/amplc_dio200_common.c
index 8c6fa1e..0fc0081 100644
--- a/drivers/staging/comedi/drivers/amplc_dio200_common.c
+++ b/drivers/staging/comedi/drivers/amplc_dio200_common.c
@@ -946,26 +946,22 @@ static void dio200_subdev_8255_set_dir(struct comedi_device *dev,
   */
  static int dio200_subdev_8255_bits(struct comedi_device *dev,
  				   struct comedi_subdevice *s,
-				   struct comedi_insn *insn, unsigned int *data)
+				   struct comedi_insn *insn,
+				   unsigned int *data)
  {
  	struct dio200_subdev_8255 *subpriv = s->private;

-	if (data[0]) {
-		s->state &= ~data[0];
-		s->state |= (data[0] & data[1]);
-		if (data[0] & 0xff)
-			dio200_write8(dev, subpriv->ofs, s->state & 0xff);
-		if (data[0] & 0xff00)
-			dio200_write8(dev, subpriv->ofs + 1,
-				      (s->state >> 8) & 0xff);
-		if (data[0] & 0xff0000)
-			dio200_write8(dev, subpriv->ofs + 2,
-				      (s->state >> 16) & 0xff);
+	if (comedi_dio_insn_bits(dev, s, insn, data)) {
+		dio200_write8(dev, subpriv->ofs, s->state & 0xff);
+		dio200_write8(dev, subpriv->ofs + 1, (s->state >> 8) & 0xff);
+		dio200_write8(dev, subpriv->ofs + 2, (s->state >> 16) & 0xff);
  	}
+
  	data[1] = dio200_read8(dev, subpriv->ofs);
  	data[1] |= dio200_read8(dev, subpriv->ofs + 1) << 8;
  	data[1] |= dio200_read8(dev, subpriv->ofs + 2) << 16;
-	return 2;
+
+	return insn->n;
  }

  /*

amplc_dio200_common is another one of those that filtered register writes according to the mask. As for the 8255 module, this change may change the state of more output pins than the original code due to the side effects of I/O direction configuration on the 8255 chip.

(It could be argued that following an INSN_CONFIG_DIO_INPUT or INSN_CONFIG_DIO_OUTPUT, drivers operating on 8255 chips should either reset s->state to 0 to reflect the physical side-effects of the chip, or rewrite s->state to the outputs. This is outside the scope of this patch though.)

[snip]

--
-=( Ian Abbott @ MEV Ltd.    E-mail: <abbotti@xxxxxxxxx>        )=-
-=( Tel: +44 (0)161 477 1898   FAX: +44 (0)161 718 3587         )=-
_______________________________________________
devel mailing list
devel@xxxxxxxxxxxxxxxxxxxxxx
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel




[Index of Archives]     [Linux Driver Backports]     [DMA Engine]     [Linux GPIO]     [Linux SPI]     [Video for Linux]     [Linux USB Devel]     [Linux Coverity]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [Yosemite Backpacking]
  Powered by Linux