[PATCH v2 24/24] staging: comedi: addi_apci_1500: fix digital input 'insn_bits' function

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

 



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 'insn_read' and 'insn_Write' functions for the digital input subdevice
cannot be removed yet. This driver is again abusing the API and uses these
functions to initialize the board and start/stop "events" generated by the
board. These will be addressed later.

Signed-off-by: H Hartley Sweeten <hsweeten@xxxxxxxxxxxxxxxxxxx>
Cc: Ian Abbott <abbotti@xxxxxxxxx>
Cc: Greg Kroah-Hartman <gregkh@xxxxxxxxxxxxxxxxxxx>
---
 .../comedi/drivers/addi-data/hwdrv_apci1500.c      | 78 ++--------------------
 drivers/staging/comedi/drivers/addi_apci_1500.c    |  2 +-
 2 files changed, 6 insertions(+), 74 deletions(-)

diff --git a/drivers/staging/comedi/drivers/addi-data/hwdrv_apci1500.c b/drivers/staging/comedi/drivers/addi-data/hwdrv_apci1500.c
index 771a305..24c4c98 100644
--- a/drivers/staging/comedi/drivers/addi-data/hwdrv_apci1500.c
+++ b/drivers/staging/comedi/drivers/addi-data/hwdrv_apci1500.c
@@ -1042,83 +1042,15 @@ static int i_APCI1500_Initialisation(struct comedi_device *dev,
 	return insn->n;
 }
 
-/*
-+----------------------------------------------------------------------------+
-| Function   Name   : int i_APCI1500_ReadMoreDigitalInput                    |
-|			  (struct comedi_device *dev,struct comedi_subdevice *s,               |
-|                     struct comedi_insn *insn,unsigned int *data)                      |
-+----------------------------------------------------------------------------+
-| Task              : Return the status of the Requested digital inputs      |
-+----------------------------------------------------------------------------+
-| Input Parameters  : struct comedi_device *dev      : Driver handle                |
-|                     unsigned int ui_NoOfChannels    : No Of Channels To be Read    |
-|                      unsigned int *data             : Data Pointer
-|                      data[0]                 : 0 Read a single channel
-|                                                1 read a port value
-|                      data[1]                 : port value
-+----------------------------------------------------------------------------+
-| Output Parameters :	--	data[0]    :The read status value
-+----------------------------------------------------------------------------+
-| Return Value      : TRUE  : No error occur                                 |
-|		            : FALSE : Error occur. Return the error          |
-|			                                                         |
-+----------------------------------------------------------------------------+
-*/
-static int i_APCI1500_ReadMoreDigitalInput(struct comedi_device *dev,
-					   struct comedi_subdevice *s,
-					   struct comedi_insn *insn,
-					   unsigned int *data)
+static int apci1500_di_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 ui_PortValue = data[1];
-	unsigned int ui_Mask = 0;
-	unsigned int ui_Channel;
-	unsigned int ui_TmpValue = 0;
-	ui_Channel = CR_CHAN(insn->chanspec);
 
-	switch (data[0]) {
-	case 0:
-		if (ui_Channel <= 15) {
-			ui_TmpValue =
-				(unsigned int) inw(devpriv->i_IobaseAddon +
-				APCI1500_DIGITAL_IP);
-			*data = (ui_TmpValue >> ui_Channel) & 0x1;
-		}		/* if(ui_Channel >= 0 && ui_Channel <=15) */
-		else {
-			printk("\nThe channel specification are in error\n");
-			return -EINVAL;	/*  "sorry channel spec wrong " */
-		}		/* else if(ui_Channel >= 0 && ui_Channel <=15) */
-		break;
-	case 1:
+	data[1] = inw(devpriv->i_IobaseAddon + APCI1500_DIGITAL_IP);
 
-		*data = (unsigned int) inw(devpriv->i_IobaseAddon +
-			APCI1500_DIGITAL_IP);
-		switch (ui_Channel) {
-		case 2:
-			ui_Mask = 3;
-			*data = (*data >> (2 * ui_PortValue)) & ui_Mask;
-			break;
-		case 4:
-			ui_Mask = 15;
-			*data = (*data >> (4 * ui_PortValue)) & ui_Mask;
-			break;
-		case 8:
-			ui_Mask = 255;
-			*data = (*data >> (8 * ui_PortValue)) & ui_Mask;
-			break;
-		case 15:
-			break;
-
-		default:
-			printk("\nSpecified channel cannot be read \n");
-			return -EINVAL;	/*  "sorry channel spec wrong " */
-			break;
-		}		/* switch(ui_Channel) */
-		break;
-	default:
-		printk("\nThe specified functionality does not exist\n");
-		return -EINVAL;
-	}			/* switch(data[0]) */
 	return insn->n;
 }
 
diff --git a/drivers/staging/comedi/drivers/addi_apci_1500.c b/drivers/staging/comedi/drivers/addi_apci_1500.c
index 4fe98e5..8d390a4 100644
--- a/drivers/staging/comedi/drivers/addi_apci_1500.c
+++ b/drivers/staging/comedi/drivers/addi_apci_1500.c
@@ -26,7 +26,7 @@ static const struct addi_board apci1500_boardtypes[] = {
 		.di_config		= i_APCI1500_ConfigDigitalInputEvent,
 		.di_read		= i_APCI1500_Initialisation,
 		.di_write		= i_APCI1500_StartStopInputEvent,
-		.di_bits		= i_APCI1500_ReadMoreDigitalInput,
+		.di_bits		= apci1500_di_insn_bits,
 		.do_config		= i_APCI1500_ConfigDigitalOutputErrorInterrupt,
 		.do_write		= i_APCI1500_WriteDigitalOutput,
 		.do_bits		= i_APCI1500_ConfigureInterrupt,
-- 
1.7.11

_______________________________________________
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