* cancelled. */
usb_kill_urb(usbduxsub_tmp->urb_in[i]);
}
- dev_dbg(&usbduxsub_tmp->interface->dev,
- "comedi: usbdux: unlinked InURB %d, err=%d\n",
- i, err);
}
}
return err;
{
int ret = 0;
- if (!this_usbduxsub) {
- pr_err("comedi?: usbdux_ai_stop: this_usbduxsub=NULL!\n");
+ if (!this_usbduxsub)
return -EFAULT;
- }
- dev_dbg(&this_usbduxsub->interface->dev, "comedi: usbdux_ai_stop\n");
if (do_unlink) {
/* stop aquistion */
if (!this_usbduxsub)
return -EFAULT;
- dev_dbg(&this_usbduxsub->interface->dev, "comedi: usbdux_ai_cancel\n");
-
/* prevent other CPUs from submitting new commands just now */
down(&this_usbduxsub->sem);
/* unlink only if the urb really has been submitted */
for (i = 0; i < usbduxsub_tmp->num_out_buffers; i++) {
if (usbduxsub_tmp->urb_out[i])
usb_kill_urb(usbduxsub_tmp->urb_out[i]);
-
- dev_dbg(&usbduxsub_tmp->interface->dev,
- "comedi: usbdux: unlinked OutURB %d: res=%d\n",
- i, err);
}
}
return err;
if (!this_usbduxsub)
return -EFAULT;
- dev_dbg(&this_usbduxsub->interface->dev, "comedi: usbdux_ao_cancel\n");
if (do_unlink)
ret = usbduxsub_unlink_outurbs(this_usbduxsub);
usbduxsub->urb_in[i]->dev = usbduxsub->usbdev;
usbduxsub->urb_in[i]->status = 0;
usbduxsub->urb_in[i]->transfer_flags = URB_ISO_ASAP;
- dev_dbg(&usbduxsub->interface->dev,
- "comedi%d: submitting in-urb[%d]: %p,%p intv=%d\n",
- usbduxsub->comedidev->minor, i,
- (usbduxsub->urb_in[i]->context),
- (usbduxsub->urb_in[i]->dev),
- (usbduxsub->urb_in[i]->interval));
err_flag = usb_submit_urb(usbduxsub->urb_in[i], GFP_ATOMIC);
- if (err_flag) {
- dev_err(&usbduxsub->interface->dev,
- "comedi_: ai: usb_submit_urb(%d) error %d\n",
- i, err_flag);
+ if (err_flag)
return err_flag;
- }
}
return 0;
}
return -EFAULT;
for (i = 0; i < usbduxsub->num_out_buffers; i++) {
- dev_dbg(&usbduxsub->interface->dev,
- "comedi_: submitting out-urb[%d]\n", i);
/* in case of a resubmission after an unlink... */
usbduxsub->urb_out[i]->context = usbduxsub->comedidev;
usbduxsub->urb_out[i]->dev = usbduxsub->usbdev;
usbduxsub->urb_out[i]->status = 0;
usbduxsub->urb_out[i]->transfer_flags = URB_ISO_ASAP;
err_flag = usb_submit_urb(usbduxsub->urb_out[i], GFP_ATOMIC);
- if (err_flag) {
- dev_err(&usbduxsub->interface->dev,
- "comedi_: ao: usb_submit_urb(%d) error %d\n",
- i, err_flag);
+ if (err_flag)
return err_flag;
- }
}
return 0;
}
static int send_dux_commands(struct usbdux_private *this_usbduxsub, int cmd_type)
{
- int result, nsent;
+ int nsent;
this_usbduxsub->dux_commands[0] = cmd_type;
- result = usb_bulk_msg(this_usbduxsub->usbdev,
- usb_sndbulkpipe(this_usbduxsub->usbdev,
- COMMAND_OUT_EP),
- this_usbduxsub->dux_commands, SIZEOFDUXBUFFER,
- &nsent, BULK_TIMEOUT);
- if (result < 0)
- dev_err(&this_usbduxsub->interface->dev, "comedi%d: "
- "could not transmit dux_command to the usb-device, "
- "err=%d\n", this_usbduxsub->comedidev->minor, result);
-
- return result;
+
+ return usb_bulk_msg(this_usbduxsub->usbdev,
+ usb_sndbulkpipe(this_usbduxsub->usbdev,
+ COMMAND_OUT_EP),
+ this_usbduxsub->dux_commands, SIZEOFDUXBUFFER,
+ &nsent, BULK_TIMEOUT);
}
static int receive_dux_commands(struct usbdux_private *this_usbduxsub, int command)
COMMAND_IN_EP),
this_usbduxsub->insn_buffer, SIZEINSNBUF,
&nrec, BULK_TIMEOUT);
- if (result < 0) {
- dev_err(&this_usbduxsub->interface->dev, "comedi%d: "
- "insn: USB error %d while receiving DUX command"
- "\n", this_usbduxsub->comedidev->minor, result);
+ if (result < 0)
return result;
- }
if (le16_to_cpu(this_usbduxsub->insn_buffer[0]) == command)
return result;
}
/* this is only reached if the data has been requested a couple of
* times */
- dev_err(&this_usbduxsub->interface->dev, "comedi%d: insn: "
- "wrong data returned from firmware: want cmd %d, got cmd %d.\n",
- this_usbduxsub->comedidev->minor, command,
- le16_to_cpu(this_usbduxsub->insn_buffer[0]));
return -EFAULT;
}
return -EFAULT;
down(&this_usbduxsub->sem);
- dev_dbg(&this_usbduxsub->interface->dev,
- "comedi%d: usbdux_ai_inttrig\n", dev->minor);
if (trignum != 0) {
- dev_err(&this_usbduxsub->interface->dev,
- "comedi%d: usbdux_ai_inttrig: invalid trignum\n",
- dev->minor);
up(&this_usbduxsub->sem);
return -EINVAL;
}
this_usbduxsub->ai_cmd_running = 1;
ret = usbduxsub_submit_inurbs(this_usbduxsub);
if (ret < 0) {
- dev_err(&this_usbduxsub->interface->dev,
- "comedi%d: usbdux_ai_inttrig: "
- "urbSubmit: err=%d\n", dev->minor, ret);
this_usbduxsub->ai_cmd_running = 0;
up(&this_usbduxsub->sem);
return ret;
}
s->async->inttrig = NULL;
- } else {
- dev_err(&this_usbduxsub->interface->dev,
- "comedi%d: ai_inttrig but acqu is already running\n",
- dev->minor);
}
up(&this_usbduxsub->sem);
return 1;
if (!this_usbduxsub)
return -EFAULT;
- dev_dbg(&this_usbduxsub->interface->dev,
- "comedi%d: usbdux_ai_cmd\n", dev->minor);
-
/* block other CPUs from starting an ai_cmd */
down(&this_usbduxsub->sem);
if (this_usbduxsub->ai_cmd_running) {
- dev_err(&this_usbduxsub->interface->dev, "comedi%d: "
- "ai_cmd not possible. Another ai_cmd is running.\n",
- dev->minor);
up(&this_usbduxsub->sem);
return -EBUSY;
}
for (i = 0; i < cmd->chanlist_len; ++i) {
chan = CR_CHAN(cmd->chanlist[i]);
range = CR_RANGE(cmd->chanlist[i]);
- if (i >= NUMCHANNELS) {
- dev_err(&this_usbduxsub->interface->dev,
- "comedi%d: channel list too long\n",
- dev->minor);
+ if (i >= NUMCHANNELS)
break;
- }
this_usbduxsub->dux_commands[i + 2] =
create_adc_command(chan, range);
}
- dev_dbg(&this_usbduxsub->interface->dev,
- "comedi %d: sending commands to the usb device: size=%u\n",
- dev->minor, NUMCHANNELS);
-
result = send_dux_commands(this_usbduxsub, SENDADCOMMANDS);
if (result < 0) {
up(&this_usbduxsub->sem);
this_usbduxsub->ai_timer = cmd->scan_begin_arg / 1000000;
}
if (this_usbduxsub->ai_timer < 1) {
- dev_err(&this_usbduxsub->interface->dev, "comedi%d: ai_cmd: "
- "timer=%d, scan_begin_arg=%d. "
- "Not properly tested by cmdtest?\n", dev->minor,
- this_usbduxsub->ai_timer, cmd->scan_begin_arg);
up(&this_usbduxsub->sem);
return -EINVAL;
}
if (!this_usbduxsub)
return 0;
- dev_dbg(&this_usbduxsub->interface->dev,
- "comedi%d: ai_insn_read, insn->n=%d, insn->subdev=%d\n",
- dev->minor, insn->n, insn->subdev);
-
down(&this_usbduxsub->sem);
if (this_usbduxsub->ai_cmd_running) {
- dev_err(&this_usbduxsub->interface->dev,
- "comedi%d: ai_insn_read not possible. "
- "Async Command is running.\n", dev->minor);
up(&this_usbduxsub->sem);
return 0;
}
if (!this_usbduxsub)
return -EFAULT;
- dev_dbg(&this_usbduxsub->interface->dev,
- "comedi%d: ao_insn_write\n", dev->minor);
-
down(&this_usbduxsub->sem);
if (this_usbduxsub->ao_cmd_running) {
- dev_err(&this_usbduxsub->interface->dev,
- "comedi%d: ao_insn_write: "
- "ERROR: asynchronous ao_cmd is running\n", dev->minor);
up(&this_usbduxsub->sem);
return 0;
}
for (i = 0; i < insn->n; i++) {
- dev_dbg(&this_usbduxsub->interface->dev,
- "comedi%d: ao_insn_write: data[chan=%d,i=%d]=%d\n",
- dev->minor, chan, i, data[i]);
-
/* number of channels: 1 */
this_usbduxsub->dux_commands[1] = 1;
/* one 16 bit value */
down(&this_usbduxsub->sem);
if (trignum != 0) {
- dev_err(&this_usbduxsub->interface->dev,
- "comedi%d: usbdux_ao_inttrig: invalid trignum\n",
- dev->minor);
up(&this_usbduxsub->sem);
return -EINVAL;
}
this_usbduxsub->ao_cmd_running = 1;
ret = usbduxsub_submit_outurbs(this_usbduxsub);
if (ret < 0) {
- dev_err(&this_usbduxsub->interface->dev,
- "comedi%d: usbdux_ao_inttrig: submitURB: "
- "err=%d\n", dev->minor, ret);
this_usbduxsub->ao_cmd_running = 0;
up(&this_usbduxsub->sem);
return ret;
}
s->async->inttrig = NULL;
- } else {
- dev_err(&this_usbduxsub->interface->dev,
- "comedi%d: ao_inttrig but acqu is already running.\n",
- dev->minor);
}
up(&this_usbduxsub->sem);
return 1;
return -EFAULT;
down(&this_usbduxsub->sem);
- dev_dbg(&this_usbduxsub->interface->dev,
- "comedi%d: %s\n", dev->minor, __func__);
/* set current channel of the running acquisition to zero */
s->async->cur_chan = 0;
for (i = 0; i < cmd->chanlist_len; ++i) {
chan = CR_CHAN(cmd->chanlist[i]);
gain = CR_RANGE(cmd->chanlist[i]);
- if (i >= NUMOUTCHANNELS) {
- dev_err(&this_usbduxsub->interface->dev,
- "comedi%d: %s: channel list too long\n",
- dev->minor, __func__);
+ if (i >= NUMOUTCHANNELS)
break;
- }
this_usbduxsub->dac_commands[i] = (chan << 6);
- dev_dbg(&this_usbduxsub->interface->dev,
- "comedi%d: dac command for ch %d is %x\n",
- dev->minor, i, this_usbduxsub->dac_commands[i]);
}
/* we count in steps of 1ms (125us) */
/* 1ms */
/* timing of the scan: we get all channels at once */
this_usbduxsub->ao_timer = cmd->scan_begin_arg / 1000000;
- dev_dbg(&this_usbduxsub->interface->dev,
- "comedi%d: scan_begin_src=%d, scan_begin_arg=%d, "
- "convert_src=%d, convert_arg=%d\n", dev->minor,
- cmd->scan_begin_src, cmd->scan_begin_arg,
- cmd->convert_src, cmd->convert_arg);
- dev_dbg(&this_usbduxsub->interface->dev,
- "comedi%d: ao_timer=%d (ms)\n",
- dev->minor, this_usbduxsub->ao_timer);
if (this_usbduxsub->ao_timer < 1) {
- dev_err(&this_usbduxsub->interface->dev,
- "comedi%d: usbdux: ao_timer=%d, "
- "scan_begin_arg=%d. "
- "Not properly tested by cmdtest?\n",
- dev->minor, this_usbduxsub->ao_timer,
- cmd->scan_begin_arg);
up(&this_usbduxsub->sem);
return -EINVAL;
}
if (usbduxsub_tmp && usbduxsub_tmp->urb_pwm) {
if (usbduxsub_tmp->urb_pwm)
usb_kill_urb(usbduxsub_tmp->urb_pwm);
- dev_dbg(&usbduxsub_tmp->interface->dev,
- "comedi: unlinked PwmURB: res=%d\n", err);
}
return err;
}
if (!this_usbduxsub)
return -EFAULT;
- dev_dbg(&this_usbduxsub->interface->dev, "comedi: %s\n", __func__);
if (do_unlink)
ret = usbduxsub_unlink_pwm_urbs(this_usbduxsub);
/* unlink only if it is really running */
res = usbdux_pwm_stop(this_usbduxsub, this_usbduxsub->pwm_cmd_running);
- dev_dbg(&this_usbduxsub->interface->dev,
- "comedi %d: sending pwm off command to the usb device.\n",
- dev->minor);
-
return send_dux_commands(this_usbduxsub, SENDPWMOFF);
}
if (!usbduxsub)
return -EFAULT;
- dev_dbg(&usbduxsub->interface->dev, "comedi_: submitting pwm-urb\n");
-
/* in case of a resubmission after an unlink... */
usb_fill_bulk_urb(usbduxsub->urb_pwm,
usbduxsub->usbdev,
usbduxsub->comedidev);
err_flag = usb_submit_urb(usbduxsub->urb_pwm, GFP_ATOMIC);
- if (err_flag) {
- dev_err(&usbduxsub->interface->dev,
- "comedi_: usbdux: pwm: usb_submit_urb error %d\n",
- err_flag);
+ if (err_flag)
return err_flag;
- }
return 0;
}
int fx2delay = 255;
if (period < MIN_PWM_PERIOD) {
- dev_err(&this_usbduxsub->interface->dev,
- "comedi%d: illegal period setting for pwm.\n",
- dev->minor);
return -EAGAIN;
} else {
fx2delay = period / ((int)(6 * 512 * (1.0 / 0.033))) - 6;
- if (fx2delay > 255) {
- dev_err(&this_usbduxsub->interface->dev,
- "comedi%d: period %d for pwm is too low.\n",
- dev->minor, period);
+ if (fx2delay > 255)
return -EAGAIN;
- }
}
this_usbduxsub->pwn_delay = fx2delay;
this_usbduxsub->pwm_period = period;
- dev_dbg(&this_usbduxsub->interface->dev, "%s: frequ=%d, period=%d\n",
- __func__, period, fx2delay);
+
return 0;
}
int ret, i;
struct usbdux_private *this_usbduxsub = dev->private;
- dev_dbg(&this_usbduxsub->interface->dev, "comedi%d: %s\n",
- dev->minor, __func__);
-
if (this_usbduxsub->pwm_cmd_running) {
/* already running */
return 0;
switch (data[0]) {
case INSN_CONFIG_ARM:
/* switch it on */
- dev_dbg(&this_usbduxsub->interface->dev,
- "comedi%d: %s: pwm on\n", dev->minor, __func__);
/*
* if not zero the PWM is limited to a certain time which is
* not supported here
return -EINVAL;
return usbdux_pwm_start(dev, s);
case INSN_CONFIG_DISARM:
- dev_dbg(&this_usbduxsub->interface->dev,
- "comedi%d: %s: pwm off\n", dev->minor, __func__);
return usbdux_pwm_cancel(dev, s);
case INSN_CONFIG_GET_PWM_STATUS:
/*
data[1] = this_usbduxsub->pwm_cmd_running;
return 0;
case INSN_CONFIG_PWM_SET_PERIOD:
- dev_dbg(&this_usbduxsub->interface->dev,
- "comedi%d: %s: setting period\n", dev->minor, __func__);
return usbdux_pwm_period(dev, s, data[1]);
case INSN_CONFIG_PWM_GET_PERIOD:
data[1] = this_usbduxsub->pwm_period;