From: H Hartley Sweeten Date: Mon, 14 Jul 2014 19:23:47 +0000 (-0700) Subject: staging: comedi: ni_mio_common: remove some unnecessary boardinfo access X-Git-Tag: v3.17-rc1~123^2~685 X-Git-Url: https://git.karo-electronics.de/?a=commitdiff_plain;h=47277365195c9722534e1ff3d4c10d36a77858e4;p=karo-tx-linux.git staging: comedi: ni_mio_common: remove some unnecessary boardinfo access 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 Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- diff --git a/drivers/staging/comedi/drivers/ni_mio_common.c b/drivers/staging/comedi/drivers/ni_mio_common.c index 8854f18eaa16..6e79bcf3ce87 100644 --- a/drivers/staging/comedi/drivers/ni_mio_common.c +++ b/drivers/staging/comedi/drivers/ni_mio_common.c @@ -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; }