diff options
author | H Hartley Sweeten <hsweeten@visionengravers.com> | 2013-08-06 09:32:33 -0700 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2013-08-12 15:17:45 -0700 |
commit | ddf62f2c7bd041d35095b525ab33e3a3e0829aaa (patch) | |
tree | bd0ca1676c62fb3cfd2cda8762aab92c75c7d8e1 /drivers/staging/comedi/drivers/pcmmio.c | |
parent | f3508b2294516d39d60d68ddab67dd658721bdc9 (diff) | |
download | kernel_goldelico_gta04-ddf62f2c7bd041d35095b525ab33e3a3e0829aaa.tar.gz kernel_goldelico_gta04-ddf62f2c7bd041d35095b525ab33e3a3e0829aaa.tar.bz2 kernel_goldelico_gta04-ddf62f2c7bd041d35095b525ab33e3a3e0829aaa.zip |
staging: comedi: drivers: use comedi_dio_insn_config() for simple cases
Convert the drivers with simple, per channel programmable i/o, to use the
comedi_dio_insn_config() helper function.
All of these pass a 'mask' of '0' to comedi_dio_insn_config() this causes
the per channel mask to be used to configure the i/o direction.
Signed-off-by: H Hartley Sweeten <hsweeten@visionengravers.com>
Reviewed-by: Ian Abbott <abbotti@mev.co.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'drivers/staging/comedi/drivers/pcmmio.c')
-rw-r--r-- | drivers/staging/comedi/drivers/pcmmio.c | 71 |
1 files changed, 15 insertions, 56 deletions
diff --git a/drivers/staging/comedi/drivers/pcmmio.c b/drivers/staging/comedi/drivers/pcmmio.c index fab93a73651..aa3c0307483 100644 --- a/drivers/staging/comedi/drivers/pcmmio.c +++ b/drivers/staging/comedi/drivers/pcmmio.c @@ -310,68 +310,27 @@ static int pcmmio_dio_insn_bits(struct comedi_device *dev, return insn->n; } -/* The input or output configuration of each digital line is - * configured by a special insn_config instruction. chanspec - * contains the channel to be changed, and data[0] contains the - * value COMEDI_INPUT or COMEDI_OUTPUT. */ static int pcmmio_dio_insn_config(struct comedi_device *dev, struct comedi_subdevice *s, - struct comedi_insn *insn, unsigned int *data) + struct comedi_insn *insn, + unsigned int *data) { - int chan = CR_CHAN(insn->chanspec), byte_no = chan / 8, bit_no = - chan % 8; - unsigned long ioaddr; - unsigned char byte; - - /* Compute ioaddr for this channel */ - ioaddr = subpriv->iobases[byte_no]; - - /* NOTE: - writing a 0 an IO channel's bit sets the channel to INPUT - and pulls the line high as well - - writing a 1 to an IO channel's bit pulls the line low - - All channels are implicitly always in OUTPUT mode -- but when - they are high they can be considered to be in INPUT mode.. - - Thus, we only force channels low if the config request was INPUT, - otherwise we do nothing to the hardware. */ - - switch (data[0]) { - case INSN_CONFIG_DIO_OUTPUT: - /* save to io_bits -- don't actually do anything since - all input channels are also output channels... */ - s->io_bits |= 1 << chan; - break; - case INSN_CONFIG_DIO_INPUT: - /* write a 0 to the actual register representing the channel - to set it to 'input'. 0 means "float high". */ - byte = inb(ioaddr); - byte &= ~(1 << bit_no); - /**< set input channel to '0' */ - - /* - * write out byte -- this is the only time we actually affect - * the hardware as all channels are implicitly output - * -- but input channels are set to float-high - */ - outb(byte, ioaddr); + unsigned int chan = CR_CHAN(insn->chanspec); + int byte_no = chan / 8; + int bit_no = chan % 8; + int ret; - /* save to io_bits */ - s->io_bits &= ~(1 << chan); - break; + ret = comedi_dio_insn_config(dev, s, insn, data, 0); + if (ret) + return ret; - case INSN_CONFIG_DIO_QUERY: - /* retrieve from shadow register */ - data[1] = - (s->io_bits & (1 << chan)) ? COMEDI_OUTPUT : COMEDI_INPUT; - return insn->n; - break; + if (data[0] == INSN_CONFIG_DIO_INPUT) { + unsigned long ioaddr = subpriv->iobases[byte_no]; + unsigned char val; - default: - return -EINVAL; - break; + val = inb(ioaddr); + val &= ~(1 << bit_no); + outb(val, ioaddr); } return insn->n; |