[PATCH 04/32] staging: comedi: das08: use indexed initializer for AI range table types

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

 



The "das08" common module for DAS08 ISA, PCI, and PCMCIA drivers
includes a predefined set of AI range tables.  The static board data (of
type `struct das08_board_struct`) for a particular board contains an
index in its `ai_pg` member (of type `enum das08_lrange`) indicating
which of the predefined AI range tables to use.  The "das08" common
module looks up this index in `das08_ai_lranges[]` to get a pointer to
the predefined range table for the board.  The same index is also looked
up in `das08_gainlists[]` to get a corresponding pointer to a list of
hardware gain values for each range supported by the board (NULL for
boards without programmable gain).

To make this clearer, used indexed initializers for `das08_ai_lranges[]`
and `das08_gainlists[]`, using the enumerated constants from `enum
das08_lrange` as the indices.  Also add a short comment to the
definition of `enum das08_lrange`.

Signed-off-by: Ian Abbott <abbotti@xxxxxxxxx>
---
 drivers/staging/comedi/drivers/das08.c | 20 ++++++++++----------
 drivers/staging/comedi/drivers/das08.h |  5 +++--
 2 files changed, 13 insertions(+), 12 deletions(-)

diff --git a/drivers/staging/comedi/drivers/das08.c b/drivers/staging/comedi/drivers/das08.c
index 73f4c8d..b1cd6ea 100644
--- a/drivers/staging/comedi/drivers/das08.c
+++ b/drivers/staging/comedi/drivers/das08.c
@@ -165,11 +165,11 @@ static const struct comedi_lrange range_das08_pgm = {
 				 */
 
 static const struct comedi_lrange *const das08_ai_lranges[] = {
-	&range_unknown,
-	&range_bipolar5,
-	&range_das08_pgh,
-	&range_das08_pgl,
-	&range_das08_pgm,
+	[das08_pg_none]		= &range_unknown,
+	[das08_bipolar5]	= &range_bipolar5,
+	[das08_pgh]		= &range_das08_pgh,
+	[das08_pgl]		= &range_das08_pgl,
+	[das08_pgm]		= &range_das08_pgm,
 };
 
 static const int das08_pgh_gainlist[] = {
@@ -179,11 +179,11 @@ static const int das08_pgl_gainlist[] = { 8, 0, 2, 4, 6, 1, 3, 5, 7 };
 static const int das08_pgm_gainlist[] = { 8, 0, 10, 12, 14, 9, 11, 13, 15 };
 
 static const int *const das08_gainlists[] = {
-	NULL,
-	NULL,
-	das08_pgh_gainlist,
-	das08_pgl_gainlist,
-	das08_pgm_gainlist,
+	[das08_pg_none]		= NULL,
+	[das08_bipolar5]	= NULL,
+	[das08_pgh]		= das08_pgh_gainlist,
+	[das08_pgl]		= das08_pgl_gainlist,
+	[das08_pgm]		= das08_pgm_gainlist,
 };
 
 static int das08_ai_eoc(struct comedi_device *dev,
diff --git a/drivers/staging/comedi/drivers/das08.h b/drivers/staging/comedi/drivers/das08.h
index b904b5e..8b1c1a9 100644
--- a/drivers/staging/comedi/drivers/das08.h
+++ b/drivers/staging/comedi/drivers/das08.h
@@ -21,8 +21,9 @@
 
 /* different ways ai data is encoded in first two registers */
 enum das08_ai_encoding { das08_encode12, das08_encode16, das08_pcm_encode12 };
-enum das08_lrange { das08_pg_none, das08_bipolar5, das08_pgh, das08_pgl,
-	das08_pgm
+/* types of ai range table used by different boards */
+enum das08_lrange {
+	das08_pg_none, das08_bipolar5, das08_pgh, das08_pgl, das08_pgm
 };
 
 struct das08_board_struct {
-- 
2.1.4

_______________________________________________
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