Staging: comedi: usbdux: code style cleanups

Fix a lot of checkpatch.pl warnings and errors in the usbdux driver.

Cc: Bernd Porr <BerndPorr@f2s.com>
Cc: David Schleef <ds@schleef.org>
Cc: Frank Mori Hess <fmhess@users.sourceforge.net>
Cc: Ian Abbott <abbotti@mev.co.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
This commit is contained in:
Greg Kroah-Hartman 2008-11-18 14:04:52 -08:00
parent 4398ecfac1
commit 8fa07567bf
1 changed files with 221 additions and 237 deletions

View File

@ -317,9 +317,11 @@ static int usbduxsub_unlink_InURBs(usbduxsub_t * usbduxsub_tmp)
return err;
}
/* This will stop a running acquisition operation */
// Is called from within this driver from both the
// interrupt context and from comedi
/*
* This will stop a running acquisition operation
* Is called from within this driver from both the
* interrupt context and from comedi
*/
static int usbdux_ai_stop(usbduxsub_t *this_usbduxsub, int do_unlink)
{
int ret = 0;
@ -460,27 +462,26 @@ static void usbduxsub_ai_IsocIrq(struct urb *urb)
urb->dev = this_usbduxsub->usbdev;
// resubmit the urb
/* resubmit the urb */
err = USB_SUBMIT_URB(urb);
if (unlikely(err < 0)) {
printk("comedi_: usbdux_: urb resubmit failed in int-context! err=%d ", err);
if (err == -EL2NSYNC) {
if (err == -EL2NSYNC)
printk("--> buggy USB host controller or bug in IRQ handler!\n");
} else {
else
printk("\n");
}
s->async->events |= COMEDI_CB_EOA;
s->async->events |= COMEDI_CB_ERROR;
comedi_event(this_usbduxsub->comedidev, s);
// don't do an unlink here
/* don't do an unlink here */
usbdux_ai_stop(this_usbduxsub, 0);
return;
}
this_usbduxsub->ai_counter--;
if (likely(this_usbduxsub->ai_counter > 0)) {
if (likely(this_usbduxsub->ai_counter > 0))
return;
}
// timer zero, transfer measurements to comedi
this_usbduxsub->ai_counter = this_usbduxsub->ai_timer;
@ -521,14 +522,13 @@ static void usbduxsub_ai_IsocIrq(struct urb *urb)
static int usbduxsub_unlink_OutURBs(usbduxsub_t *usbduxsub_tmp)
{
int i = 0;
int err = 0;
if (usbduxsub_tmp && usbduxsub_tmp->urbOut) {
for (i = 0; i < usbduxsub_tmp->numOfOutBuffers; i++) {
if (usbduxsub_tmp->urbOut[i]) {
if (usbduxsub_tmp->urbOut[i])
usb_kill_urb(usbduxsub_tmp->urbOut[i]);
}
#ifdef NOISY_DUX_DEBUGBUG
printk("comedi: usbdux: unlinked OutURB %d: res=%d\n",
i, err);
@ -554,17 +554,15 @@ static int usbdux_ao_stop(usbduxsub_t * this_usbduxsub, int do_unlink)
#ifdef NOISY_DUX_DEBUGBUG
printk("comedi: usbdux_ao_cancel\n");
#endif
if (do_unlink) {
if (do_unlink)
ret = usbduxsub_unlink_OutURBs(this_usbduxsub);
}
this_usbduxsub->ao_cmd_running = 0;
return ret;
}
// force unlink
// is called by comedi
/* force unlink, is called by comedi */
static int usbdux_ao_cancel(comedi_device *dev, comedi_subdevice *s)
{
usbduxsub_t *this_usbduxsub = dev->private;
@ -618,12 +616,12 @@ static void usbduxsub_ao_IsocIrq(struct urb *urb)
/* success */
break;
// after an unlink command, unplug, ... etc
// no unlink needed here. Already shutting down.
case -ECONNRESET:
case -ENOENT:
case -ESHUTDOWN:
case -ECONNABORTED:
// after an unlink command, unplug, ... etc
// no unlink needed here. Already shutting down.
if (this_usbduxsub->ao_cmd_running) {
s->async->events |= COMEDI_CB_EOA;
comedi_event(this_usbduxsub->comedidev, s);
@ -631,8 +629,8 @@ static void usbduxsub_ao_IsocIrq(struct urb *urb)
}
return;
// a real error
default:
// a real error
if (this_usbduxsub->ao_cmd_running) {
printk("comedi_: usbdux_: Non-zero urb status received in ao intr context: %d\n", urb->status);
s->async->events |= COMEDI_CB_ERROR;
@ -645,9 +643,9 @@ static void usbduxsub_ao_IsocIrq(struct urb *urb)
}
// are we actually running?
if (!(this_usbduxsub->ao_cmd_running)) {
if (!(this_usbduxsub->ao_cmd_running))
return;
}
// normal operation: executing a command in this subdevice
this_usbduxsub->ao_counter--;
if (this_usbduxsub->ao_counter <= 0) {
@ -672,9 +670,9 @@ static void usbduxsub_ao_IsocIrq(struct urb *urb)
s->async->cmd.chanlist_len;
for (i = 0; i < s->async->cmd.chanlist_len; i++) {
sampl_t temp;
if (i >= NUMOUTCHANNELS) {
if (i >= NUMOUTCHANNELS)
break;
}
// pointer to the DA
datap = (&(((int8_t *) urb->transfer_buffer)[i * 3 + 1]));
// get the data from comedi
@ -712,11 +710,11 @@ static void usbduxsub_ao_IsocIrq(struct urb *urb)
if ((ret = USB_SUBMIT_URB(urb)) < 0) {
printk("comedi_: usbdux_: ao urb resubm failed in int-cont.");
printk("ret=%d", ret);
if (ret == EL2NSYNC) {
if (ret == EL2NSYNC)
printk("--> buggy USB host controller or bug in IRQ handling!\n");
} else {
else
printk("\n");
}
s->async->events |= COMEDI_CB_EOA;
s->async->events |= COMEDI_CB_ERROR;
comedi_event(this_usbduxsub->comedidev, s);
@ -834,8 +832,8 @@ static int usbduxsub_upload(usbduxsub_t * usbduxsub,
return 0;
}
int firmwareUpload(usbduxsub_t * usbduxsub,
uint8_t * firmwareBinary, int sizeFirmware)
static int firmwareUpload(usbduxsub_t *usbduxsub, uint8_t *firmwareBinary,
int sizeFirmware)
{
int ret;
@ -860,16 +858,16 @@ int firmwareUpload(usbduxsub_t * usbduxsub,
return 0;
}
int usbduxsub_submit_InURBs(usbduxsub_t * usbduxsub)
static int usbduxsub_submit_InURBs(usbduxsub_t *usbduxsub)
{
int i, errFlag;
if (!usbduxsub) {
if (!usbduxsub)
return -EFAULT;
}
/* Submit all URBs and start the transfer on the bus */
for (i = 0; i < usbduxsub->numOfInBuffers; i++) {
// in case of a resubmission after an unlink...
/* in case of a resubmission after an unlink... */
usbduxsub->urbIn[i]->interval = usbduxsub->ai_interval;
usbduxsub->urbIn[i]->context = usbduxsub->comedidev;
usbduxsub->urbIn[i]->dev = usbduxsub->usbdev;
@ -889,7 +887,7 @@ int usbduxsub_submit_InURBs(usbduxsub_t * usbduxsub)
return 0;
}
int usbduxsub_submit_OutURBs(usbduxsub_t * usbduxsub)
static int usbduxsub_submit_OutURBs(usbduxsub_t *usbduxsub)
{
int i, errFlag;
@ -916,8 +914,8 @@ int usbduxsub_submit_OutURBs(usbduxsub_t * usbduxsub)
return 0;
}
static int usbdux_ai_cmdtest(comedi_device * dev,
comedi_subdevice * s, comedi_cmd * cmd)
static int usbdux_ai_cmdtest(comedi_device *dev, comedi_subdevice *s,
comedi_cmd *cmd)
{
int err = 0, tmp, i;
unsigned int tmpTimer;
@ -1089,9 +1087,9 @@ static int send_dux_commands(usbduxsub_t * this_usbduxsub, int cmd_type)
usb_sndbulkpipe(this_usbduxsub->usbdev,
COMMAND_OUT_EP),
this_usbduxsub->dux_commands, SIZEOFDUXBUFFER, &nsent, 10 * HZ);
if (result < 0) {
if (result < 0)
printk("comedi%d: could not transmit dux_command to the usb-device, err=%d\n", this_usbduxsub->comedidev->minor, result);
}
return result;
}
@ -1119,8 +1117,8 @@ static int receive_dux_commands(usbduxsub_t * this_usbduxsub, int command)
return -EFAULT;
}
static int usbdux_ai_inttrig(comedi_device * dev,
comedi_subdevice * s, unsigned int trignum)
static int usbdux_ai_inttrig(comedi_device *dev, comedi_subdevice *s,
unsigned int trignum)
{
int ret;
usbduxsub_t *this_usbduxsub = dev->private;
@ -1171,10 +1169,10 @@ static int usbdux_ai_cmd(comedi_device * dev, comedi_subdevice * s)
#ifdef NOISY_DUX_DEBUGBUG
printk("comedi%d: usbdux_ai_cmd\n", dev->minor);
#endif
if (!this_usbduxsub) {
if (!this_usbduxsub)
return -EFAULT;
}
// block other CPUs from starting an ai_cmd
/* block other CPUs from starting an ai_cmd */
down(&this_usbduxsub->sem);
if (!(this_usbduxsub->probed)) {
@ -1186,7 +1184,7 @@ static int usbdux_ai_cmd(comedi_device * dev, comedi_subdevice * s)
up(&this_usbduxsub->sem);
return -EBUSY;
}
// set current channel of the running aquisition to zero
/* set current channel of the running aquisition to zero */
s->async->cur_chan = 0;
this_usbduxsub->dux_commands[1] = cmd->chanlist_len;
@ -1211,20 +1209,21 @@ static int usbdux_ai_cmd(comedi_device * dev, comedi_subdevice * s)
}
if (this_usbduxsub->high_speed) {
// every channel gets a time window of 125us. Thus, if we
// sample all 8 channels we need 1ms. If we sample only
// one channel we need only 125us
/*
* every channel gets a time window of 125us. Thus, if we
* sample all 8 channels we need 1ms. If we sample only one
* channel we need only 125us
*/
this_usbduxsub->ai_interval = 1;
// find a power of 2 for the interval
/* find a power of 2 for the interval */
while ((this_usbduxsub->ai_interval) < (cmd->chanlist_len)) {
this_usbduxsub->ai_interval =
(this_usbduxsub->ai_interval) * 2;
}
this_usbduxsub->ai_timer =
cmd->scan_begin_arg / (125000 *
this_usbduxsub->ai_timer = cmd->scan_begin_arg / (125000 *
(this_usbduxsub->ai_interval));
} else {
// interval always 1ms
/* interval always 1ms */
this_usbduxsub->ai_interval = 1;
this_usbduxsub->ai_timer = cmd->scan_begin_arg / 1000000;
}
@ -1267,8 +1266,8 @@ static int usbdux_ai_cmd(comedi_device * dev, comedi_subdevice * s)
}
/* Mode 0 is used to get a single conversion on demand */
static int usbdux_ai_insn_read(comedi_device * dev,
comedi_subdevice * s, comedi_insn * insn, lsampl_t * data)
static int usbdux_ai_insn_read(comedi_device *dev, comedi_subdevice *s,
comedi_insn *insn, lsampl_t *data)
{
int i;
lsampl_t one = 0;
@ -1314,9 +1313,9 @@ static int usbdux_ai_insn_read(comedi_device * dev,
return 0;
}
one = le16_to_cpu(this_usbduxsub->insnBuffer[1]);
if (CR_RANGE(insn->chanspec) <= 1) {
if (CR_RANGE(insn->chanspec) <= 1)
one = one ^ 0x800;
}
data[i] = one;
}
up(&this_usbduxsub->sem);
@ -1333,17 +1332,17 @@ static int usbdux_ao_insn_read(comedi_device * dev, comedi_subdevice * s,
int chan = CR_CHAN(insn->chanspec);
usbduxsub_t *this_usbduxsub = dev->private;
if (!this_usbduxsub) {
if (!this_usbduxsub)
return -EFAULT;
}
down(&this_usbduxsub->sem);
if (!(this_usbduxsub->probed)) {
up(&this_usbduxsub->sem);
return -ENODEV;
}
for (i = 0; i < insn->n; i++) {
for (i = 0; i < insn->n; i++)
data[i] = this_usbduxsub->outBuffer[chan];
}
up(&this_usbduxsub->sem);
return i;
}
@ -1358,9 +1357,9 @@ static int usbdux_ao_insn_write(comedi_device * dev, comedi_subdevice * s,
#ifdef NOISY_DUX_DEBUGBUG
printk("comedi%d: ao_insn_write\n", dev->minor);
#endif
if (!this_usbduxsub) {
if (!this_usbduxsub)
return -EFAULT;
}
down(&this_usbduxsub->sem);
if (!(this_usbduxsub->probed)) {
up(&this_usbduxsub->sem);
@ -1402,9 +1401,9 @@ static int usbdux_ao_inttrig(comedi_device * dev, comedi_subdevice * s,
int ret;
usbduxsub_t *this_usbduxsub = dev->private;
if (!this_usbduxsub) {
if (!this_usbduxsub)
return -EFAULT;
}
down(&this_usbduxsub->sem);
if (!(this_usbduxsub->probed)) {
up(&this_usbduxsub->sem);
@ -1433,18 +1432,18 @@ static int usbdux_ao_inttrig(comedi_device * dev, comedi_subdevice * s,
return 1;
}
static int usbdux_ao_cmdtest(comedi_device * dev,
comedi_subdevice * s, comedi_cmd * cmd)
static int usbdux_ao_cmdtest(comedi_device *dev, comedi_subdevice *s,
comedi_cmd *cmd)
{
int err = 0, tmp;
usbduxsub_t *this_usbduxsub = dev->private;
if (!this_usbduxsub) {
if (!this_usbduxsub)
return -EFAULT;
}
if (!(this_usbduxsub->probed)) {
if (!(this_usbduxsub->probed))
return -ENODEV;
}
#ifdef NOISY_DUX_DEBUGBUG
printk("comedi%d: usbdux_ao_cmdtest\n", dev->minor);
#endif
@ -1573,9 +1572,9 @@ static int usbdux_ao_cmd(comedi_device * dev, comedi_subdevice * s)
int i, ret;
usbduxsub_t *this_usbduxsub = dev->private;
if (!this_usbduxsub) {
if (!this_usbduxsub)
return -EFAULT;
}
down(&this_usbduxsub->sem);
if (!(this_usbduxsub->probed)) {
up(&this_usbduxsub->sem);
@ -1666,8 +1665,8 @@ static int usbdux_ao_cmd(comedi_device * dev, comedi_subdevice * s)
return 0;
}
static int usbdux_dio_insn_config(comedi_device * dev,
comedi_subdevice * s, comedi_insn * insn, lsampl_t * data)
static int usbdux_dio_insn_config(comedi_device *dev, comedi_subdevice *s,
comedi_insn *insn, lsampl_t *data)
{
int chan = CR_CHAN(insn->chanspec);
@ -1697,16 +1696,16 @@ static int usbdux_dio_insn_config(comedi_device * dev,
return insn->n;
}
static int usbdux_dio_insn_bits(comedi_device * dev,
comedi_subdevice * s, comedi_insn * insn, lsampl_t * data)
static int usbdux_dio_insn_bits(comedi_device *dev, comedi_subdevice *s,
comedi_insn *insn, lsampl_t *data)
{
usbduxsub_t *this_usbduxsub = dev->private;
int err;
if (!this_usbduxsub) {
if (!this_usbduxsub)
return -EFAULT;
}
if (insn->n != 2)
return -EINVAL;
@ -1742,8 +1741,7 @@ static int usbdux_dio_insn_bits(comedi_device * dev,
return 2;
}
// reads the 4 counters
// only two are used just now
/* reads the 4 counters, only two are used just now */
static int usbdux_counter_read(comedi_device *dev, comedi_subdevice *s,
comedi_insn *insn, lsampl_t *data)
{
@ -1751,9 +1749,8 @@ static int usbdux_counter_read(comedi_device * dev, comedi_subdevice * s,
int chan = insn->chanspec;
int err;
if (!this_usbduxsub) {
if (!this_usbduxsub)
return -EFAULT;
}
down(&this_usbduxsub->sem);
@ -1784,9 +1781,8 @@ static int usbdux_counter_write(comedi_device * dev, comedi_subdevice * s,
usbduxsub_t *this_usbduxsub = dev->private;
int err;
if (!this_usbduxsub) {
if (!this_usbduxsub)
return -EFAULT;
}
down(&this_usbduxsub->sem);
@ -1848,32 +1844,30 @@ static int usbdux_pwm_stop(usbduxsub_t * this_usbduxsub, int do_unlink)
#ifdef NOISY_DUX_DEBUGBUG
printk("comedi: usbdux_pwm_cancel\n");
#endif
if (do_unlink) {
if (do_unlink)
ret = usbduxsub_unlink_PwmURBs(this_usbduxsub);
}
this_usbduxsub->pwm_cmd_running = 0;
return ret;
}
// force unlink
// is called by comedi
/* force unlink - is called by comedi */
static int usbdux_pwm_cancel(comedi_device *dev, comedi_subdevice *s)
{
usbduxsub_t *this_usbduxsub = dev->private;
int res = 0;
// unlink only if it is really running
/* unlink only if it is really running */
res = usbdux_pwm_stop(this_usbduxsub, this_usbduxsub->pwm_cmd_running);
#ifdef NOISY_DUX_DEBUGBUG
printk("comedi %d: sending pwm off command to the usb device.\n",
dev->minor);
#endif
if ((res = send_dux_commands(this_usbduxsub, SENDPWMOFF)) < 0) {
if ((res = send_dux_commands(this_usbduxsub, SENDPWMOFF)) < 0)
return res;
}
return res;
}
@ -1911,19 +1905,21 @@ static void usbduxsub_pwm_irq(struct urb *urb)
/* success */
break;
// after an unlink command, unplug, ... etc
// no unlink needed here. Already shutting down.
case -ECONNRESET:
case -ENOENT:
case -ESHUTDOWN:
case -ECONNABORTED:
if (this_usbduxsub->pwm_cmd_running) {
/*
* after an unlink command, unplug, ... etc
* no unlink needed here. Already shutting down.
*/
if (this_usbduxsub->pwm_cmd_running)
usbdux_pwm_stop(this_usbduxsub, 0);
}
return;
// a real error
default:
/* a real error */
if (this_usbduxsub->pwm_cmd_running) {
printk("comedi_: usbdux_: Non-zero urb status received in pwm intr context: %d\n", urb->status);
usbdux_pwm_stop(this_usbduxsub, 0);
@ -1931,10 +1927,9 @@ static void usbduxsub_pwm_irq(struct urb *urb)
return;
}
// are we actually running?
if (!(this_usbduxsub->pwm_cmd_running)) {
/* are we actually running? */
if (!(this_usbduxsub->pwm_cmd_running))
return;
}
urb->transfer_buffer_length = this_usbduxsub->sizePwmBuf;
urb->dev = this_usbduxsub->usbdev;
@ -1943,24 +1938,24 @@ static void usbduxsub_pwm_irq(struct urb *urb)
if ((ret = USB_SUBMIT_URB(urb)) < 0) {
printk("comedi_: usbdux_: pwm urb resubm failed in int-cont.");
printk("ret=%d", ret);
if (ret == EL2NSYNC) {
if (ret == EL2NSYNC)
printk("--> buggy USB host controller or bug in IRQ handling!\n");
} else {
else
printk("\n");
}
// don't do an unlink here
/* don't do an unlink here */
usbdux_pwm_stop(this_usbduxsub, 0);
}
}
}
int usbduxsub_submit_PwmURBs(usbduxsub_t * usbduxsub)
static int usbduxsub_submit_PwmURBs(usbduxsub_t *usbduxsub)
{
int errFlag;
if (!usbduxsub) {
if (!usbduxsub)
return -EFAULT;
}
#ifdef NOISY_DUX_DEBUGBUG
printk("comedi_: usbdux: submitting pwm-urb\n");
#endif
@ -1987,8 +1982,8 @@ static int usbdux_pwm_period(comedi_device * dev, comedi_subdevice * s,
{
usbduxsub_t *this_usbduxsub = dev->private;
int fx2delay = 255;
if (period < MIN_PWM_PERIOD)
{
if (period < MIN_PWM_PERIOD) {
printk("comedi%d: illegal period setting for pwm.\n", dev->minor);
return -EAGAIN;
} else {
@ -2098,21 +2093,19 @@ static int usbdux_pwm_write(comedi_device * dev, comedi_subdevice * s,
// the sign is set via a special INSN only, this gives us 8 bits for
// normal operation
return usbdux_pwm_pattern(dev,s,
CR_CHAN(insn->chanspec),
data[0],
0); // relay sign 0 by default
// relay sign 0 by default
return usbdux_pwm_pattern(dev, s, CR_CHAN(insn->chanspec),
data[0], 0);
}
static int usbdux_pwm_read(comedi_device *x1, comedi_subdevice *x2,
comedi_insn *x3, lsampl_t *x4)
{
// not needed
/* not needed */
return -EINVAL;
};
// switches on/off PWM
/* switches on/off PWM */
static int usbdux_pwm_config(comedi_device *dev, comedi_subdevice *s,
comedi_insn *insn, lsampl_t *data)
{
@ -2120,15 +2113,16 @@ static int usbdux_pwm_config(comedi_device * dev, comedi_subdevice * s,
switch (data[0]) {
case INSN_CONFIG_ARM:
#ifdef NOISY_DUX_DEBUGBUG
// switch it on
/* switch it on */
printk("comedi%d: pwm_insn_config: pwm on\n",
dev->minor);
#endif
// if not zero the PWM is limited to a certain time which is
// not supported here
if (data[1]!=0) {
/*
* if not zero the PWM is limited to a certain time which is
* not supported here
*/
if (data[1] != 0)
return -EINVAL;
}
return usbdux_pwm_start(dev, s);
case INSN_CONFIG_DISARM:
#ifdef NOISY_DUX_DEBUGBUG
@ -2137,8 +2131,10 @@ static int usbdux_pwm_config(comedi_device * dev, comedi_subdevice * s,
#endif
return usbdux_pwm_cancel(dev, s);
case INSN_CONFIG_GET_PWM_STATUS:
// to check if the USB transmission has failed or in case
// PWM was limited to n cycles to check if it has terminated
/*
* to check if the USB transmission has failed or in case PWM
* was limited to n cycles to check if it has terminated
*/
data[1] = this_usbduxsub->pwm_cmd_running;
return 0;
case INSN_CONFIG_PWM_SET_PERIOD:
@ -2151,20 +2147,24 @@ static int usbdux_pwm_config(comedi_device * dev, comedi_subdevice * s,
data[1] = this_usbduxsub->pwmPeriod;
return 0;
case INSN_CONFIG_PWM_SET_H_BRIDGE:
// value in the first byte and the sign in the second for a relay
/* value in the first byte and the sign in the second for a
relay */
return usbdux_pwm_pattern(dev, s,
CR_CHAN(insn->chanspec), // the channel number
data[1], // actual PWM data
(data[2]!=0)); // just a sign
/* the channel number */
CR_CHAN(insn->chanspec),
/* actual PWM data */
data[1],
/* just a sign */
(data[2] != 0));
case INSN_CONFIG_PWM_GET_H_BRIDGE:
// values are not kept in this driver, nothing to return here
/* values are not kept in this driver, nothing to return here */
return -EINVAL;
}
return -EINVAL;
}
// end of PWM
///////////////////////////////////////////////////////////////////
/* end of PWM */
/*****************************************************************/
static void tidy_up(usbduxsub_t *usbduxsub_tmp)
{
@ -2173,10 +2173,10 @@ static void tidy_up(usbduxsub_t * usbduxsub_tmp)
#ifdef CONFIG_COMEDI_DEBUG
printk("comedi_: usbdux: tiding up\n");
#endif
if (!usbduxsub_tmp) {
if (!usbduxsub_tmp)
return;
}
// shows the usb subsystem that the driver is down
/* shows the usb subsystem that the driver is down */
if (usbduxsub_tmp->interface)
usb_set_intfdata(usbduxsub_tmp->interface, NULL);
@ -2227,34 +2227,22 @@ static void tidy_up(usbduxsub_t * usbduxsub_tmp)
usbduxsub_tmp->pwm_cmd_running = 0;
usbduxsub_unlink_PwmURBs(usbduxsub_tmp);
}
if (usbduxsub_tmp->urbPwm->transfer_buffer) {
kfree(usbduxsub_tmp->urbPwm->transfer_buffer);
usbduxsub_tmp->urbPwm->transfer_buffer = NULL;
}
usb_kill_urb(usbduxsub_tmp->urbPwm);
usb_free_urb(usbduxsub_tmp->urbPwm);
usbduxsub_tmp->urbPwm = NULL;
}
if (usbduxsub_tmp->inBuffer) {
kfree(usbduxsub_tmp->inBuffer);
usbduxsub_tmp->inBuffer = NULL;
}
if (usbduxsub_tmp->insnBuffer) {
kfree(usbduxsub_tmp->insnBuffer);
usbduxsub_tmp->insnBuffer = NULL;
}
if (usbduxsub_tmp->inBuffer) {
kfree(usbduxsub_tmp->inBuffer);
usbduxsub_tmp->inBuffer = NULL;
}
if (usbduxsub_tmp->dac_commands) {
kfree(usbduxsub_tmp->dac_commands);
usbduxsub_tmp->dac_commands = NULL;
}
if (usbduxsub_tmp->dux_commands) {
kfree(usbduxsub_tmp->dux_commands);
usbduxsub_tmp->dux_commands = NULL;
}
usbduxsub_tmp->ai_cmd_running = 0;
usbduxsub_tmp->ao_cmd_running = 0;
usbduxsub_tmp->pwm_cmd_running = 0;
@ -2263,23 +2251,24 @@ static void tidy_up(usbduxsub_t * usbduxsub_tmp)
static unsigned hex2unsigned(char *h)
{
unsigned hi, lo;
if (h[0] > '9') {
if (h[0] > '9')
hi = h[0] - 'A' + 0x0a;
} else {
else
hi = h[0] - '0';
}
if (h[1] > '9') {
if (h[1] > '9')
lo = h[1] - 'A' + 0x0a;
} else {
else
lo = h[1] - '0';
}
return hi * 0x10 + lo;
}
// for FX2
/* for FX2 */
#define FIRMWARE_MAX_LEN 0x2000
// taken from David Brownell's fxload and adjusted for this driver
/* taken from David Brownell's fxload and adjusted for this driver */
static int read_firmware(usbduxsub_t *usbduxsub, void *firmwarePtr, long size)
{
int i = 0;
@ -2335,9 +2324,9 @@ static int read_firmware(usbduxsub_t * usbduxsub, void *firmwarePtr, long size)
/* Read the target offset */
off = (hex2unsigned(buf + 3) * 0x0100) + hex2unsigned(buf + 5);
if ((off + len) > maxAddr) {
if ((off + len) > maxAddr)
maxAddr = off + len;
}
if (maxAddr >= FIRMWARE_MAX_LEN) {
printk("comedi_: usbdux: firmware upload goes beyond FX2 RAM boundaries.");
@ -2349,9 +2338,9 @@ static int read_firmware(usbduxsub_t * usbduxsub, void *firmwarePtr, long size)
type = hex2unsigned(buf + 7);
/* If this is an EOF record, then make it so. */
if (type == 1) {
if (type == 1)
break;
}
if (type != 0) {
printk("comedi_: usbdux: unsupported record type: %u\n",
@ -2466,7 +2455,7 @@ static int usbduxsub_probe(struct usb_interface *uinterf,
up(&start_stop_sem);
return PROBE_ERR_RETURN(-ENOMEM);
}
// setting to alternate setting 3: enabling iso ep and bulk ep.
/* setting to alternate setting 3: enabling iso ep and bulk ep. */
i = usb_set_interface(usbduxsub[index].usbdev,
usbduxsub[index].ifnum, 3);
if (i < 0) {
@ -2475,11 +2464,11 @@ static int usbduxsub_probe(struct usb_interface *uinterf,
up(&start_stop_sem);
return PROBE_ERR_RETURN(-ENODEV);
}
if (usbduxsub[index].high_speed) {
if (usbduxsub[index].high_speed)
usbduxsub[index].numOfInBuffers = NUMOFINBUFFERSHIGH;
} else {
else
usbduxsub[index].numOfInBuffers = NUMOFINBUFFERSFULL;
}
usbduxsub[index].urbIn =
kzalloc(sizeof(struct urb *) * usbduxsub[index].numOfInBuffers,
GFP_KERNEL);
@ -2522,12 +2511,12 @@ static int usbduxsub_probe(struct usb_interface *uinterf,
usbduxsub[index].urbIn[i]->iso_frame_desc[0].length = SIZEINBUF;
}
// out
if (usbduxsub[index].high_speed) {
/* out */
if (usbduxsub[index].high_speed)
usbduxsub[index].numOfOutBuffers = NUMOFOUTBUFFERSHIGH;
} else {
else
usbduxsub[index].numOfOutBuffers = NUMOFOUTBUFFERSFULL;
}
usbduxsub[index].urbOut =
kzalloc(sizeof(struct urb *) * usbduxsub[index].numOfOutBuffers,
GFP_KERNEL);
@ -2637,7 +2626,7 @@ static void usbduxsub_disconnect(struct usb_interface *intf)
#endif
}
// is called when comedi-config is called
/* is called when comedi-config is called */
static int usbdux_attach(comedi_device *dev, comedi_devconfig *it)
{
int ret;
@ -2833,10 +2822,10 @@ static int usbdux_detach(comedi_device * dev)
/* main driver struct */
static comedi_driver driver_usbdux = {
driver_name:"usbdux",
module:THIS_MODULE,
attach:usbdux_attach,
detach:usbdux_detach,
.driver_name = "usbdux",
.module = THIS_MODULE,
.attach = usbdux_attach,
.detach = usbdux_detach,
};
static void init_usb_devices(void)
@ -2854,26 +2843,21 @@ static void init_usb_devices(void)
}
}
// Table with the USB-devices: just now only testing IDs
/* Table with the USB-devices: just now only testing IDs */
static struct usb_device_id usbduxsub_table[] = {
{USB_DEVICE(0x13d8, 0x0001),
},
{USB_DEVICE(0x13d8, 0x0002)
},
{USB_DEVICE(0x13d8, 0x0001) },
{USB_DEVICE(0x13d8, 0x0002) },
{} /* Terminating entry */
};
MODULE_DEVICE_TABLE(usb, usbduxsub_table);
// The usbduxsub-driver
/* The usbduxsub-driver */
static struct usb_driver usbduxsub_driver = {
#ifdef COMEDI_HAVE_USB_DRIVER_OWNER
owner:THIS_MODULE,
#endif
name:BOARDNAME,
probe:usbduxsub_probe,
disconnect:usbduxsub_disconnect,
id_table:usbduxsub_table,
.name = BOARDNAME,
.probe = usbduxsub_probe,
.disconnect = usbduxsub_disconnect,
.id_table = usbduxsub_table,
};
// Can't use the nice macro as I have also to initialise the USB