The IO Select registers are readable. Remove the need for the 'dio_direction' member in the private data by just checking the register value for the INSN_CONFIG_DIO_QUERY instruction. Also, refactor the switch statement to return -EINVAL for unhandled instructions and have the (*insn_config) return insn->n normally. Signed-off-by: H Hartley Sweeten <hsweeten@xxxxxxxxxxxxxxxxxxx> Cc: Ian Abbott <abbotti@xxxxxxxxx> Cc: Greg Kroah-Hartman <gregk@xxxxxxxxxxxxxxxxxxx> --- drivers/staging/comedi/drivers/ni_65xx.c | 21 ++++++++++----------- 1 file changed, 10 insertions(+), 11 deletions(-) diff --git a/drivers/staging/comedi/drivers/ni_65xx.c b/drivers/staging/comedi/drivers/ni_65xx.c index c8cd0e1..4b3f504 100644 --- a/drivers/staging/comedi/drivers/ni_65xx.c +++ b/drivers/staging/comedi/drivers/ni_65xx.c @@ -272,7 +272,6 @@ static inline unsigned ni_65xx_total_num_ports(const struct ni_65xx_board struct ni_65xx_private { void __iomem *mmio; unsigned short output_bits[NI_65XX_MAX_NUM_PORTS]; - unsigned short dio_direction[NI_65XX_MAX_NUM_PORTS]; }; struct ni_65xx_subdevice_private { @@ -322,35 +321,35 @@ static int ni_65xx_dio_insn_config(struct comedi_device *dev, val &= ~chan_mask; } writeb(val, devpriv->mmio + NI_65XX_FILTER_ENA(port)); - - return insn->n; + break; case INSN_CONFIG_DIO_OUTPUT: if (s->type != COMEDI_SUBD_DIO) return -EINVAL; - devpriv->dio_direction[port] = COMEDI_OUTPUT; writeb(NI_65XX_IO_SEL_OUTPUT, devpriv->mmio + NI_65XX_IO_SEL_REG(port)); - return 1; break; + case INSN_CONFIG_DIO_INPUT: if (s->type != COMEDI_SUBD_DIO) return -EINVAL; - devpriv->dio_direction[port] = COMEDI_INPUT; writeb(NI_65XX_IO_SEL_INPUT, devpriv->mmio + NI_65XX_IO_SEL_REG(port)); - return 1; break; + case INSN_CONFIG_DIO_QUERY: if (s->type != COMEDI_SUBD_DIO) return -EINVAL; - data[1] = devpriv->dio_direction[port]; - return insn->n; + val = readb(devpriv->mmio + NI_65XX_IO_SEL_REG(port)); + data[1] = (val == NI_65XX_IO_SEL_INPUT) ? COMEDI_INPUT + : COMEDI_OUTPUT; break; + default: - break; + return -EINVAL; } - return -EINVAL; + + return insn->n; } static int ni_65xx_dio_insn_bits(struct comedi_device *dev, -- 1.9.3 _______________________________________________ devel mailing list devel@xxxxxxxxxxxxxxxxxxxxxx http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel