From: H Hartley Sweeten Date: Wed, 23 Jan 2013 19:37:38 +0000 (-0700) Subject: staging: comedi: addi_apci_3501: cleanup the digital input subdevice X-Git-Tag: firefly_0821_release~3680^2~1080^2~307 X-Git-Url: http://demsky.eecs.uci.edu/git/?a=commitdiff_plain;h=513192fc7e34d089d4b949a0e7ba6ccd4780f663;p=firefly-linux-kernel-4.4.55.git staging: comedi: addi_apci_3501: cleanup the digital input subdevice The board supported by this driver has 2 digital input. 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.i_NbrDiChannel for the digital input subdevice is no longer being used, remove initialization of it also. Copy the apci3501_di_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_READABLE. The SDF_GROUND and SDF_COMMON flags only have meaning for analog subdevices. 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: H Hartley Sweeten Cc: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- diff --git a/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3501.c b/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3501.c index c7abe85c59f7..4ecdb9e20f4f 100644 --- a/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3501.c +++ b/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3501.c @@ -84,18 +84,6 @@ static struct comedi_lrange range_apci3501_ao = { } }; -static int apci3501_di_insn_bits(struct comedi_device *dev, - struct comedi_subdevice *s, - struct comedi_insn *insn, - unsigned int *data) -{ - struct addi_private *devpriv = dev->private; - - data[1] = inl(devpriv->iobase + APCI3501_DIGITAL_IP) & 0x3; - - return insn->n; -} - /* +----------------------------------------------------------------------------+ | Function Name : int i_APCI3501_ConfigAnalogOutput | diff --git a/drivers/staging/comedi/drivers/addi_apci_3501.c b/drivers/staging/comedi/drivers/addi_apci_3501.c index 8ea3838165bf..fa2b2352062e 100644 --- a/drivers/staging/comedi/drivers/addi_apci_3501.c +++ b/drivers/staging/comedi/drivers/addi_apci_3501.c @@ -18,15 +18,25 @@ static const struct addi_board apci3501_boardtypes[] = { .pc_EepromChip = ADDIDATA_S5933, .i_AoMaxdata = 16383, .pr_AoRangelist = &range_apci3501_ao, - .i_NbrDiChannel = 2, .interrupt = v_APCI3501_Interrupt, .reset = i_APCI3501_Reset, .ao_config = i_APCI3501_ConfigAnalogOutput, .ao_write = i_APCI3501_WriteAnalogOutput, - .di_bits = apci3501_di_insn_bits, }, }; +static int apci3501_di_insn_bits(struct comedi_device *dev, + struct comedi_subdevice *s, + struct comedi_insn *insn, + unsigned int *data) +{ + struct addi_private *devpriv = dev->private; + + data[1] = inl(devpriv->iobase + APCI3501_DIGITAL_IP) & 0x3; + + return insn->n; +} + static int apci3501_do_insn_bits(struct comedi_device *dev, struct comedi_subdevice *s, struct comedi_insn *insn, @@ -150,7 +160,6 @@ static int apci3501_auto_attach(struct comedi_device *dev, devpriv->s_EeParameters.i_NbrAoChannel = this_board->i_NbrAoChannel; devpriv->s_EeParameters.i_AiMaxdata = this_board->i_AiMaxdata; devpriv->s_EeParameters.i_AoMaxdata = this_board->i_AoMaxdata; - devpriv->s_EeParameters.i_NbrDiChannel = this_board->i_NbrDiChannel; devpriv->s_EeParameters.i_Dma = this_board->i_Dma; devpriv->s_EeParameters.ui_MinAcquisitiontimeNs = this_board->ui_MinAcquisitiontimeNs; @@ -241,22 +250,12 @@ static int apci3501_auto_attach(struct comedi_device *dev, } /* Allocate and Initialise DI Subdevice Structures */ s = &dev->subdevices[2]; - if (devpriv->s_EeParameters.i_NbrDiChannel) { - s->type = COMEDI_SUBD_DI; - s->subdev_flags = SDF_READABLE | SDF_GROUND | SDF_COMMON; - s->n_chan = devpriv->s_EeParameters.i_NbrDiChannel; - s->maxdata = 1; - s->len_chanlist = - devpriv->s_EeParameters.i_NbrDiChannel; - s->range_table = &range_digital; - s->io_bits = 0; /* all bits input */ - s->insn_config = this_board->di_config; - s->insn_read = this_board->di_read; - s->insn_write = this_board->di_write; - s->insn_bits = this_board->di_bits; - } else { - s->type = COMEDI_SUBD_UNUSED; - } + s->type = COMEDI_SUBD_DI; + s->subdev_flags = SDF_READABLE; + s->n_chan = 2; + s->maxdata = 1; + s->range_table = &range_digital; + s->insn_bits = apci3501_di_insn_bits; /* Initialize the digital output subdevice */ s = &dev->subdevices[3];