Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit fba5963c authored by Ian Abbott's avatar Ian Abbott Committed by Greg Kroah-Hartman
Browse files

staging: comedi: das08: use indexed initializer for AI range table types



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: default avatarIan Abbott <abbotti@mev.co.uk>
Reviewed-by: default avatarH Hartley Sweeten <hsweeten@visionengravers.com>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent d4d79433
Loading
Loading
Loading
Loading
+10 −10
Original line number Diff line number Diff line
@@ -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,
+3 −2
Original line number Diff line number Diff line
@@ -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 {