Commit 564c526a authored by Ian Abbott's avatar Ian Abbott Committed by Greg Kroah-Hartman

staging: comedi: dt9812: use CR_CHAN() for channel number

As pointed out by Dan Carpenper in
<http://driverdev.linuxdriverproject.org/pipermail/devel/2013-February/036025.html>,
the dt9812 comedi driver's use of the `chanspec` member of `struct
comedi_insn` as a channel number is incorrect.  Change it to use
`CR_CHAN(insn->chanspec)` as the channel number (where `insn` is a
pointer to the `struct comedi_insn` being processed).
Reported-by: default avatarDan Carpenter <dan.carpenter@oracle.com>
Cc: stable <stable@vger.kernel.org> # 3.8 onwards
Cc: Anders Blomdell <anders.blomdell@control.lth.se>
Signed-off-by: default avatarIan Abbott <abbotti@mev.co.uk>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent aa1e1234
...@@ -947,12 +947,13 @@ static int dt9812_di_rinsn(struct comedi_device *dev, ...@@ -947,12 +947,13 @@ static int dt9812_di_rinsn(struct comedi_device *dev,
unsigned int *data) unsigned int *data)
{ {
struct comedi_dt9812 *devpriv = dev->private; struct comedi_dt9812 *devpriv = dev->private;
unsigned int channel = CR_CHAN(insn->chanspec);
int n; int n;
u8 bits = 0; u8 bits = 0;
dt9812_digital_in(devpriv->slot, &bits); dt9812_digital_in(devpriv->slot, &bits);
for (n = 0; n < insn->n; n++) for (n = 0; n < insn->n; n++)
data[n] = ((1 << insn->chanspec) & bits) != 0; data[n] = ((1 << channel) & bits) != 0;
return n; return n;
} }
...@@ -961,12 +962,13 @@ static int dt9812_do_winsn(struct comedi_device *dev, ...@@ -961,12 +962,13 @@ static int dt9812_do_winsn(struct comedi_device *dev,
unsigned int *data) unsigned int *data)
{ {
struct comedi_dt9812 *devpriv = dev->private; struct comedi_dt9812 *devpriv = dev->private;
unsigned int channel = CR_CHAN(insn->chanspec);
int n; int n;
u8 bits = 0; u8 bits = 0;
dt9812_digital_out_shadow(devpriv->slot, &bits); dt9812_digital_out_shadow(devpriv->slot, &bits);
for (n = 0; n < insn->n; n++) { for (n = 0; n < insn->n; n++) {
u8 mask = 1 << insn->chanspec; u8 mask = 1 << channel;
bits &= ~mask; bits &= ~mask;
if (data[n]) if (data[n])
...@@ -981,13 +983,13 @@ static int dt9812_ai_rinsn(struct comedi_device *dev, ...@@ -981,13 +983,13 @@ static int dt9812_ai_rinsn(struct comedi_device *dev,
unsigned int *data) unsigned int *data)
{ {
struct comedi_dt9812 *devpriv = dev->private; struct comedi_dt9812 *devpriv = dev->private;
unsigned int channel = CR_CHAN(insn->chanspec);
int n; int n;
for (n = 0; n < insn->n; n++) { for (n = 0; n < insn->n; n++) {
u16 value = 0; u16 value = 0;
dt9812_analog_in(devpriv->slot, insn->chanspec, &value, dt9812_analog_in(devpriv->slot, channel, &value, DT9812_GAIN_1);
DT9812_GAIN_1);
data[n] = value; data[n] = value;
} }
return n; return n;
...@@ -998,12 +1000,13 @@ static int dt9812_ao_rinsn(struct comedi_device *dev, ...@@ -998,12 +1000,13 @@ static int dt9812_ao_rinsn(struct comedi_device *dev,
unsigned int *data) unsigned int *data)
{ {
struct comedi_dt9812 *devpriv = dev->private; struct comedi_dt9812 *devpriv = dev->private;
unsigned int channel = CR_CHAN(insn->chanspec);
int n; int n;
u16 value; u16 value;
for (n = 0; n < insn->n; n++) { for (n = 0; n < insn->n; n++) {
value = 0; value = 0;
dt9812_analog_out_shadow(devpriv->slot, insn->chanspec, &value); dt9812_analog_out_shadow(devpriv->slot, channel, &value);
data[n] = value; data[n] = value;
} }
return n; return n;
...@@ -1014,10 +1017,11 @@ static int dt9812_ao_winsn(struct comedi_device *dev, ...@@ -1014,10 +1017,11 @@ static int dt9812_ao_winsn(struct comedi_device *dev,
unsigned int *data) unsigned int *data)
{ {
struct comedi_dt9812 *devpriv = dev->private; struct comedi_dt9812 *devpriv = dev->private;
unsigned int channel = CR_CHAN(insn->chanspec);
int n; int n;
for (n = 0; n < insn->n; n++) for (n = 0; n < insn->n; n++)
dt9812_analog_out(devpriv->slot, insn->chanspec, data[n]); dt9812_analog_out(devpriv->slot, channel, data[n]);
return n; return n;
} }
......
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