Commit 08f91d18 authored by H Hartley Sweeten's avatar H Hartley Sweeten Committed by Greg Kroah-Hartman

staging: comedi: pcl726: tidy up the comedi_lrange code

For aesthetics, declare the comedi_lrange tables with one entry per line.

Since the range data in the boardinfo is only for the analog outputs,
rename the variables to make this clearer.

Use ARRAY_SIZE to initialize the 'ao_num_ranges' member instead of open
coding the value.
Signed-off-by: default avatarH Hartley Sweeten <hsweeten@visionengravers.com>
Reviewed-by: default avatarIan Abbott <abbotti@mev.co.uk>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent 3f4d0101
...@@ -84,72 +84,77 @@ Interrupts are not supported. ...@@ -84,72 +84,77 @@ Interrupts are not supported.
#define PCL727_DO_LSB_REG 0x19 #define PCL727_DO_LSB_REG 0x19
static const struct comedi_lrange *const rangelist_726[] = { static const struct comedi_lrange *const rangelist_726[] = {
&range_unipolar5, &range_unipolar10, &range_unipolar5,
&range_bipolar5, &range_bipolar10, &range_unipolar10,
&range_4_20mA, &range_unknown &range_bipolar5,
&range_bipolar10,
&range_4_20mA,
&range_unknown
}; };
static const struct comedi_lrange *const rangelist_727[] = { static const struct comedi_lrange *const rangelist_727[] = {
&range_unipolar5, &range_unipolar10, &range_unipolar5,
&range_unipolar10,
&range_bipolar5, &range_bipolar5,
&range_4_20mA &range_4_20mA
}; };
static const struct comedi_lrange *const rangelist_728[] = { static const struct comedi_lrange *const rangelist_728[] = {
&range_unipolar5, &range_unipolar10, &range_unipolar5,
&range_bipolar5, &range_bipolar10, &range_unipolar10,
&range_4_20mA, &range_0_20mA &range_bipolar5,
&range_bipolar10,
&range_4_20mA,
&range_0_20mA
}; };
struct pcl726_board { struct pcl726_board {
const char *name; /* driver name */ const char *name; /* driver name */
int n_aochan; /* num of D/A chans */ int n_aochan; /* num of D/A chans */
int num_of_ranges; /* num of ranges */
unsigned int IRQbits; /* allowed interrupts */ unsigned int IRQbits; /* allowed interrupts */
unsigned int io_range; /* len of IO space */ unsigned int io_range; /* len of IO space */
unsigned int have_dio:1; unsigned int have_dio:1;
unsigned int is_pcl727:1; unsigned int is_pcl727:1;
const struct comedi_lrange *const *range_type_list; const struct comedi_lrange *const *ao_ranges;
/* list of supported ranges */ int ao_num_ranges;
}; };
static const struct pcl726_board boardtypes[] = { static const struct pcl726_board boardtypes[] = {
{ {
.name = "pcl726", .name = "pcl726",
.n_aochan = 6, .n_aochan = 6,
.num_of_ranges = 6,
.io_range = PCL726_SIZE, .io_range = PCL726_SIZE,
.have_dio = 1, .have_dio = 1,
.range_type_list = &rangelist_726[0], .ao_ranges = &rangelist_726[0],
.ao_num_ranges = ARRAY_SIZE(rangelist_726),
}, { }, {
.name = "pcl727", .name = "pcl727",
.n_aochan = 12, .n_aochan = 12,
.num_of_ranges = 4,
.io_range = PCL727_SIZE, .io_range = PCL727_SIZE,
.have_dio = 1, .have_dio = 1,
.is_pcl727 = 1, .is_pcl727 = 1,
.range_type_list = &rangelist_727[0], .ao_ranges = &rangelist_727[0],
.ao_num_ranges = ARRAY_SIZE(rangelist_727),
}, { }, {
.name = "pcl728", .name = "pcl728",
.n_aochan = 2, .n_aochan = 2,
.num_of_ranges = 6,
.io_range = PCL728_SIZE, .io_range = PCL728_SIZE,
.range_type_list = &rangelist_728[0], .ao_num_ranges = ARRAY_SIZE(rangelist_728),
.ao_ranges = &rangelist_728[0],
}, { }, {
.name = "acl6126", .name = "acl6126",
.n_aochan = 6, .n_aochan = 6,
.num_of_ranges = 5,
.IRQbits = 0x96e8, .IRQbits = 0x96e8,
.io_range = PCL726_SIZE, .io_range = PCL726_SIZE,
.have_dio = 1, .have_dio = 1,
.range_type_list = &rangelist_726[0], .ao_num_ranges = ARRAY_SIZE(rangelist_726),
.ao_ranges = &rangelist_726[0],
}, { }, {
.name = "acl6128", .name = "acl6128",
.n_aochan = 2, .n_aochan = 2,
.num_of_ranges = 6,
.io_range = PCL728_SIZE, .io_range = PCL728_SIZE,
.range_type_list = &rangelist_728[0], .ao_num_ranges = ARRAY_SIZE(rangelist_728),
.ao_ranges = &rangelist_728[0],
}, },
}; };
...@@ -289,8 +294,8 @@ static int pcl726_attach(struct comedi_device *dev, ...@@ -289,8 +294,8 @@ static int pcl726_attach(struct comedi_device *dev,
for (i = 0; i < 12; i++) { for (i = 0; i < 12; i++) {
unsigned int opt = it->options[2 + i]; unsigned int opt = it->options[2 + i];
if (opt < board->num_of_ranges && i < board->n_aochan) if (opt < board->ao_num_ranges && i < board->n_aochan)
devpriv->rangelist[i] = board->range_type_list[opt]; devpriv->rangelist[i] = board->ao_ranges[opt];
else else
devpriv->rangelist[i] = &range_unknown; devpriv->rangelist[i] = &range_unknown;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment