staging: comedi: addi_apci_3120: fix digital input 'insn_bits' function
This driver does not follow the comedi API. The digital input 'insn_bits' function is supposed to return the status of all the input channels in data[1]. Currently this function returns the status in data[0]. Fix the function so it works like the comedi core expects. The core can then use the function to emulate the 'insn_read' function for individual channels. Signed-off-by: H Hartley Sweeten <hsweeten@visionengravers.com> Cc: Ian Abbott <abbotti@mev.co.uk> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
This commit is contained in:
parent
e9840e632a
commit
a7f4b3ca60
2 changed files with 9 additions and 49 deletions
|
@ -2186,57 +2186,18 @@ static int i_APCI3120_InsnReadTimer(struct comedi_device *dev,
|
||||||
return insn->n;
|
return insn->n;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
static int apci3120_di_insn_bits(struct comedi_device *dev,
|
||||||
* Reads the value of the specified Digital input channel
|
struct comedi_subdevice *s,
|
||||||
*/
|
struct comedi_insn *insn,
|
||||||
static int i_APCI3120_InsnReadDigitalInput(struct comedi_device *dev,
|
unsigned int *data)
|
||||||
struct comedi_subdevice *s,
|
|
||||||
struct comedi_insn *insn,
|
|
||||||
unsigned int *data)
|
|
||||||
{
|
{
|
||||||
struct addi_private *devpriv = dev->private;
|
struct addi_private *devpriv = dev->private;
|
||||||
unsigned int ui_Chan, ui_TmpValue;
|
unsigned int val;
|
||||||
|
|
||||||
ui_Chan = CR_CHAN(insn->chanspec); /* channel specified */
|
/* the input channels are bits 11:8 of the status reg */
|
||||||
|
val = inw(devpriv->iobase + APCI3120_RD_STATUS);
|
||||||
|
data[1] = (val >> 8) & 0xf;
|
||||||
|
|
||||||
/* this_board->di_read(dev,ui_Chan,data); */
|
|
||||||
if (ui_Chan <= 3) {
|
|
||||||
ui_TmpValue = (unsigned int) inw(devpriv->iobase + APCI3120_RD_STATUS);
|
|
||||||
|
|
||||||
/*
|
|
||||||
* since only 1 channel reqd to bring it to last bit it is rotated 8
|
|
||||||
* +(chan - 1) times then ANDed with 1 for last bit.
|
|
||||||
*/
|
|
||||||
*data = (ui_TmpValue >> (ui_Chan + 8)) & 1;
|
|
||||||
/* return 0; */
|
|
||||||
} else {
|
|
||||||
/* comedi_error(dev," chan spec wrong"); */
|
|
||||||
return -EINVAL; /* "sorry channel spec wrong " */
|
|
||||||
}
|
|
||||||
return insn->n;
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Reads the value of the Digital input Port i.e.4channels
|
|
||||||
* value is returned in data[0]
|
|
||||||
*/
|
|
||||||
static int i_APCI3120_InsnBitsDigitalInput(struct comedi_device *dev,
|
|
||||||
struct comedi_subdevice *s,
|
|
||||||
struct comedi_insn *insn,
|
|
||||||
unsigned int *data)
|
|
||||||
{
|
|
||||||
struct addi_private *devpriv = dev->private;
|
|
||||||
unsigned int ui_TmpValue;
|
|
||||||
|
|
||||||
ui_TmpValue = (unsigned int) inw(devpriv->iobase + APCI3120_RD_STATUS);
|
|
||||||
/***** state of 4 channels in the 11, 10, 9, 8 bits of status reg
|
|
||||||
rotated right 8 times to bring them to last four bits
|
|
||||||
ANDed with oxf for value.
|
|
||||||
*****/
|
|
||||||
|
|
||||||
*data = (ui_TmpValue >> 8) & 0xf;
|
|
||||||
/* this_board->di_bits(dev,data); */
|
|
||||||
return insn->n;
|
return insn->n;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -179,8 +179,7 @@ static int apci3120_attach_pci(struct comedi_device *dev,
|
||||||
s->len_chanlist = this_board->i_NbrDiChannel;
|
s->len_chanlist = this_board->i_NbrDiChannel;
|
||||||
s->range_table = &range_digital;
|
s->range_table = &range_digital;
|
||||||
s->io_bits = 0; /* all bits input */
|
s->io_bits = 0; /* all bits input */
|
||||||
s->insn_read = i_APCI3120_InsnReadDigitalInput;
|
s->insn_bits = apci3120_di_insn_bits;
|
||||||
s->insn_bits = i_APCI3120_InsnBitsDigitalInput;
|
|
||||||
|
|
||||||
/* Allocate and Initialise DO Subdevice Structures */
|
/* Allocate and Initialise DO Subdevice Structures */
|
||||||
s = &dev->subdevices[3];
|
s = &dev->subdevices[3];
|
||||||
|
|
Loading…
Reference in a new issue