[PATCH 08/46] staging: comedi: adl_pci9111: cleanup pci9111_do_insn_bits()

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

 



Remove the unnecessary comments.

Cleanup the function to follow the comedi standard for digital
outputs. The 'mask' does not need to be checked, the comedi core
will make sure that it is valid based on the subdevice data.
The outputs only need to be updated if the 'mask' indicates
something is changing, otherwise we just need to return the
current "state" of the outputs.

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

diff --git a/drivers/staging/comedi/drivers/adl_pci9111.c b/drivers/staging/comedi/drivers/adl_pci9111.c
index 71eebe5..477aa2b 100644
--- a/drivers/staging/comedi/drivers/adl_pci9111.c
+++ b/drivers/staging/comedi/drivers/adl_pci9111.c
@@ -108,7 +108,6 @@ TODO:
 #define PCI9111_AO_RESOLUTION_MASK		0x0FFF
 #define PCI9111_DI_CHANNEL_NBR			16
 #define	PCI9111_DO_CHANNEL_NBR			16
-#define PCI9111_DO_MASK				0xFFFF
 
 #define PCI9111_RANGE_SETTING_DELAY		10
 #define PCI9111_AI_INSTANT_READ_UDELAY_US	2
@@ -1088,28 +1087,22 @@ static int pci9111_di_insn_bits(struct comedi_device *dev,
 	return insn->n;
 }
 
-/*  Digital outputs */
-
 static int pci9111_do_insn_bits(struct comedi_device *dev,
 				struct comedi_subdevice *s,
-				struct comedi_insn *insn, unsigned int *data)
+				struct comedi_insn *insn,
+				unsigned int *data)
 {
-	unsigned int bits;
+	unsigned int mask = data[0];
+	unsigned int bits = data[1];
 
-	/*  Only set bits that have been masked */
-	/*  data[0] = mask */
-	/*  data[1] = bit state */
+	if (mask) {
+		s->state &= ~mask;
+		s->state |= (bits & mask);
 
-	data[0] &= PCI9111_DO_MASK;
-
-	bits = s->state;
-	bits &= ~data[0];
-	bits |= data[0] & data[1];
-	s->state = bits;
-
-	outw(bits, dev->iobase + PCI9111_DIO_REG);
+		outw(s->state, dev->iobase + PCI9111_DIO_REG);
+	}
 
-	data[1] = bits;
+	data[1] = s->state;
 
 	return insn->n;
 }
-- 
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