Commit 953a36c4 authored by H Hartley Sweeten's avatar H Hartley Sweeten Committed by Greg Kroah-Hartman

staging: comedi: addi_apci_3501: cleanup the digital output subdevice

The board supported by this driver has 2 digital outputs. Remove the
conditional and always init the subdevice.

Also, move the subdevice insn_bits function pointer as well as the
n_chan out of the boardinfo and use them to initialize the subdevice
directly.

Since devpriv->s_EeParameters for the digital output subdevice are no
longer being used, remove initialization of them also.

Copy the apci3501_do_insn_bits() function from hwrdv_apci3501.c into
the main driver file.

Fix the subdev_flags for the subdevice. The only required flag is
SDF_WRITEABLE. The SDF_GROUND and SDF_COMMON flags only have meaning
for analog subdevices and the SDF_READABLE flag is not required.

Fix the maxdata for the subdevice. Digital outputs can only be 1 or 0.

Remove the len_chanlist initialization, it only has meaning for subdevices
that support commands.

Remove the io_bits initialization, it only has meaning for digital i/o
subdevices that have configurable outputs.
Signed-off-by: default avatarH Hartley Sweeten <hsweeten@visionengravers.com>
Cc: Ian Abbott <abbotti@mev.co.uk>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent 3d596e50
...@@ -96,28 +96,6 @@ static int apci3501_di_insn_bits(struct comedi_device *dev, ...@@ -96,28 +96,6 @@ static int apci3501_di_insn_bits(struct comedi_device *dev,
return insn->n; return insn->n;
} }
static int apci3501_do_insn_bits(struct comedi_device *dev,
struct comedi_subdevice *s,
struct comedi_insn *insn,
unsigned int *data)
{
struct addi_private *devpriv = dev->private;
unsigned int mask = data[0];
unsigned int bits = data[1];
s->state = inl(devpriv->iobase + APCI3501_DIGITAL_OP);
if (mask) {
s->state &= ~mask;
s->state |= (bits & mask);
outl(s->state, devpriv->iobase + APCI3501_DIGITAL_OP);
}
data[1] = s->state;
return insn->n;
}
/* /*
+----------------------------------------------------------------------------+ +----------------------------------------------------------------------------+
| Function Name : int i_APCI3501_ConfigAnalogOutput | | Function Name : int i_APCI3501_ConfigAnalogOutput |
......
...@@ -19,17 +19,36 @@ static const struct addi_board apci3501_boardtypes[] = { ...@@ -19,17 +19,36 @@ static const struct addi_board apci3501_boardtypes[] = {
.i_AoMaxdata = 16383, .i_AoMaxdata = 16383,
.pr_AoRangelist = &range_apci3501_ao, .pr_AoRangelist = &range_apci3501_ao,
.i_NbrDiChannel = 2, .i_NbrDiChannel = 2,
.i_NbrDoChannel = 2,
.i_DoMaxdata = 0x3,
.interrupt = v_APCI3501_Interrupt, .interrupt = v_APCI3501_Interrupt,
.reset = i_APCI3501_Reset, .reset = i_APCI3501_Reset,
.ao_config = i_APCI3501_ConfigAnalogOutput, .ao_config = i_APCI3501_ConfigAnalogOutput,
.ao_write = i_APCI3501_WriteAnalogOutput, .ao_write = i_APCI3501_WriteAnalogOutput,
.di_bits = apci3501_di_insn_bits, .di_bits = apci3501_di_insn_bits,
.do_bits = apci3501_do_insn_bits,
}, },
}; };
static int apci3501_do_insn_bits(struct comedi_device *dev,
struct comedi_subdevice *s,
struct comedi_insn *insn,
unsigned int *data)
{
struct addi_private *devpriv = dev->private;
unsigned int mask = data[0];
unsigned int bits = data[1];
s->state = inl(devpriv->iobase + APCI3501_DIGITAL_OP);
if (mask) {
s->state &= ~mask;
s->state |= (bits & mask);
outl(s->state, devpriv->iobase + APCI3501_DIGITAL_OP);
}
data[1] = s->state;
return insn->n;
}
static int i_ADDIDATA_InsnReadEeprom(struct comedi_device *dev, static int i_ADDIDATA_InsnReadEeprom(struct comedi_device *dev,
struct comedi_subdevice *s, struct comedi_subdevice *s,
struct comedi_insn *insn, struct comedi_insn *insn,
...@@ -132,8 +151,6 @@ static int apci3501_auto_attach(struct comedi_device *dev, ...@@ -132,8 +151,6 @@ static int apci3501_auto_attach(struct comedi_device *dev,
devpriv->s_EeParameters.i_AiMaxdata = this_board->i_AiMaxdata; devpriv->s_EeParameters.i_AiMaxdata = this_board->i_AiMaxdata;
devpriv->s_EeParameters.i_AoMaxdata = this_board->i_AoMaxdata; devpriv->s_EeParameters.i_AoMaxdata = this_board->i_AoMaxdata;
devpriv->s_EeParameters.i_NbrDiChannel = this_board->i_NbrDiChannel; devpriv->s_EeParameters.i_NbrDiChannel = this_board->i_NbrDiChannel;
devpriv->s_EeParameters.i_NbrDoChannel = this_board->i_NbrDoChannel;
devpriv->s_EeParameters.i_DoMaxdata = this_board->i_DoMaxdata;
devpriv->s_EeParameters.i_Dma = this_board->i_Dma; devpriv->s_EeParameters.i_Dma = this_board->i_Dma;
devpriv->s_EeParameters.ui_MinAcquisitiontimeNs = devpriv->s_EeParameters.ui_MinAcquisitiontimeNs =
this_board->ui_MinAcquisitiontimeNs; this_board->ui_MinAcquisitiontimeNs;
...@@ -240,27 +257,15 @@ static int apci3501_auto_attach(struct comedi_device *dev, ...@@ -240,27 +257,15 @@ static int apci3501_auto_attach(struct comedi_device *dev,
} else { } else {
s->type = COMEDI_SUBD_UNUSED; s->type = COMEDI_SUBD_UNUSED;
} }
/* Allocate and Initialise DO Subdevice Structures */
/* Initialize the digital output subdevice */
s = &dev->subdevices[3]; s = &dev->subdevices[3];
if (devpriv->s_EeParameters.i_NbrDoChannel) {
s->type = COMEDI_SUBD_DO; s->type = COMEDI_SUBD_DO;
s->subdev_flags = s->subdev_flags = SDF_WRITEABLE;
SDF_READABLE | SDF_WRITEABLE | SDF_GROUND | SDF_COMMON; s->n_chan = 2;
s->n_chan = devpriv->s_EeParameters.i_NbrDoChannel; s->maxdata = 1;
s->maxdata = devpriv->s_EeParameters.i_DoMaxdata;
s->len_chanlist =
devpriv->s_EeParameters.i_NbrDoChannel;
s->range_table = &range_digital; s->range_table = &range_digital;
s->io_bits = 0xf; /* all bits output */ s->insn_bits = apci3501_do_insn_bits;
/* insn_config - for digital output memory */
s->insn_config = this_board->do_config;
s->insn_write = this_board->do_write;
s->insn_bits = this_board->do_bits;
s->insn_read = this_board->do_read;
} else {
s->type = COMEDI_SUBD_UNUSED;
}
/* Allocate and Initialise Timer Subdevice Structures */ /* Allocate and Initialise Timer Subdevice Structures */
s = &dev->subdevices[4]; s = &dev->subdevices[4];
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment