Commit 6171667a authored by H Hartley Sweeten's avatar H Hartley Sweeten Committed by Greg Kroah-Hartman

staging: comedi: ni_mio_common: use comedi_dio_update_state()

Use comedi_dio_update_state() to handle the boilerplate code to update
the subdevice s->state.

Remove the DEBUG_DIO, its just added noise.
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 b3ff824a
...@@ -3547,28 +3547,22 @@ static int ni_dio_insn_config(struct comedi_device *dev, ...@@ -3547,28 +3547,22 @@ static int ni_dio_insn_config(struct comedi_device *dev,
static int ni_dio_insn_bits(struct comedi_device *dev, static int ni_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)
{ {
struct ni_private *devpriv = dev->private; struct ni_private *devpriv = dev->private;
#ifdef DEBUG_DIO /* Make sure we're not using the serial part of the dio */
printk("ni_dio_insn_bits() mask=0x%x bits=0x%x\n", data[0], data[1]); if ((data[0] & (DIO_SDIN | DIO_SDOUT)) && devpriv->serial_interval_ns)
#endif return -EBUSY;
if (data[0]) {
/* Perform check to make sure we're not using the
serial part of the dio */
if ((data[0] & (DIO_SDIN | DIO_SDOUT))
&& devpriv->serial_interval_ns)
return -EBUSY;
s->state &= ~data[0]; if (comedi_dio_update_state(s, data)) {
s->state |= (data[0] & data[1]);
devpriv->dio_output &= ~DIO_Parallel_Data_Mask; devpriv->dio_output &= ~DIO_Parallel_Data_Mask;
devpriv->dio_output |= DIO_Parallel_Data_Out(s->state); devpriv->dio_output |= DIO_Parallel_Data_Out(s->state);
devpriv->stc_writew(dev, devpriv->dio_output, devpriv->stc_writew(dev, devpriv->dio_output,
DIO_Output_Register); DIO_Output_Register);
} }
data[1] = devpriv->stc_readw(dev, DIO_Parallel_Input_Register); data[1] = devpriv->stc_readw(dev, DIO_Parallel_Input_Register);
return insn->n; return insn->n;
...@@ -3598,16 +3592,9 @@ static int ni_m_series_dio_insn_bits(struct comedi_device *dev, ...@@ -3598,16 +3592,9 @@ static int ni_m_series_dio_insn_bits(struct comedi_device *dev,
{ {
struct ni_private *devpriv __maybe_unused = dev->private; struct ni_private *devpriv __maybe_unused = dev->private;
#ifdef DEBUG_DIO if (comedi_dio_update_state(s, data))
printk("ni_m_series_dio_insn_bits() mask=0x%x bits=0x%x\n", data[0],
data[1]);
#endif
if (data[0]) {
s->state &= ~data[0];
s->state |= (data[0] & data[1]);
ni_writel(s->state, M_Offset_Static_Digital_Output); ni_writel(s->state, M_Offset_Static_Digital_Output);
}
data[1] = ni_readl(M_Offset_Static_Digital_Input); data[1] = ni_readl(M_Offset_Static_Digital_Input);
return insn->n; return insn->n;
...@@ -5355,20 +5342,20 @@ static int ni_config_filter(struct comedi_device *dev, unsigned pfi_channel, ...@@ -5355,20 +5342,20 @@ static int ni_config_filter(struct comedi_device *dev, unsigned pfi_channel,
static int ni_pfi_insn_bits(struct comedi_device *dev, static int ni_pfi_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)
{ {
const struct ni_board_struct *board = comedi_board(dev); const struct ni_board_struct *board = comedi_board(dev);
struct ni_private *devpriv __maybe_unused = dev->private; 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))
return -ENOTSUPP; return -ENOTSUPP;
}
if (data[0]) { if (comedi_dio_update_state(s, data))
s->state &= ~data[0];
s->state |= (data[0] & data[1]);
ni_writew(s->state, M_Offset_PFI_DO); ni_writew(s->state, M_Offset_PFI_DO);
}
data[1] = ni_readw(M_Offset_PFI_DI); data[1] = ni_readw(M_Offset_PFI_DI);
return insn->n; return insn->n;
} }
......
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