diff options
author | H Hartley Sweeten <hsweeten@visionengravers.com> | 2013-08-26 18:29:10 -0400 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2013-08-27 19:59:08 -0400 |
commit | 49b71ebab2b40ffec19007e8b4dba6b8f8622f46 (patch) | |
tree | b14e97cb56a97cad1ad5307af2b185b5d07c3a84 | |
parent | 9b3e5aec9b275a6a7bad48f2dc2c2dcfd38a4779 (diff) |
staging: comedi: dmm32at: fix dmm32at_dio_insn_config()
This is the (*insn_config) function for a DIO subdevice. It should be
using the data[0] value as the "instruction" to perform on the subdevice.
Use the comedi_dio_insn_config() helper to properly handle instructions.
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>
-rw-r--r-- | drivers/staging/comedi/drivers/dmm32at.c | 35 |
1 files changed, 19 insertions, 16 deletions
diff --git a/drivers/staging/comedi/drivers/dmm32at.c b/drivers/staging/comedi/drivers/dmm32at.c index 5237f47d39ae..118a4fd129f9 100644 --- a/drivers/staging/comedi/drivers/dmm32at.c +++ b/drivers/staging/comedi/drivers/dmm32at.c | |||
@@ -648,31 +648,34 @@ static int dmm32at_dio_insn_bits(struct comedi_device *dev, | |||
648 | 648 | ||
649 | static int dmm32at_dio_insn_config(struct comedi_device *dev, | 649 | static int dmm32at_dio_insn_config(struct comedi_device *dev, |
650 | struct comedi_subdevice *s, | 650 | struct comedi_subdevice *s, |
651 | struct comedi_insn *insn, unsigned int *data) | 651 | struct comedi_insn *insn, |
652 | unsigned int *data) | ||
652 | { | 653 | { |
653 | struct dmm32at_private *devpriv = dev->private; | 654 | struct dmm32at_private *devpriv = dev->private; |
655 | unsigned int chan = CR_CHAN(insn->chanspec); | ||
656 | unsigned int mask; | ||
654 | unsigned char chanbit; | 657 | unsigned char chanbit; |
655 | int chan = CR_CHAN(insn->chanspec); | 658 | int ret; |
656 | |||
657 | if (insn->n != 1) | ||
658 | return -EINVAL; | ||
659 | 659 | ||
660 | if (chan < 8) | 660 | if (chan < 8) { |
661 | mask = 0x0000ff; | ||
661 | chanbit = DMM32AT_DIRA; | 662 | chanbit = DMM32AT_DIRA; |
662 | else if (chan < 16) | 663 | } else if (chan < 16) { |
664 | mask = 0x00ff00; | ||
663 | chanbit = DMM32AT_DIRB; | 665 | chanbit = DMM32AT_DIRB; |
664 | else if (chan < 20) | 666 | } else if (chan < 20) { |
667 | mask = 0x0f0000; | ||
665 | chanbit = DMM32AT_DIRCL; | 668 | chanbit = DMM32AT_DIRCL; |
666 | else | 669 | } else { |
670 | mask = 0xf00000; | ||
667 | chanbit = DMM32AT_DIRCH; | 671 | chanbit = DMM32AT_DIRCH; |
672 | } | ||
668 | 673 | ||
669 | /* The input or output configuration of each digital line is | 674 | ret = comedi_dio_insn_config(dev, s, insn, data, mask); |
670 | * configured by a special insn_config instruction. chanspec | 675 | if (ret) |
671 | * contains the channel to be changed, and data[0] contains the | 676 | return ret; |
672 | * value COMEDI_INPUT or COMEDI_OUTPUT. */ | ||
673 | 677 | ||
674 | /* if output clear the bit, otherwise set it */ | 678 | if (data[0] == INSN_CONFIG_DIO_OUTPUT) |
675 | if (data[0] == COMEDI_OUTPUT) | ||
676 | devpriv->dio_config &= ~chanbit; | 679 | devpriv->dio_config &= ~chanbit; |
677 | else | 680 | else |
678 | devpriv->dio_config |= chanbit; | 681 | devpriv->dio_config |= chanbit; |
@@ -681,7 +684,7 @@ static int dmm32at_dio_insn_config(struct comedi_device *dev, | |||
681 | /* set the DIO's to the new configuration setting */ | 684 | /* set the DIO's to the new configuration setting */ |
682 | outb(devpriv->dio_config, dev->iobase + DMM32AT_DIOCONF); | 685 | outb(devpriv->dio_config, dev->iobase + DMM32AT_DIOCONF); |
683 | 686 | ||
684 | return 1; | 687 | return insn->n; |
685 | } | 688 | } |
686 | 689 | ||
687 | static int dmm32at_attach(struct comedi_device *dev, | 690 | static int dmm32at_attach(struct comedi_device *dev, |