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; } /* diff --git a/drivers/staging/comedi/drivers/cb_pcidas64.c b/drivers/staging/comedi/drivers/cb_pcidas64.c index 388dbd7..67c27b2 100644 --- a/drivers/staging/comedi/drivers/cb_pcidas64.c +++ b/drivers/staging/comedi/drivers/cb_pcidas64.c @@ -3495,13 +3495,8 @@ static int do_wbits(struct comedi_device *dev, struct comedi_subdevice *s, { struct pcidas64_private *devpriv = dev->private; - data[0] &= 0xf; - /* zero bits we are going to change */ - s->state &= ~data[0]; - /* set new bits */ - s->state |= data[0] & data[1]; - - writeb(s->state, devpriv->dio_counter_iobase + DO_REG); + if (comedi_dio_insn_bits(dev, s, insn, data)) + writeb(s->state, devpriv->dio_counter_iobase + DO_REG); data[1] = s->state; @@ -3531,12 +3526,9 @@ static int dio_60xx_wbits(struct comedi_device *dev, struct comedi_subdevice *s, { struct pcidas64_private *devpriv = dev->private; - if (data[0]) { - s->state &= ~data[0]; - s->state |= (data[0] & data[1]); + if (comedi_dio_insn_bits(dev, s, insn, data)) writeb(s->state, devpriv->dio_counter_iobase + DIO_DATA_60XX_REG); - } data[1] = readb(devpriv->dio_counter_iobase + DIO_DATA_60XX_REG); diff --git a/drivers/staging/comedi/drivers/ni_mio_common.c b/drivers/staging/comedi/drivers/ni_mio_common.c index c2c5d1f..9f1819f 100644 --- a/drivers/staging/comedi/drivers/ni_mio_common.c +++ b/drivers/staging/comedi/drivers/ni_mio_common.c @@ -3597,11 +3597,9 @@ static int ni_m_series_dio_insn_bits(struct comedi_device *dev, data[1]); #endif - if (data[0]) { - s->state &= ~data[0]; - s->state |= (data[0] & data[1]); + if (comedi_dio_insn_bits(dev, s, insn, data)) ni_writel(s->state, M_Offset_Static_Digital_Output); - } + data[1] = ni_readl(M_Offset_Static_Digital_Input); return insn->n; @@ -5349,20 +5347,20 @@ static int ni_config_filter(struct comedi_device *dev, unsigned pfi_channel, static int ni_pfi_insn_bits(struct comedi_device *dev, struct comedi_subdevice *s, - struct comedi_insn *insn, unsigned int *data) + struct comedi_insn *insn, + unsigned int *data) { const struct ni_board_struct *board = comedi_board(dev); struct ni_private *devpriv __maybe_unused = dev->private; - if ((board->reg_type & ni_reg_m_series_mask) == 0) { + if ((board->reg_type & ni_reg_m_series_mask) == 0) return -ENOTSUPP; - } - if (data[0]) { - s->state &= ~data[0]; - s->state |= (data[0] & data[1]); + + if (comedi_dio_insn_bits(dev, s, insn, data)) ni_writew(s->state, M_Offset_PFI_DO); - } + data[1] = ni_readw(M_Offset_PFI_DI); + return insn->n; } -- 1.8.3.2 _______________________________________________ devel mailing list devel@xxxxxxxxxxxxxxxxxxxxxx http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel