From: Ian Abbott Date: Fri, 5 Jun 2015 17:30:07 +0000 (+0100) Subject: staging: comedi: das08: use indexed initializer for AI range table types X-Git-Url: https://git.karo-electronics.de/?a=commitdiff_plain;h=fba5963c9259252747f79f778805ca7b368d9000;p=linux-beck.git 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: Ian Abbott Reviewed-by: H Hartley Sweeten Signed-off-by: Greg Kroah-Hartman --- diff --git a/drivers/staging/comedi/drivers/das08.c b/drivers/staging/comedi/drivers/das08.c index 73f4c8dbbde3..b1cd6eaacf61 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 b904b5e5020b..8b1c1a958858 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 {