staging: comedi: das08: use indexed initializer for AI range table types
authorIan Abbott <abbotti@mev.co.uk>
Fri, 5 Jun 2015 17:30:07 +0000 (18:30 +0100)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Sat, 13 Jun 2015 00:06:39 +0000 (17:06 -0700)
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@mev.co.uk>
Reviewed-by: H Hartley Sweeten <hsweeten@visionengravers.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/staging/comedi/drivers/das08.c
drivers/staging/comedi/drivers/das08.h

index 73f4c8d..b1cd6ea 100644 (file)
@@ -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,
index b904b5e..8b1c1a9 100644 (file)
@@ -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 {