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>
This commit is contained in:
parent
9b3e5aec9b
commit
49b71ebab2
1 changed files with 19 additions and 16 deletions
|
@ -648,31 +648,34 @@ static int dmm32at_dio_insn_bits(struct comedi_device *dev,
|
||||||
|
|
||||||
static int dmm32at_dio_insn_config(struct comedi_device *dev,
|
static int dmm32at_dio_insn_config(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 dmm32at_private *devpriv = dev->private;
|
struct dmm32at_private *devpriv = dev->private;
|
||||||
|
unsigned int chan = CR_CHAN(insn->chanspec);
|
||||||
|
unsigned int mask;
|
||||||
unsigned char chanbit;
|
unsigned char chanbit;
|
||||||
int chan = CR_CHAN(insn->chanspec);
|
int ret;
|
||||||
|
|
||||||
if (insn->n != 1)
|
if (chan < 8) {
|
||||||
return -EINVAL;
|
mask = 0x0000ff;
|
||||||
|
|
||||||
if (chan < 8)
|
|
||||||
chanbit = DMM32AT_DIRA;
|
chanbit = DMM32AT_DIRA;
|
||||||
else if (chan < 16)
|
} else if (chan < 16) {
|
||||||
|
mask = 0x00ff00;
|
||||||
chanbit = DMM32AT_DIRB;
|
chanbit = DMM32AT_DIRB;
|
||||||
else if (chan < 20)
|
} else if (chan < 20) {
|
||||||
|
mask = 0x0f0000;
|
||||||
chanbit = DMM32AT_DIRCL;
|
chanbit = DMM32AT_DIRCL;
|
||||||
else
|
} else {
|
||||||
|
mask = 0xf00000;
|
||||||
chanbit = DMM32AT_DIRCH;
|
chanbit = DMM32AT_DIRCH;
|
||||||
|
}
|
||||||
|
|
||||||
/* The input or output configuration of each digital line is
|
ret = comedi_dio_insn_config(dev, s, insn, data, mask);
|
||||||
* configured by a special insn_config instruction. chanspec
|
if (ret)
|
||||||
* contains the channel to be changed, and data[0] contains the
|
return ret;
|
||||||
* value COMEDI_INPUT or COMEDI_OUTPUT. */
|
|
||||||
|
|
||||||
/* if output clear the bit, otherwise set it */
|
if (data[0] == INSN_CONFIG_DIO_OUTPUT)
|
||||||
if (data[0] == COMEDI_OUTPUT)
|
|
||||||
devpriv->dio_config &= ~chanbit;
|
devpriv->dio_config &= ~chanbit;
|
||||||
else
|
else
|
||||||
devpriv->dio_config |= chanbit;
|
devpriv->dio_config |= chanbit;
|
||||||
|
@ -681,7 +684,7 @@ static int dmm32at_dio_insn_config(struct comedi_device *dev,
|
||||||
/* set the DIO's to the new configuration setting */
|
/* set the DIO's to the new configuration setting */
|
||||||
outb(devpriv->dio_config, dev->iobase + DMM32AT_DIOCONF);
|
outb(devpriv->dio_config, dev->iobase + DMM32AT_DIOCONF);
|
||||||
|
|
||||||
return 1;
|
return insn->n;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int dmm32at_attach(struct comedi_device *dev,
|
static int dmm32at_attach(struct comedi_device *dev,
|
||||||
|
|
Loading…
Add table
Reference in a new issue