mirror of https://gitee.com/openkylin/linux.git
staging: comedi: usbdux: fix usbdux_counter_write()
Comedi (*insn_write) operations are supposed to write insn->n values. Fix this function to work like the core expects. Rename the local variable used for the private data pointer to the comedi "norm". Remove the unnecessary sanity check of the private data pointer. This function can only be called is the private data was allocated during the attach. 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>
This commit is contained in:
parent
48967d4f5d
commit
f2929618d3
|
@ -1369,27 +1369,30 @@ static int usbdux_counter_read(struct comedi_device *dev,
|
|||
|
||||
static int usbdux_counter_write(struct comedi_device *dev,
|
||||
struct comedi_subdevice *s,
|
||||
struct comedi_insn *insn, unsigned int *data)
|
||||
struct comedi_insn *insn,
|
||||
unsigned int *data)
|
||||
{
|
||||
struct usbdux_private *this_usbduxsub = dev->private;
|
||||
int err;
|
||||
struct usbdux_private *devpriv = dev->private;
|
||||
unsigned int chan = CR_CHAN(insn->chanspec);
|
||||
int16_t *p = (int16_t *)&devpriv->dux_commands[2];
|
||||
int ret = 0;
|
||||
int i;
|
||||
|
||||
if (!this_usbduxsub)
|
||||
return -EFAULT;
|
||||
down(&devpriv->sem);
|
||||
|
||||
down(&this_usbduxsub->sem);
|
||||
this_usbduxsub->dux_commands[1] = insn->chanspec;
|
||||
*((int16_t *) (this_usbduxsub->dux_commands + 2)) = cpu_to_le16(*data);
|
||||
devpriv->dux_commands[1] = chan;
|
||||
|
||||
err = send_dux_commands(dev, WRITECOUNTERCOMMAND);
|
||||
if (err < 0) {
|
||||
up(&this_usbduxsub->sem);
|
||||
return err;
|
||||
for (i = 0; i < insn->n; i++) {
|
||||
*p = cpu_to_le16(data[i]);
|
||||
|
||||
ret = send_dux_commands(dev, WRITECOUNTERCOMMAND);
|
||||
if (ret < 0)
|
||||
break;
|
||||
}
|
||||
|
||||
up(&this_usbduxsub->sem);
|
||||
up(&devpriv->sem);
|
||||
|
||||
return 1;
|
||||
return ret ? ret : insn->n;
|
||||
}
|
||||
|
||||
static int usbdux_counter_config(struct comedi_device *dev,
|
||||
|
|
Loading…
Reference in New Issue