diff options
author | H Hartley Sweeten <hsweeten@visionengravers.com> | 2013-09-25 15:37:18 -0700 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2013-09-26 09:32:19 -0700 |
commit | 716343c43891dcb865bd9f2603e68804d3cc5660 (patch) | |
tree | 8206fef45a88941752ca103f486be29fe398fdcb /drivers/staging/comedi/drivers/pcl726.c | |
parent | fff46207245cd9e39c05b638afaee2478e64914b (diff) |
staging: comedi: pcl726: fix the analog output range_table_list initialization
The analog output channels use jumpers on the board to individually set
the range used. This driver uses the configuration options passed to the
(*attach) function to setup the analog output subdevice range_table_list
for each channel.
The configuration options should be 'it->options[2 + i]' for each channel 'i'
not '...[2 + 1]' for each channel. Fix the error and move the code so that
the range_table_list is setup before the subdevice is initialized.
Signed-off-by: H Hartley Sweeten <hsweeten@visionengravers.com>
Reviewed-by: Ian Abbott <abbotti@mev.co.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'drivers/staging/comedi/drivers/pcl726.c')
-rw-r--r-- | drivers/staging/comedi/drivers/pcl726.c | 25 |
1 files changed, 10 insertions, 15 deletions
diff --git a/drivers/staging/comedi/drivers/pcl726.c b/drivers/staging/comedi/drivers/pcl726.c index bcad27b1950e..7952d8754449 100644 --- a/drivers/staging/comedi/drivers/pcl726.c +++ b/drivers/staging/comedi/drivers/pcl726.c @@ -268,9 +268,6 @@ static int pcl726_attach(struct comedi_device *dev, struct comedi_devconfig *it) if (!devpriv) return -ENOMEM; - for (i = 0; i < 12; i++) - devpriv->rangelist[i] = &range_unknown; - /* * Hook up the external trigger source interrupt only if the * user config option is valid and the board supports interrupts. @@ -284,6 +281,16 @@ static int pcl726_attach(struct comedi_device *dev, struct comedi_devconfig *it) } } + /* setup the per-channel analog output range_table_list */ + for (i = 0; i < 12; i++) { + unsigned int opt = it->options[2 + i]; + + if (opt < board->num_of_ranges && i < board->n_aochan) + devpriv->rangelist[i] = board->range_type_list[opt]; + else + devpriv->rangelist[i] = &range_unknown; + } + ret = comedi_alloc_subdevices(dev, 3); if (ret) return ret; @@ -298,18 +305,6 @@ static int pcl726_attach(struct comedi_device *dev, struct comedi_devconfig *it) s->insn_write = pcl726_ao_insn_write; s->insn_read = pcl726_ao_insn_read; s->range_table_list = devpriv->rangelist; - for (i = 0; i < board->n_aochan; i++) { - int j; - - j = it->options[2 + 1]; - if ((j < 0) || (j >= board->num_of_ranges)) { - printk - ("Invalid range for channel %d! Must be 0<=%d<%d\n", - i, j, board->num_of_ranges - 1); - j = 0; - } - devpriv->rangelist[i] = board->range_type_list[j]; - } s = &dev->subdevices[1]; /* di */ |