Commit 72db740f authored by H Hartley Sweeten's avatar H Hartley Sweeten Committed by Greg Kroah-Hartman

staging: comedi: usbdux: tidy up usbdux_attach_common()

Rename the local variable used for the device private data.

Move the setting of the device private data 'comedidev' to the
(*auto_attach) where the other back pointers are set.

Tidy up the subdevice init by removing the unnecessary comments
and adding some whitespace.

Remove the unnecessary dev_info() after a sucessful attach.
Signed-off-by: default avatarH Hartley Sweeten <hsweeten@visionengravers.com>
Cc: Ian Abbott <abbotti@mev.co.uk>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent ee9c2dd3
...@@ -1952,123 +1952,82 @@ static int usbdux_pwm_config(struct comedi_device *dev, ...@@ -1952,123 +1952,82 @@ static int usbdux_pwm_config(struct comedi_device *dev,
static int usbdux_attach_common(struct comedi_device *dev) static int usbdux_attach_common(struct comedi_device *dev)
{ {
struct usbdux_private *udev = dev->private; struct usbdux_private *devpriv = dev->private;
struct comedi_subdevice *s;
int ret; int ret;
struct comedi_subdevice *s = NULL;
int n_subdevs;
down(&udev->sem);
/* pointer back to the corresponding comedi device */
udev->comedidev = dev;
/* set number of subdevices */ down(&devpriv->sem);
if (udev->high_speed) {
/* with pwm */
n_subdevs = 5;
} else {
/* without pwm */
n_subdevs = 4;
}
ret = comedi_alloc_subdevices(dev, n_subdevs); ret = comedi_alloc_subdevices(dev, (devpriv->high_speed) ? 5 : 4);
if (ret) { if (ret) {
up(&udev->sem); up(&devpriv->sem);
return ret; return ret;
} }
/* the first subdevice is the A/D converter */ /* Analog Input subdevice */
s = &dev->subdevices[SUBDEV_AD]; s = &dev->subdevices[SUBDEV_AD];
/* the URBs get the comedi subdevice */
/* which is responsible for reading */
/* this is the subdevice which reads data */
dev->read_subdev = s; dev->read_subdev = s;
/* the subdevice receives as private structure the */ s->type = COMEDI_SUBD_AI;
/* usb-structure */ s->subdev_flags = SDF_READABLE | SDF_GROUND | SDF_CMD_READ;
s->private = NULL; s->n_chan = 8;
/* analog input */ s->maxdata = 0x0fff;
s->type = COMEDI_SUBD_AI; s->len_chanlist = 8;
/* readable and ref is to ground */ s->range_table = &range_usbdux_ai_range;
s->subdev_flags = SDF_READABLE | SDF_GROUND | SDF_CMD_READ; s->insn_read = usbdux_ai_insn_read;
/* 8 channels */ s->do_cmdtest = usbdux_ai_cmdtest;
s->n_chan = 8; s->do_cmd = usbdux_ai_cmd;
/* length of the channellist */ s->cancel = usbdux_ai_cancel;
s->len_chanlist = 8;
/* callback functions */ /* Analog Output subdevice */
s->insn_read = usbdux_ai_insn_read;
s->do_cmdtest = usbdux_ai_cmdtest;
s->do_cmd = usbdux_ai_cmd;
s->cancel = usbdux_ai_cancel;
/* max value from the A/D converter (12bit) */
s->maxdata = 0xfff;
/* range table to convert to physical units */
s->range_table = (&range_usbdux_ai_range);
/* analog out */
s = &dev->subdevices[SUBDEV_DA]; s = &dev->subdevices[SUBDEV_DA];
/* analog out */
s->type = COMEDI_SUBD_AO;
/* backward pointer */
dev->write_subdev = s; dev->write_subdev = s;
/* the subdevice receives as private structure the */ s->type = COMEDI_SUBD_AO;
/* usb-structure */ s->subdev_flags = SDF_WRITABLE | SDF_GROUND | SDF_CMD_WRITE;
s->private = NULL; s->n_chan = 4;
/* are writable */ s->maxdata = 0x0fff;
s->subdev_flags = SDF_WRITABLE | SDF_GROUND | SDF_CMD_WRITE; s->len_chanlist = 4;
/* 4 channels */ s->range_table = &range_usbdux_ao_range;
s->n_chan = 4; s->do_cmdtest = usbdux_ao_cmdtest;
/* length of the channellist */ s->do_cmd = usbdux_ao_cmd;
s->len_chanlist = 4; s->cancel = usbdux_ao_cancel;
/* 12 bit resolution */ s->insn_read = usbdux_ao_insn_read;
s->maxdata = 0x0fff; s->insn_write = usbdux_ao_insn_write;
/* bipolar range */
s->range_table = (&range_usbdux_ao_range); /* Digital I/O subdevice */
/* callback */
s->do_cmdtest = usbdux_ao_cmdtest;
s->do_cmd = usbdux_ao_cmd;
s->cancel = usbdux_ao_cancel;
s->insn_read = usbdux_ao_insn_read;
s->insn_write = usbdux_ao_insn_write;
/* digital I/O */
s = &dev->subdevices[SUBDEV_DIO]; s = &dev->subdevices[SUBDEV_DIO];
s->type = COMEDI_SUBD_DIO; s->type = COMEDI_SUBD_DIO;
s->subdev_flags = SDF_READABLE | SDF_WRITABLE; s->subdev_flags = SDF_READABLE | SDF_WRITABLE;
s->n_chan = 8; s->n_chan = 8;
s->maxdata = 1; s->maxdata = 1;
s->range_table = (&range_digital); s->range_table = &range_digital;
s->insn_bits = usbdux_dio_insn_bits; s->insn_bits = usbdux_dio_insn_bits;
s->insn_config = usbdux_dio_insn_config; s->insn_config = usbdux_dio_insn_config;
/* we don't use it */
s->private = NULL; /* Counter subdevice */
/* counter */
s = &dev->subdevices[SUBDEV_COUNTER]; s = &dev->subdevices[SUBDEV_COUNTER];
s->type = COMEDI_SUBD_COUNTER; s->type = COMEDI_SUBD_COUNTER;
s->subdev_flags = SDF_WRITABLE | SDF_READABLE; s->subdev_flags = SDF_WRITABLE | SDF_READABLE;
s->n_chan = 4; s->n_chan = 4;
s->maxdata = 0xFFFF; s->maxdata = 0xffff;
s->insn_read = usbdux_counter_read; s->insn_read = usbdux_counter_read;
s->insn_write = usbdux_counter_write; s->insn_write = usbdux_counter_write;
s->insn_config = usbdux_counter_config; s->insn_config = usbdux_counter_config;
if (udev->high_speed) { if (devpriv->high_speed) {
/* timer / pwm */ /* PWM subdevice */
s = &dev->subdevices[SUBDEV_PWM]; s = &dev->subdevices[SUBDEV_PWM];
s->type = COMEDI_SUBD_PWM; s->type = COMEDI_SUBD_PWM;
s->subdev_flags = SDF_WRITABLE | SDF_PWM_HBRIDGE; s->subdev_flags = SDF_WRITABLE | SDF_PWM_HBRIDGE;
s->n_chan = 8; s->n_chan = 8;
/* this defines the max duty cycle resolution */ s->maxdata = devpriv->size_pwm_buf;
s->maxdata = udev->size_pwm_buf; s->insn_write = usbdux_pwm_write;
s->insn_write = usbdux_pwm_write; s->insn_read = usbdux_pwm_read;
s->insn_read = usbdux_pwm_read; s->insn_config = usbdux_pwm_config;
s->insn_config = usbdux_pwm_config;
usbdux_pwm_period(dev, s, PWM_DEFAULT_PERIOD); usbdux_pwm_period(dev, s, PWM_DEFAULT_PERIOD);
} }
up(&udev->sem); up(&devpriv->sem);
dev_info(&udev->interface->dev, "comedi%d: attached to usbdux.\n",
dev->minor);
return 0; return 0;
} }
...@@ -2238,6 +2197,7 @@ static int usbdux_auto_attach(struct comedi_device *dev, ...@@ -2238,6 +2197,7 @@ static int usbdux_auto_attach(struct comedi_device *dev,
sema_init(&devpriv->sem, 1); sema_init(&devpriv->sem, 1);
devpriv->comedidev = dev;
devpriv->usbdev = usb; devpriv->usbdev = usb;
devpriv->interface = intf; devpriv->interface = intf;
devpriv->ifnum = intf->altsetting->desc.bInterfaceNumber; devpriv->ifnum = intf->altsetting->desc.bInterfaceNumber;
......
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