]> git.karo-electronics.de Git - linux-beck.git/commitdiff
staging: comedi: ni_mio_common: remove some unnecessary boardinfo access
authorH Hartley Sweeten <hsweeten@visionengravers.com>
Mon, 14 Jul 2014 19:23:47 +0000 (12:23 -0700)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 16 Jul 2014 20:24:42 +0000 (13:24 -0700)
Currently ni_m_series_ao_config_chanlist() gets the boardinfo pointer in
order to get the number of analog output channels. Get this from the
comedi_subdevice instead.

The ni_old_ao_config_chanlist() function also gets the boardinfo pointer
to get the analog output resolution, 'aobits', in order to calculate the
value needed to convert samples from unsigned to two's complement for
bipolar ranges. Use the comedi_subdevice 'maxdata' instead.

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>
drivers/staging/comedi/drivers/ni_mio_common.c

index 8854f18eaa165f28b1b5d67636cef9f77a88ed9c..6e79bcf3ce876d43576db0e323ac25e619323071 100644 (file)
@@ -2818,7 +2818,6 @@ static int ni_m_series_ao_config_chanlist(struct comedi_device *dev,
                                          unsigned int chanspec[],
                                          unsigned int n_chans, int timed)
 {
-       const struct ni_board_struct *board = comedi_board(dev);
        struct ni_private *devpriv = dev->private;
        unsigned int range;
        unsigned int chan;
@@ -2827,7 +2826,7 @@ static int ni_m_series_ao_config_chanlist(struct comedi_device *dev,
        int invert = 0;
 
        if (timed) {
-               for (i = 0; i < board->n_aochan; ++i) {
+               for (i = 0; i < s->n_chan; ++i) {
                        devpriv->ao_conf[i] &= ~MSeries_AO_Update_Timed_Bit;
                        ni_writeb(dev, devpriv->ao_conf[i],
                                  M_Offset_AO_Config_Bank(i));
@@ -2893,7 +2892,6 @@ static int ni_old_ao_config_chanlist(struct comedi_device *dev,
                                     unsigned int chanspec[],
                                     unsigned int n_chans)
 {
-       const struct ni_board_struct *board = comedi_board(dev);
        struct ni_private *devpriv = dev->private;
        unsigned int range;
        unsigned int chan;
@@ -2908,7 +2906,7 @@ static int ni_old_ao_config_chanlist(struct comedi_device *dev,
 
                if (comedi_range_is_bipolar(s, range)) {
                        conf |= AO_Bipolar;
-                       invert = (1 << (board->aobits - 1));
+                       invert = (s->maxdata + 1) >> 1;
                } else {
                        invert = 0;
                }