diff options
author | H Hartley Sweeten <hsweeten@visionengravers.com> | 2013-08-06 09:33:05 -0700 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2013-08-12 15:14:47 -0700 |
commit | 5dacadcca3176e2b1f8db662e503c080484d71fa (patch) | |
tree | 72149f0663fd6e5eddf7594652fa2c7f8135ae1a /drivers/staging/comedi/drivers/adv_pci1723.c | |
parent | e495dd833b2345f89888378c6ec7456995791087 (diff) |
staging: comedi: drivers: use comedi_dio_insn_config() for complex cases
Convert the drivers with complex, port programmable i/o, to use the
comedi_dio_insn_config() helper function.
All of these drivers have some sort of 'port' programmable i/o where multiple
i/o channels are configured as a group. The 'mask' associated with the group
is passed to comedi_dio_insn_config() so that all the channels are configured.
Signed-off-by: H Hartley Sweeten <hsweeten@visionengravers.com>
Reviewed-by: Ian Abbott <abbotti@mev.co.uk>
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'drivers/staging/comedi/drivers/adv_pci1723.c')
-rw-r--r-- | drivers/staging/comedi/drivers/adv_pci1723.c | 43 |
1 files changed, 17 insertions, 26 deletions
diff --git a/drivers/staging/comedi/drivers/adv_pci1723.c b/drivers/staging/comedi/drivers/adv_pci1723.c index f914fb1f571b..b793d6987b84 100644 --- a/drivers/staging/comedi/drivers/adv_pci1723.c +++ b/drivers/staging/comedi/drivers/adv_pci1723.c @@ -180,38 +180,29 @@ static int pci1723_dio_insn_config(struct comedi_device *dev, struct comedi_subdevice *s, struct comedi_insn *insn, unsigned int *data) { + unsigned int chan = CR_CHAN(insn->chanspec); unsigned int mask; - unsigned int bits; - unsigned short dio_mode; + unsigned short mode; + int ret; - mask = 1 << CR_CHAN(insn->chanspec); - if (mask & 0x00FF) - bits = 0x00FF; + if (chan < 8) + mask = 0x00ff; else - bits = 0xFF00; + mask = 0xff00; - switch (data[0]) { - case INSN_CONFIG_DIO_INPUT: - s->io_bits &= ~bits; - break; - case INSN_CONFIG_DIO_OUTPUT: - s->io_bits |= bits; - break; - case INSN_CONFIG_DIO_QUERY: - data[1] = (s->io_bits & bits) ? COMEDI_OUTPUT : COMEDI_INPUT; - return insn->n; - default: - return -EINVAL; - } + ret = comedi_dio_insn_config(dev, s, insn, data, mask); + if (ret) + return ret; /* update hardware DIO mode */ - dio_mode = 0x0000; /* low byte output, high byte output */ - if ((s->io_bits & 0x00FF) == 0) - dio_mode |= 0x0001; /* low byte input */ - if ((s->io_bits & 0xFF00) == 0) - dio_mode |= 0x0002; /* high byte input */ - outw(dio_mode, dev->iobase + PCI1723_DIGITAL_IO_PORT_SET); - return 1; + mode = 0x0000; /* assume output */ + if (!(s->io_bits & 0x00ff)) + mode |= 0x0001; /* low byte input */ + if (!(s->io_bits & 0xff00)) + mode |= 0x0002; /* high byte input */ + outw(mode, dev->iobase + PCI1723_DIGITAL_IO_PORT_SET); + + return insn->n; } /* |