Re: [PATCH 14/46] staging: comedi: me4000: simplify analog input range programming

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

 



On 04/08/15 18:57, H Hartley Sweeten wrote:
The comedi_lrange table for the analog inputs is inverted compared
to the values that need to be written to the ME4000_AI_CHANNEL_LIST_REG
to select the range.

Create a macro, ME4000_AI_LIST_RANGE(), to handle the inversion. Remove
the old defines and simplify the code a bit.

Signed-off-by: H Hartley Sweeten <hsweeten@xxxxxxxxxxxxxxxxxxx>
---
  drivers/staging/comedi/drivers/me4000.c | 41 ++++++++-------------------------
  1 file changed, 9 insertions(+), 32 deletions(-)

diff --git a/drivers/staging/comedi/drivers/me4000.c b/drivers/staging/comedi/drivers/me4000.c
index c3653a35..db0a18f 100644
--- a/drivers/staging/comedi/drivers/me4000.c
+++ b/drivers/staging/comedi/drivers/me4000.c
@@ -111,10 +111,7 @@ broken.
  #define ME4000_AI_CTRL_BIT_EX_TRIG_BOTH		(1 << 31)
  #define ME4000_AI_CHANNEL_LIST_REG		0x78
  #define ME4000_AI_LIST_INPUT_DIFFERENTIAL	(1 << 5)
-#define ME4000_AI_LIST_RANGE_BIPOLAR_10		(0 << 6)
-#define ME4000_AI_LIST_RANGE_BIPOLAR_2_5	(1 << 6)
-#define ME4000_AI_LIST_RANGE_UNIPOLAR_10	(2 << 6)
-#define ME4000_AI_LIST_RANGE_UNIPOLAR_2_5	(3 << 6)
+#define ME4000_AI_LIST_RANGE(x)			((3 - ((x) & 3)) << 6)

You could also use '((~(x) & 3) << 6)' but yours is probably more readable!

--
-=( Ian Abbott @ MEV Ltd.    E-mail: <abbotti@xxxxxxxxx> )=-
-=(                          Web: http://www.mev.co.uk/  )=-
_______________________________________________
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