[PATCH 05/30] staging: comedi: addi_apci_3501: cleanup the digital input subdevice

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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 <hsweeten@xxxxxxxxxxxxxxxxxxx>
Cc: Ian Abbott <abbotti@xxxxxxxxx>
Cc: Greg Kroah-Hartman <gregkh@xxxxxxxxxxxxxxxxxxx>
---
 .../comedi/drivers/addi-data/hwdrv_apci3501.c      | 12 -------
 drivers/staging/comedi/drivers/addi_apci_3501.c    | 37 +++++++++++-----------
 2 files changed, 18 insertions(+), 31 deletions(-)

diff --git a/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3501.c b/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3501.c
index c7abe85..4ecdb9e 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 8ea3838..fa2b235 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];
-- 
1.8.1.1.293.gfe73786

_______________________________________________
devel mailing list
devel@xxxxxxxxxxxxxxxxxxxxxx
http://driverdev.linuxdriverproject.org/mailman/listinfo/devel


[Index of Archives]     [Linux Driver Backports]     [DMA Engine]     [Linux GPIO]     [Linux SPI]     [Video for Linux]     [Linux USB Devel]     [Linux Coverity]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [Yosemite Backpacking]
  Powered by Linux