[PATCH 07/17] staging: comedi: ni_65xx: remove 'output_bits' from private data

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

 



Remove the need for the 'output_bits' in the private data by just
reading the current state of the data port when updating the output
channels in the (*insn_bits) function.

Rename the local variable 'port_read_bits' to 'bits' so that we can
use it for updating the output channels and reading back the actual
state to return to the user.

Signed-off-by: H Hartley Sweeten <hsweeten@xxxxxxxxxxxxxxxxxxx>
Cc: Ian Abbott <abbotti@xxxxxxxxx>
Cc: Greg Kroah-Hartman <gregk@xxxxxxxxxxxxxxxxxxx>
---
 drivers/staging/comedi/drivers/ni_65xx.c | 24 ++++++++++++------------
 1 file changed, 12 insertions(+), 12 deletions(-)

diff --git a/drivers/staging/comedi/drivers/ni_65xx.c b/drivers/staging/comedi/drivers/ni_65xx.c
index 1f3e83b..8c0f5d3 100644
--- a/drivers/staging/comedi/drivers/ni_65xx.c
+++ b/drivers/staging/comedi/drivers/ni_65xx.c
@@ -260,7 +260,6 @@ static inline unsigned ni_65xx_total_num_ports(const struct ni_65xx_board
 
 struct ni_65xx_private {
 	void __iomem *mmio;
-	unsigned short output_bits[NI_65XX_MAX_NUM_PORTS];
 };
 
 struct ni_65xx_subdevice_private {
@@ -356,7 +355,7 @@ static int ni_65xx_dio_insn_bits(struct comedi_device *dev,
 	     port_offset <= last_port_offset; port_offset++) {
 		unsigned port = sprivate(s)->base_port + port_offset;
 		int base_port_channel = port_offset * ni_65xx_channels_per_port;
-		unsigned port_mask, port_data, port_read_bits;
+		unsigned port_mask, port_data, bits;
 		int bitshift = base_port_channel - base_bitfield_channel;
 
 		if (bitshift >= 32)
@@ -372,22 +371,23 @@ static int ni_65xx_dio_insn_bits(struct comedi_device *dev,
 		}
 		port_mask &= 0xff;
 		port_data &= 0xff;
+
+		/* update the outputs */
 		if (port_mask) {
-			unsigned bits;
-			devpriv->output_bits[port] &= ~port_mask;
-			devpriv->output_bits[port] |=
-			    port_data & port_mask;
-			bits = devpriv->output_bits[port];
+			bits = readb(devpriv->mmio + NI_65XX_IO_DATA_REG(port));
+			bits &= ~port_mask;
+			bits |= (port_data & port_mask);
 			writeb(bits, devpriv->mmio + NI_65XX_IO_DATA_REG(port));
 		}
-		port_read_bits = readb(devpriv->mmio +
-				       NI_65XX_IO_DATA_REG(port));
+
+		/* now read back the actual state */
+		bits = readb(devpriv->mmio + NI_65XX_IO_DATA_REG(port));
 		if (bitshift > 0)
-			port_read_bits <<= bitshift;
+			bits <<= bitshift;
 		else
-			port_read_bits >>= -bitshift;
+			bits >>= -bitshift;
 
-		read_bits |= port_read_bits;
+		read_bits |= bits;
 	}
 	data[1] = read_bits;
 	return insn->n;
-- 
1.9.3

_______________________________________________
devel mailing list
devel@xxxxxxxxxxxxxxxxxxxxxx
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-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