struct usbduxsigma_private {
/* actual number of in-buffers */
- int numOfInBuffers;
+ int n_ai_urbs;
/* actual number of out-buffers */
- int numOfOutBuffers;
+ int n_ao_urbs;
/* ISO-transfer handling: buffers */
- struct urb **urbIn;
- struct urb **urbOut;
+ struct urb **ai_urbs;
+ struct urb **ao_urbs;
/* pwm-transfer handling */
- struct urb *urbPwm;
+ struct urb *pwm_urb;
/* PWM period */
- unsigned int pwmPeriod;
+ unsigned int pwm_period;
/* PWM internal delay for the GPIF in the FX2 */
- uint8_t pwmDelay;
+ uint8_t pwm_delay;
/* size of the PWM buffer which holds the bit pattern */
- int sizePwmBuf;
+ int pwm_buf_sz;
/* input buffer for the ISO-transfer */
- int32_t *inBuffer;
+ int32_t *in_buf;
/* input buffer for single insn */
- int8_t *insnBuffer;
+ int8_t *insn_buf;
unsigned int ao_readback[USBDUXSIGMA_NUM_AO_CHAN];
if (do_unlink) {
int i;
- for (i = 0; i < devpriv->numOfInBuffers; i++) {
- if (devpriv->urbIn[i])
- usb_kill_urb(devpriv->urbIn[i]);
+ for (i = 0; i < devpriv->n_ai_urbs; i++) {
+ if (devpriv->ai_urbs[i])
+ usb_kill_urb(devpriv->ai_urbs[i]);
}
}
switch (urb->status) {
case 0:
/* copy the result in the transfer buffer */
- memcpy(devpriv->inBuffer, urb->transfer_buffer, SIZEINBUF);
+ memcpy(devpriv->in_buf, urb->transfer_buffer, SIZEINBUF);
break;
case -EILSEQ:
/*
}
/* get the state of the dio pins to allow external trigger */
- dio_state = be32_to_cpu(devpriv->inBuffer[0]);
+ dio_state = be32_to_cpu(devpriv->in_buf[0]);
devpriv->ai_counter--;
if (likely(devpriv->ai_counter > 0))
/* get the data from the USB bus and hand it over to comedi */
for (i = 0; i < s->async->cmd.chanlist_len; i++) {
/* transfer data, note first byte is the DIO state */
- val = be32_to_cpu(devpriv->inBuffer[i+1]);
+ val = be32_to_cpu(devpriv->in_buf[i+1]);
val &= 0x00ffffff; /* strip status byte */
val ^= 0x00800000; /* convert to unsigned */
if (do_unlink) {
int i;
- for (i = 0; i < devpriv->numOfOutBuffers; i++) {
- if (devpriv->urbOut[i])
- usb_kill_urb(devpriv->urbOut[i]);
+ for (i = 0; i < devpriv->n_ao_urbs; i++) {
+ if (devpriv->ao_urbs[i])
+ usb_kill_urb(devpriv->ao_urbs[i]);
}
}
for (i = 0; i < RETRIES; i++) {
ret = usb_bulk_msg(usb,
usb_rcvbulkpipe(usb, USBDUXSIGMA_CMD_IN_EP),
- devpriv->insnBuffer, SIZEINSNBUF,
+ devpriv->insn_buf, SIZEINSNBUF,
&nrec, BULK_TIMEOUT);
if (ret < 0)
return ret;
- if (devpriv->insnBuffer[0] == command)
+ if (devpriv->insn_buf[0] == command)
return 0;
}
/*
down(&devpriv->sem);
if (!devpriv->ai_cmd_running) {
- ret = usbduxsigma_submit_urbs(dev, devpriv->urbIn,
- devpriv->numOfInBuffers, 1);
+ ret = usbduxsigma_submit_urbs(dev, devpriv->ai_urbs,
+ devpriv->n_ai_urbs, 1);
if (ret < 0) {
up(&devpriv->sem);
return ret;
if (cmd->start_src == TRIG_NOW) {
/* enable this acquisition operation */
- ret = usbduxsigma_submit_urbs(dev, devpriv->urbIn,
- devpriv->numOfInBuffers, 1);
+ ret = usbduxsigma_submit_urbs(dev, devpriv->ai_urbs,
+ devpriv->n_ai_urbs, 1);
if (ret < 0) {
up(&devpriv->sem);
return ret;
}
/* 32 bits big endian from the A/D converter */
- val = be32_to_cpu(*((int32_t *)((devpriv->insnBuffer) + 1)));
+ val = be32_to_cpu(*((int32_t *)((devpriv->insn_buf) + 1)));
val &= 0x00ffffff; /* strip status byte */
val ^= 0x00800000; /* convert to unsigned */
down(&devpriv->sem);
if (!devpriv->ao_cmd_running) {
- ret = usbduxsigma_submit_urbs(dev, devpriv->urbOut,
- devpriv->numOfOutBuffers, 0);
+ ret = usbduxsigma_submit_urbs(dev, devpriv->ao_urbs,
+ devpriv->n_ao_urbs, 0);
if (ret < 0) {
up(&devpriv->sem);
return ret;
if (cmd->start_src == TRIG_NOW) {
/* enable this acquisition operation */
- ret = usbduxsigma_submit_urbs(dev, devpriv->urbOut,
- devpriv->numOfOutBuffers, 0);
+ ret = usbduxsigma_submit_urbs(dev, devpriv->ao_urbs,
+ devpriv->n_ao_urbs, 0);
if (ret < 0) {
up(&devpriv->sem);
return ret;
if (ret < 0)
goto done;
- s->state = devpriv->insnBuffer[1] |
- (devpriv->insnBuffer[2] << 8) |
- (devpriv->insnBuffer[3] << 16);
+ s->state = devpriv->insn_buf[1] |
+ (devpriv->insn_buf[2] << 8) |
+ (devpriv->insn_buf[3] << 16);
data[1] = s->state;
ret = insn->n;
struct usbduxsigma_private *devpriv = dev->private;
if (do_unlink) {
- if (devpriv->urbPwm)
- usb_kill_urb(devpriv->urbPwm);
+ if (devpriv->pwm_urb)
+ usb_kill_urb(devpriv->pwm_urb);
}
devpriv->pwm_cmd_running = 0;
if (!devpriv->pwm_cmd_running)
return;
- urb->transfer_buffer_length = devpriv->sizePwmBuf;
+ urb->transfer_buffer_length = devpriv->pwm_buf_sz;
urb->dev = comedi_to_usb_dev(dev);
urb->status = 0;
ret = usb_submit_urb(urb, GFP_ATOMIC);
{
struct usb_device *usb = comedi_to_usb_dev(dev);
struct usbduxsigma_private *devpriv = dev->private;
- struct urb *urb = devpriv->urbPwm;
+ struct urb *urb = devpriv->pwm_urb;
/* in case of a resubmission after an unlink... */
usb_fill_bulk_urb(urb,
usb, usb_sndbulkpipe(usb, USBDUXSIGMA_PWM_OUT_EP),
- urb->transfer_buffer, devpriv->sizePwmBuf,
+ urb->transfer_buffer, devpriv->pwm_buf_sz,
usbduxsigma_pwm_urb_complete, dev);
return usb_submit_urb(urb, GFP_ATOMIC);
if (fx2delay > 255)
return -EAGAIN;
}
- devpriv->pwmDelay = fx2delay;
- devpriv->pwmPeriod = period;
+ devpriv->pwm_delay = fx2delay;
+ devpriv->pwm_period = period;
return 0;
}
if (devpriv->pwm_cmd_running)
return 0;
- devpriv->dux_commands[1] = devpriv->pwmDelay;
+ devpriv->dux_commands[1] = devpriv->pwm_delay;
ret = usbbuxsigma_send_cmd(dev, USBDUXSIGMA_PWM_ON_CMD);
if (ret < 0)
return ret;
- memset(devpriv->urbPwm->transfer_buffer, 0, devpriv->sizePwmBuf);
+ memset(devpriv->pwm_urb->transfer_buffer, 0, devpriv->pwm_buf_sz);
ret = usbduxsigma_submit_pwm_urb(dev);
if (ret < 0)
struct usbduxsigma_private *devpriv = dev->private;
char pwm_mask = (1 << chan); /* DIO bit for the PWM data */
char sgn_mask = (16 << chan); /* DIO bit for the sign */
- char *buf = (char *)(devpriv->urbPwm->transfer_buffer);
- int szbuf = devpriv->sizePwmBuf;
+ char *buf = (char *)(devpriv->pwm_urb->transfer_buffer);
+ int szbuf = devpriv->pwm_buf_sz;
int i;
for (i = 0; i < szbuf; i++) {
case INSN_CONFIG_PWM_SET_PERIOD:
return usbduxsigma_pwm_period(dev, s, data[1]);
case INSN_CONFIG_PWM_GET_PERIOD:
- data[1] = devpriv->pwmPeriod;
+ data[1] = devpriv->pwm_period;
return 0;
case INSN_CONFIG_PWM_SET_H_BRIDGE:
/*
return ret;
/* 32 bits big endian from the A/D converter */
- val = be32_to_cpu(*((int32_t *)((devpriv->insnBuffer)+1)));
+ val = be32_to_cpu(*((int32_t *)((devpriv->insn_buf)+1)));
val &= 0x00ffffff; /* strip status byte */
val ^= 0x00800000; /* convert to unsigned */
s->type = COMEDI_SUBD_PWM;
s->subdev_flags = SDF_WRITABLE | SDF_PWM_HBRIDGE;
s->n_chan = 8;
- s->maxdata = devpriv->sizePwmBuf;
+ s->maxdata = devpriv->pwm_buf_sz;
s->insn_write = usbduxsigma_pwm_write;
s->insn_config = usbduxsigma_pwm_config;
devpriv->dac_commands = kzalloc(NUMOUTCHANNELS, GFP_KERNEL);
devpriv->dux_commands = kzalloc(SIZEOFDUXBUFFER, GFP_KERNEL);
- devpriv->inBuffer = kzalloc(SIZEINBUF, GFP_KERNEL);
- devpriv->insnBuffer = kzalloc(SIZEINSNBUF, GFP_KERNEL);
- devpriv->urbIn = kcalloc(devpriv->numOfInBuffers, sizeof(*urb),
- GFP_KERNEL);
- devpriv->urbOut = kcalloc(devpriv->numOfOutBuffers, sizeof(*urb),
- GFP_KERNEL);
+ devpriv->in_buf = kzalloc(SIZEINBUF, GFP_KERNEL);
+ devpriv->insn_buf = kzalloc(SIZEINSNBUF, GFP_KERNEL);
+ devpriv->ai_urbs = kcalloc(devpriv->n_ai_urbs, sizeof(*urb),
+ GFP_KERNEL);
+ devpriv->ao_urbs = kcalloc(devpriv->n_ao_urbs, sizeof(*urb),
+ GFP_KERNEL);
if (!devpriv->dac_commands || !devpriv->dux_commands ||
- !devpriv->inBuffer || !devpriv->insnBuffer ||
- !devpriv->urbIn || !devpriv->urbOut)
+ !devpriv->in_buf || !devpriv->insn_buf ||
+ !devpriv->ai_urbs || !devpriv->ao_urbs)
return -ENOMEM;
- for (i = 0; i < devpriv->numOfInBuffers; i++) {
+ for (i = 0; i < devpriv->n_ai_urbs; i++) {
/* one frame: 1ms */
urb = usb_alloc_urb(1, GFP_KERNEL);
if (!urb)
return -ENOMEM;
- devpriv->urbIn[i] = urb;
+ devpriv->ai_urbs[i] = urb;
urb->dev = usb;
/* will be filled later with a pointer to the comedi-device */
/* and ONLY then the urb should be submitted */
urb->iso_frame_desc[0].length = SIZEINBUF;
}
- for (i = 0; i < devpriv->numOfOutBuffers; i++) {
+ for (i = 0; i < devpriv->n_ao_urbs; i++) {
/* one frame: 1ms */
urb = usb_alloc_urb(1, GFP_KERNEL);
if (!urb)
return -ENOMEM;
- devpriv->urbOut[i] = urb;
+ devpriv->ao_urbs[i] = urb;
urb->dev = usb;
/* will be filled later with a pointer to the comedi-device */
/* and ONLY then the urb should be submitted */
if (devpriv->high_speed) {
/* max bulk ep size in high speed */
- devpriv->sizePwmBuf = 512;
+ devpriv->pwm_buf_sz = 512;
urb = usb_alloc_urb(0, GFP_KERNEL);
if (!urb)
return -ENOMEM;
- devpriv->urbPwm = urb;
- urb->transfer_buffer = kzalloc(devpriv->sizePwmBuf, GFP_KERNEL);
+ devpriv->pwm_urb = urb;
+ urb->transfer_buffer = kzalloc(devpriv->pwm_buf_sz, GFP_KERNEL);
if (!urb->transfer_buffer)
return -ENOMEM;
} else {
- devpriv->urbPwm = NULL;
- devpriv->sizePwmBuf = 0;
+ devpriv->pwm_urb = NULL;
+ devpriv->pwm_buf_sz = 0;
}
return 0;
usbduxsigma_ao_stop(dev, 1);
usbduxsigma_pwm_stop(dev, 1);
- urb = devpriv->urbPwm;
+ urb = devpriv->pwm_urb;
if (urb) {
kfree(urb->transfer_buffer);
usb_free_urb(urb);
}
- if (devpriv->urbOut) {
- for (i = 0; i < devpriv->numOfOutBuffers; i++) {
- urb = devpriv->urbOut[i];
+ if (devpriv->ao_urbs) {
+ for (i = 0; i < devpriv->n_ao_urbs; i++) {
+ urb = devpriv->ao_urbs[i];
if (urb) {
kfree(urb->transfer_buffer);
usb_free_urb(urb);
}
}
- kfree(devpriv->urbOut);
+ kfree(devpriv->ao_urbs);
}
- if (devpriv->urbIn) {
- for (i = 0; i < devpriv->numOfInBuffers; i++) {
- urb = devpriv->urbIn[i];
+ if (devpriv->ai_urbs) {
+ for (i = 0; i < devpriv->n_ai_urbs; i++) {
+ urb = devpriv->ai_urbs[i];
if (urb) {
kfree(urb->transfer_buffer);
usb_free_urb(urb);
}
}
- kfree(devpriv->urbIn);
+ kfree(devpriv->ai_urbs);
}
- kfree(devpriv->insnBuffer);
- kfree(devpriv->inBuffer);
+ kfree(devpriv->insn_buf);
+ kfree(devpriv->in_buf);
kfree(devpriv->dux_commands);
kfree(devpriv->dac_commands);
}
/* test if it is high speed (USB 2.0) */
devpriv->high_speed = (usb->speed == USB_SPEED_HIGH);
if (devpriv->high_speed) {
- devpriv->numOfInBuffers = NUMOFINBUFFERSHIGH;
- devpriv->numOfOutBuffers = NUMOFOUTBUFFERSHIGH;
+ devpriv->n_ai_urbs = NUMOFINBUFFERSHIGH;
+ devpriv->n_ao_urbs = NUMOFOUTBUFFERSHIGH;
} else {
- devpriv->numOfInBuffers = NUMOFINBUFFERSFULL;
- devpriv->numOfOutBuffers = NUMOFOUTBUFFERSFULL;
+ devpriv->n_ai_urbs = NUMOFINBUFFERSFULL;
+ devpriv->n_ao_urbs = NUMOFOUTBUFFERSFULL;
}
ret = usbduxsigma_alloc_usb_buffers(dev);