static int vmk80xx_read_packet(struct vmk80xx_usb *dev)
{
+ const struct vmk80xx_board *boardinfo = dev->board;
struct urb *urb;
int retval;
&dev->flags)))
return -ERESTART;
- if (dev->board->model == VMK8061_MODEL) {
+ if (boardinfo->model == VMK8061_MODEL) {
vmk80xx_do_bulk_msg(dev);
return 0;
static int vmk80xx_write_packet(struct vmk80xx_usb *dev, int cmd)
{
+ const struct vmk80xx_board *boardinfo = dev->board;
struct urb *urb;
int retval;
&dev->flags)))
return -ERESTART;
- if (dev->board->model == VMK8061_MODEL) {
+ if (boardinfo->model == VMK8061_MODEL) {
dev->usb_tx_buf[0] = cmd;
vmk80xx_do_bulk_msg(dev);
struct comedi_subdevice *s,
struct comedi_insn *insn, unsigned int *data)
{
+ const struct vmk80xx_board *boardinfo = comedi_board(cdev);
struct vmk80xx_usb *dev = cdev->private;
int chan;
int reg[2];
down(&dev->limit_sem);
chan = CR_CHAN(insn->chanspec);
- switch (dev->board->model) {
+ switch (boardinfo->model) {
case VMK8055_MODEL:
if (!chan)
reg[0] = VMK8055_AI1_REG;
if (vmk80xx_read_packet(dev))
break;
- if (dev->board->model == VMK8055_MODEL) {
+ if (boardinfo->model == VMK8055_MODEL) {
data[n] = dev->usb_rx_buf[reg[0]];
continue;
}
struct comedi_subdevice *s,
struct comedi_insn *insn, unsigned int *data)
{
+ const struct vmk80xx_board *boardinfo = comedi_board(cdev);
struct vmk80xx_usb *dev = cdev->private;
int chan;
int cmd;
down(&dev->limit_sem);
chan = CR_CHAN(insn->chanspec);
- switch (dev->board->model) {
+ switch (boardinfo->model) {
case VMK8055_MODEL:
cmd = VMK8055_CMD_WRT_AD;
if (!chan)
struct comedi_subdevice *s,
struct comedi_insn *insn, unsigned int *data)
{
+ const struct vmk80xx_board *boardinfo = comedi_board(cdev);
struct vmk80xx_usb *dev = cdev->private;
unsigned char *rx_buf;
int reg;
rx_buf = dev->usb_rx_buf;
- if (dev->board->model == VMK8061_MODEL) {
+ if (boardinfo->model == VMK8061_MODEL) {
reg = VMK8061_DI_REG;
dev->usb_tx_buf[0] = VMK8061_CMD_RD_DI;
} else {
retval = vmk80xx_read_packet(dev);
if (!retval) {
- if (dev->board->model == VMK8055_MODEL)
+ if (boardinfo->model == VMK8055_MODEL)
data[1] = (((rx_buf[reg] >> 4) & 0x03) |
((rx_buf[reg] << 2) & 0x04) |
((rx_buf[reg] >> 3) & 0x18));
struct comedi_subdevice *s,
struct comedi_insn *insn, unsigned int *data)
{
+ const struct vmk80xx_board *boardinfo = comedi_board(cdev);
struct vmk80xx_usb *dev = cdev->private;
int chan;
unsigned char *rx_buf;
rx_buf = dev->usb_rx_buf;
- if (dev->board->model == VMK8061_MODEL) {
+ if (boardinfo->model == VMK8061_MODEL) {
reg = VMK8061_DI_REG;
dev->usb_tx_buf[0] = VMK8061_CMD_RD_DI;
} else {
if (vmk80xx_read_packet(dev))
break;
- if (dev->board->model == VMK8055_MODEL)
+ if (boardinfo->model == VMK8055_MODEL)
inp = (((rx_buf[reg] >> 4) & 0x03) |
((rx_buf[reg] << 2) & 0x04) |
((rx_buf[reg] >> 3) & 0x18));
struct comedi_subdevice *s,
struct comedi_insn *insn, unsigned int *data)
{
+ const struct vmk80xx_board *boardinfo = comedi_board(cdev);
struct vmk80xx_usb *dev = cdev->private;
int chan;
unsigned char *tx_buf;
tx_buf = dev->usb_tx_buf;
for (n = 0; n < insn->n; n++) {
- if (dev->board->model == VMK8055_MODEL) {
+ if (boardinfo->model == VMK8055_MODEL) {
reg = VMK8055_DO_REG;
cmd = VMK8055_CMD_WRT_AD;
if (data[n] == 1)
struct comedi_subdevice *s,
struct comedi_insn *insn, unsigned int *data)
{
+ const struct vmk80xx_board *boardinfo = comedi_board(cdev);
struct vmk80xx_usb *dev = cdev->private;
unsigned char *rx_buf, *tx_buf;
int dir, reg, cmd;
if (data[0])
dir |= DIR_OUT;
- if (dev->board->model == VMK8061_MODEL)
+ if (boardinfo->model == VMK8061_MODEL)
dir |= DIR_IN;
retval = rudimentary_check(dev, dir);
tx_buf = dev->usb_tx_buf;
if (data[0]) {
- if (dev->board->model == VMK8055_MODEL) {
+ if (boardinfo->model == VMK8055_MODEL) {
reg = VMK8055_DO_REG;
cmd = VMK8055_CMD_WRT_AD;
} else { /* VMK8061_MODEL */
goto out;
}
- if (dev->board->model == VMK8061_MODEL) {
+ if (boardinfo->model == VMK8061_MODEL) {
reg = VMK8061_DO_REG;
tx_buf[0] = VMK8061_CMD_RD_DO;
struct comedi_subdevice *s,
struct comedi_insn *insn, unsigned int *data)
{
+ const struct vmk80xx_board *boardinfo = comedi_board(cdev);
struct vmk80xx_usb *dev = cdev->private;
int chan;
int reg[2];
down(&dev->limit_sem);
chan = CR_CHAN(insn->chanspec);
- switch (dev->board->model) {
+ switch (boardinfo->model) {
case VMK8055_MODEL:
if (!chan)
reg[0] = VMK8055_CNT1_REG;
if (vmk80xx_read_packet(dev))
break;
- if (dev->board->model == VMK8055_MODEL)
+ if (boardinfo->model == VMK8055_MODEL)
data[n] = dev->usb_rx_buf[reg[0]];
else /* VMK8061_MODEL */
data[n] = dev->usb_rx_buf[reg[0] * (chan + 1) + 1]
struct comedi_subdevice *s,
struct comedi_insn *insn, unsigned int *data)
{
+ const struct vmk80xx_board *boardinfo = comedi_board(cdev);
struct vmk80xx_usb *dev = cdev->private;
unsigned int insn_cmd;
int chan;
chan = CR_CHAN(insn->chanspec);
- if (dev->board->model == VMK8055_MODEL) {
+ if (boardinfo->model == VMK8055_MODEL) {
if (!chan) {
cmd = VMK8055_CMD_RST_CNT1;
reg = VMK8055_CNT1_REG;
static int vmk80xx_attach_common(struct comedi_device *cdev,
struct vmk80xx_usb *dev)
{
+ const struct vmk80xx_board *boardinfo;
int n_subd;
struct comedi_subdevice *s;
int ret;
down(&dev->limit_sem);
- cdev->board_name = dev->board->name;
+
+ boardinfo = dev->board;
+ cdev->board_ptr = boardinfo;
+ cdev->board_name = boardinfo->name;
cdev->private = dev;
- if (dev->board->model == VMK8055_MODEL)
+
+ if (boardinfo->model == VMK8055_MODEL)
n_subd = 5;
else
n_subd = 6;
up(&dev->limit_sem);
return ret;
}
+
/* Analog input subdevice */
s = &cdev->subdevices[VMK80XX_SUBD_AI];
s->type = COMEDI_SUBD_AI;
s->subdev_flags = SDF_READABLE | SDF_GROUND;
- s->n_chan = dev->board->ai_chans;
- s->maxdata = (1 << dev->board->ai_bits) - 1;
- s->range_table = dev->board->range;
+ s->n_chan = boardinfo->ai_chans;
+ s->maxdata = (1 << boardinfo->ai_bits) - 1;
+ s->range_table = boardinfo->range;
s->insn_read = vmk80xx_ai_rinsn;
+
/* Analog output subdevice */
s = &cdev->subdevices[VMK80XX_SUBD_AO];
s->type = COMEDI_SUBD_AO;
s->subdev_flags = SDF_WRITEABLE | SDF_GROUND;
- s->n_chan = dev->board->ao_chans;
- s->maxdata = (1 << dev->board->ao_bits) - 1;
- s->range_table = dev->board->range;
+ s->n_chan = boardinfo->ao_chans;
+ s->maxdata = (1 << boardinfo->ao_bits) - 1;
+ s->range_table = boardinfo->range;
s->insn_write = vmk80xx_ao_winsn;
- if (dev->board->model == VMK8061_MODEL) {
+ if (boardinfo->model == VMK8061_MODEL) {
s->subdev_flags |= SDF_READABLE;
s->insn_read = vmk80xx_ao_rinsn;
}
+
/* Digital input subdevice */
s = &cdev->subdevices[VMK80XX_SUBD_DI];
s->type = COMEDI_SUBD_DI;
s->subdev_flags = SDF_READABLE | SDF_GROUND;
- s->n_chan = dev->board->di_chans;
+ s->n_chan = boardinfo->di_chans;
s->maxdata = 1;
s->insn_read = vmk80xx_di_rinsn;
s->insn_bits = vmk80xx_di_bits;
+
/* Digital output subdevice */
s = &cdev->subdevices[VMK80XX_SUBD_DO];
s->type = COMEDI_SUBD_DO;
s->subdev_flags = SDF_WRITEABLE | SDF_GROUND;
- s->n_chan = dev->board->do_chans;
+ s->n_chan = boardinfo->do_chans;
s->maxdata = 1;
s->insn_write = vmk80xx_do_winsn;
s->insn_bits = vmk80xx_do_bits;
- if (dev->board->model == VMK8061_MODEL) {
+ if (boardinfo->model == VMK8061_MODEL) {
s->subdev_flags |= SDF_READABLE;
s->insn_read = vmk80xx_do_rinsn;
}
+
/* Counter subdevice */
s = &cdev->subdevices[VMK80XX_SUBD_CNT];
s->type = COMEDI_SUBD_COUNTER;
s->subdev_flags = SDF_READABLE;
- s->n_chan = dev->board->cnt_chans;
+ s->n_chan = boardinfo->cnt_chans;
s->insn_read = vmk80xx_cnt_rinsn;
s->insn_config = vmk80xx_cnt_cinsn;
- if (dev->board->model == VMK8055_MODEL) {
+ if (boardinfo->model == VMK8055_MODEL) {
s->subdev_flags |= SDF_WRITEABLE;
- s->maxdata = (1 << dev->board->cnt_bits) - 1;
+ s->maxdata = (1 << boardinfo->cnt_bits) - 1;
s->insn_write = vmk80xx_cnt_winsn;
}
+
/* PWM subdevice */
- if (dev->board->model == VMK8061_MODEL) {
+ if (boardinfo->model == VMK8061_MODEL) {
s = &cdev->subdevices[VMK80XX_SUBD_PWM];
s->type = COMEDI_SUBD_PWM;
s->subdev_flags = SDF_READABLE | SDF_WRITEABLE;
- s->n_chan = dev->board->pwm_chans;
- s->maxdata = (1 << dev->board->pwm_bits) - 1;
+ s->n_chan = boardinfo->pwm_chans;
+ s->maxdata = (1 << boardinfo->pwm_bits) - 1;
s->insn_read = vmk80xx_pwm_rinsn;
s->insn_write = vmk80xx_pwm_winsn;
}
+
dev->attached = 1;
dev_info(cdev->class_dev, "vmk80xx: board #%d [%s] attached\n",
- dev->count, dev->board->name);
+ dev->count, boardinfo->name);
+
up(&dev->limit_sem);
+
return 0;
}
static int vmk80xx_usb_probe(struct usb_interface *intf,
const struct usb_device_id *id)
{
+ const struct vmk80xx_board *boardinfo;
int i;
struct vmk80xx_usb *dev;
struct usb_host_interface *iface_desc;
usb_set_intfdata(intf, dev);
- dev->board = &vmk80xx_boardinfo[id->driver_info];
+ boardinfo = &vmk80xx_boardinfo[id->driver_info];
+ dev->board = boardinfo;
- if (dev->board->model == VMK8061_MODEL) {
+ if (boardinfo->model == VMK8061_MODEL) {
vmk80xx_read_eeprom(dev, IC3_VERSION);
dev_info(&intf->dev, "%s\n", dev->fw.ic3_vers);
}
}
- if (dev->board->model == VMK8055_MODEL)
+ if (boardinfo->model == VMK8055_MODEL)
vmk80xx_reset_device(dev);
dev->probed = 1;
dev_info(&intf->dev, "board #%d [%s] now attached\n",
- dev->count, dev->board->name);
+ dev->count, boardinfo->name);
mutex_unlock(&glb_mutex);