[PATCH 06/25] staging: comedi: das16m1: tidy up analog input data register defines

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

 



Convert the inline helper munge_sample() into a macro and rename the
defines for the analog input data register/bits. Use the register define
when accessing this register instead of just dev->iobase.

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

diff --git a/drivers/staging/comedi/drivers/das16m1.c b/drivers/staging/comedi/drivers/das16m1.c
index 6638a9a..2c7c86c 100644
--- a/drivers/staging/comedi/drivers/das16m1.c
+++ b/drivers/staging/comedi/drivers/das16m1.c
@@ -63,8 +63,9 @@
 /*
  * Register map (dev->iobase)
  */
-#define DAS16M1_AI             0	/*  16-bit wide register */
-#define   AI_CHAN(x)             ((x) & 0xf)
+#define DAS16M1_AI_REG			0x00	/* 16-bit register */
+#define DAS16M1_AI_TO_CHAN(x)		(((x) >> 0) & 0xf)
+#define DAS16M1_AI_TO_SAMPLE(x)		(((x) >> 4) & 0xfff)
 #define DAS16M1_CS             2
 #define   EXT_TRIG_BIT           0x1
 #define   OVRUN                  0x20
@@ -109,17 +110,12 @@ struct das16m1_private_struct {
 	unsigned long extra_iobase;
 };
 
-static inline unsigned short munge_sample(unsigned short data)
-{
-	return (data >> 4) & 0xfff;
-}
-
 static void munge_sample_array(unsigned short *array, unsigned int num_elements)
 {
 	unsigned int i;
 
 	for (i = 0; i < num_elements; i++)
-		array[i] = munge_sample(array[i]);
+		array[i] = DAS16M1_AI_TO_SAMPLE(array[i]);
 }
 
 static int das16m1_ai_check_chanlist(struct comedi_device *dev,
@@ -331,16 +327,19 @@ static int das16m1_ai_rinsn(struct comedi_device *dev,
 	outb(byte, dev->iobase + DAS16M1_QUEUE_DATA);
 
 	for (n = 0; n < insn->n; n++) {
+		unsigned short val;
+
 		/* clear IRQDATA bit */
 		outb(0, dev->iobase + DAS16M1_CLEAR_INTR);
 		/* trigger conversion */
-		outb(0, dev->iobase);
+		outb(0, dev->iobase + DAS16M1_AI_REG);
 
 		ret = comedi_timeout(dev, s, insn, das16m1_ai_eoc, 0);
 		if (ret)
 			return ret;
 
-		data[n] = munge_sample(inw(dev->iobase));
+		val = inw(dev->iobase + DAS16M1_AI_REG);
+		data[n] = DAS16M1_AI_TO_SAMPLE(val);
 	}
 
 	return n;
-- 
2.6.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