Commit 52d895d3 authored by H Hartley Sweeten's avatar H Hartley Sweeten Committed by Greg Kroah-Hartman

staging: comedi: vmk80xx: remove need for boardinfo in private_data

The only information in the boardinfo that is used outside of the
attach of the driver is the 'model' of the device.

Remove the 'board' pointer from the private data and replace it with
the 'model' enum and just copy that information over during the 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 57cf09ae
...@@ -202,7 +202,6 @@ struct vmk80xx_private { ...@@ -202,7 +202,6 @@ struct vmk80xx_private {
struct usb_endpoint_descriptor *ep_tx; struct usb_endpoint_descriptor *ep_tx;
struct usb_anchor rx_anchor; struct usb_anchor rx_anchor;
struct usb_anchor tx_anchor; struct usb_anchor tx_anchor;
const struct vmk80xx_board *board;
struct firmware_version fw; struct firmware_version fw;
struct semaphore limit_sem; struct semaphore limit_sem;
wait_queue_head_t read_wait; wait_queue_head_t read_wait;
...@@ -210,6 +209,7 @@ struct vmk80xx_private { ...@@ -210,6 +209,7 @@ struct vmk80xx_private {
unsigned char *usb_rx_buf; unsigned char *usb_rx_buf;
unsigned char *usb_tx_buf; unsigned char *usb_tx_buf;
unsigned long flags; unsigned long flags;
enum vmk80xx_model model;
}; };
static void vmk80xx_tx_callback(struct urb *urb) static void vmk80xx_tx_callback(struct urb *urb)
...@@ -423,7 +423,6 @@ static void vmk80xx_do_bulk_msg(struct vmk80xx_private *devpriv) ...@@ -423,7 +423,6 @@ static void vmk80xx_do_bulk_msg(struct vmk80xx_private *devpriv)
static int vmk80xx_read_packet(struct vmk80xx_private *devpriv) static int vmk80xx_read_packet(struct vmk80xx_private *devpriv)
{ {
const struct vmk80xx_board *boardinfo = devpriv->board;
unsigned long *flags = &devpriv->flags; unsigned long *flags = &devpriv->flags;
struct urb *urb; struct urb *urb;
int retval; int retval;
...@@ -437,7 +436,7 @@ static int vmk80xx_read_packet(struct vmk80xx_private *devpriv) ...@@ -437,7 +436,7 @@ static int vmk80xx_read_packet(struct vmk80xx_private *devpriv)
!test_bit(TRANS_IN_BUSY, flags))) !test_bit(TRANS_IN_BUSY, flags)))
return -ERESTART; return -ERESTART;
if (boardinfo->model == VMK8061_MODEL) { if (devpriv->model == VMK8061_MODEL) {
vmk80xx_do_bulk_msg(devpriv); vmk80xx_do_bulk_msg(devpriv);
return 0; return 0;
...@@ -470,7 +469,6 @@ static int vmk80xx_read_packet(struct vmk80xx_private *devpriv) ...@@ -470,7 +469,6 @@ static int vmk80xx_read_packet(struct vmk80xx_private *devpriv)
static int vmk80xx_write_packet(struct vmk80xx_private *devpriv, int cmd) static int vmk80xx_write_packet(struct vmk80xx_private *devpriv, int cmd)
{ {
const struct vmk80xx_board *boardinfo = devpriv->board;
unsigned long *flags = &devpriv->flags; unsigned long *flags = &devpriv->flags;
struct urb *urb; struct urb *urb;
int retval; int retval;
...@@ -483,7 +481,7 @@ static int vmk80xx_write_packet(struct vmk80xx_private *devpriv, int cmd) ...@@ -483,7 +481,7 @@ static int vmk80xx_write_packet(struct vmk80xx_private *devpriv, int cmd)
!test_bit(TRANS_OUT_BUSY, flags))) !test_bit(TRANS_OUT_BUSY, flags)))
return -ERESTART; return -ERESTART;
if (boardinfo->model == VMK8061_MODEL) { if (devpriv->model == VMK8061_MODEL) {
devpriv->usb_tx_buf[0] = cmd; devpriv->usb_tx_buf[0] = cmd;
vmk80xx_do_bulk_msg(devpriv); vmk80xx_do_bulk_msg(devpriv);
...@@ -539,7 +537,6 @@ static int vmk80xx_ai_rinsn(struct comedi_device *dev, ...@@ -539,7 +537,6 @@ static int vmk80xx_ai_rinsn(struct comedi_device *dev,
struct comedi_subdevice *s, struct comedi_subdevice *s,
struct comedi_insn *insn, unsigned int *data) struct comedi_insn *insn, unsigned int *data)
{ {
const struct vmk80xx_board *boardinfo = comedi_board(dev);
struct vmk80xx_private *devpriv = dev->private; struct vmk80xx_private *devpriv = dev->private;
int chan; int chan;
int reg[2]; int reg[2];
...@@ -552,7 +549,7 @@ static int vmk80xx_ai_rinsn(struct comedi_device *dev, ...@@ -552,7 +549,7 @@ static int vmk80xx_ai_rinsn(struct comedi_device *dev,
down(&devpriv->limit_sem); down(&devpriv->limit_sem);
chan = CR_CHAN(insn->chanspec); chan = CR_CHAN(insn->chanspec);
switch (boardinfo->model) { switch (devpriv->model) {
case VMK8055_MODEL: case VMK8055_MODEL:
if (!chan) if (!chan)
reg[0] = VMK8055_AI1_REG; reg[0] = VMK8055_AI1_REG;
...@@ -572,7 +569,7 @@ static int vmk80xx_ai_rinsn(struct comedi_device *dev, ...@@ -572,7 +569,7 @@ static int vmk80xx_ai_rinsn(struct comedi_device *dev,
if (vmk80xx_read_packet(devpriv)) if (vmk80xx_read_packet(devpriv))
break; break;
if (boardinfo->model == VMK8055_MODEL) { if (devpriv->model == VMK8055_MODEL) {
data[n] = devpriv->usb_rx_buf[reg[0]]; data[n] = devpriv->usb_rx_buf[reg[0]];
continue; continue;
} }
...@@ -591,7 +588,6 @@ static int vmk80xx_ao_winsn(struct comedi_device *dev, ...@@ -591,7 +588,6 @@ static int vmk80xx_ao_winsn(struct comedi_device *dev,
struct comedi_subdevice *s, struct comedi_subdevice *s,
struct comedi_insn *insn, unsigned int *data) struct comedi_insn *insn, unsigned int *data)
{ {
const struct vmk80xx_board *boardinfo = comedi_board(dev);
struct vmk80xx_private *devpriv = dev->private; struct vmk80xx_private *devpriv = dev->private;
int chan; int chan;
int cmd; int cmd;
...@@ -605,7 +601,7 @@ static int vmk80xx_ao_winsn(struct comedi_device *dev, ...@@ -605,7 +601,7 @@ static int vmk80xx_ao_winsn(struct comedi_device *dev,
down(&devpriv->limit_sem); down(&devpriv->limit_sem);
chan = CR_CHAN(insn->chanspec); chan = CR_CHAN(insn->chanspec);
switch (boardinfo->model) { switch (devpriv->model) {
case VMK8055_MODEL: case VMK8055_MODEL:
cmd = VMK8055_CMD_WRT_AD; cmd = VMK8055_CMD_WRT_AD;
if (!chan) if (!chan)
...@@ -668,7 +664,6 @@ static int vmk80xx_di_bits(struct comedi_device *dev, ...@@ -668,7 +664,6 @@ static int vmk80xx_di_bits(struct comedi_device *dev,
struct comedi_subdevice *s, struct comedi_subdevice *s,
struct comedi_insn *insn, unsigned int *data) struct comedi_insn *insn, unsigned int *data)
{ {
const struct vmk80xx_board *boardinfo = comedi_board(dev);
struct vmk80xx_private *devpriv = dev->private; struct vmk80xx_private *devpriv = dev->private;
unsigned char *rx_buf; unsigned char *rx_buf;
int reg; int reg;
...@@ -682,7 +677,7 @@ static int vmk80xx_di_bits(struct comedi_device *dev, ...@@ -682,7 +677,7 @@ static int vmk80xx_di_bits(struct comedi_device *dev,
rx_buf = devpriv->usb_rx_buf; rx_buf = devpriv->usb_rx_buf;
if (boardinfo->model == VMK8061_MODEL) { if (devpriv->model == VMK8061_MODEL) {
reg = VMK8061_DI_REG; reg = VMK8061_DI_REG;
devpriv->usb_tx_buf[0] = VMK8061_CMD_RD_DI; devpriv->usb_tx_buf[0] = VMK8061_CMD_RD_DI;
} else { } else {
...@@ -692,7 +687,7 @@ static int vmk80xx_di_bits(struct comedi_device *dev, ...@@ -692,7 +687,7 @@ static int vmk80xx_di_bits(struct comedi_device *dev,
retval = vmk80xx_read_packet(devpriv); retval = vmk80xx_read_packet(devpriv);
if (!retval) { if (!retval) {
if (boardinfo->model == VMK8055_MODEL) if (devpriv->model == VMK8055_MODEL)
data[1] = (((rx_buf[reg] >> 4) & 0x03) | data[1] = (((rx_buf[reg] >> 4) & 0x03) |
((rx_buf[reg] << 2) & 0x04) | ((rx_buf[reg] << 2) & 0x04) |
((rx_buf[reg] >> 3) & 0x18)); ((rx_buf[reg] >> 3) & 0x18));
...@@ -711,7 +706,6 @@ static int vmk80xx_di_rinsn(struct comedi_device *dev, ...@@ -711,7 +706,6 @@ static int vmk80xx_di_rinsn(struct comedi_device *dev,
struct comedi_subdevice *s, struct comedi_subdevice *s,
struct comedi_insn *insn, unsigned int *data) struct comedi_insn *insn, unsigned int *data)
{ {
const struct vmk80xx_board *boardinfo = comedi_board(dev);
struct vmk80xx_private *devpriv = dev->private; struct vmk80xx_private *devpriv = dev->private;
int chan; int chan;
unsigned char *rx_buf; unsigned char *rx_buf;
...@@ -728,7 +722,7 @@ static int vmk80xx_di_rinsn(struct comedi_device *dev, ...@@ -728,7 +722,7 @@ static int vmk80xx_di_rinsn(struct comedi_device *dev,
rx_buf = devpriv->usb_rx_buf; rx_buf = devpriv->usb_rx_buf;
if (boardinfo->model == VMK8061_MODEL) { if (devpriv->model == VMK8061_MODEL) {
reg = VMK8061_DI_REG; reg = VMK8061_DI_REG;
devpriv->usb_tx_buf[0] = VMK8061_CMD_RD_DI; devpriv->usb_tx_buf[0] = VMK8061_CMD_RD_DI;
} else { } else {
...@@ -738,7 +732,7 @@ static int vmk80xx_di_rinsn(struct comedi_device *dev, ...@@ -738,7 +732,7 @@ static int vmk80xx_di_rinsn(struct comedi_device *dev,
if (vmk80xx_read_packet(devpriv)) if (vmk80xx_read_packet(devpriv))
break; break;
if (boardinfo->model == VMK8055_MODEL) if (devpriv->model == VMK8055_MODEL)
inp = (((rx_buf[reg] >> 4) & 0x03) | inp = (((rx_buf[reg] >> 4) & 0x03) |
((rx_buf[reg] << 2) & 0x04) | ((rx_buf[reg] << 2) & 0x04) |
((rx_buf[reg] >> 3) & 0x18)); ((rx_buf[reg] >> 3) & 0x18));
...@@ -757,7 +751,6 @@ static int vmk80xx_do_winsn(struct comedi_device *dev, ...@@ -757,7 +751,6 @@ static int vmk80xx_do_winsn(struct comedi_device *dev,
struct comedi_subdevice *s, struct comedi_subdevice *s,
struct comedi_insn *insn, unsigned int *data) struct comedi_insn *insn, unsigned int *data)
{ {
const struct vmk80xx_board *boardinfo = comedi_board(dev);
struct vmk80xx_private *devpriv = dev->private; struct vmk80xx_private *devpriv = dev->private;
int chan; int chan;
unsigned char *tx_buf; unsigned char *tx_buf;
...@@ -775,7 +768,7 @@ static int vmk80xx_do_winsn(struct comedi_device *dev, ...@@ -775,7 +768,7 @@ static int vmk80xx_do_winsn(struct comedi_device *dev,
tx_buf = devpriv->usb_tx_buf; tx_buf = devpriv->usb_tx_buf;
for (n = 0; n < insn->n; n++) { for (n = 0; n < insn->n; n++) {
if (boardinfo->model == VMK8055_MODEL) { if (devpriv->model == VMK8055_MODEL) {
reg = VMK8055_DO_REG; reg = VMK8055_DO_REG;
cmd = VMK8055_CMD_WRT_AD; cmd = VMK8055_CMD_WRT_AD;
if (data[n] == 1) if (data[n] == 1)
...@@ -838,7 +831,6 @@ static int vmk80xx_do_bits(struct comedi_device *dev, ...@@ -838,7 +831,6 @@ static int vmk80xx_do_bits(struct comedi_device *dev,
struct comedi_subdevice *s, struct comedi_subdevice *s,
struct comedi_insn *insn, unsigned int *data) struct comedi_insn *insn, unsigned int *data)
{ {
const struct vmk80xx_board *boardinfo = comedi_board(dev);
struct vmk80xx_private *devpriv = dev->private; struct vmk80xx_private *devpriv = dev->private;
unsigned char *rx_buf, *tx_buf; unsigned char *rx_buf, *tx_buf;
int dir, reg, cmd; int dir, reg, cmd;
...@@ -849,7 +841,7 @@ static int vmk80xx_do_bits(struct comedi_device *dev, ...@@ -849,7 +841,7 @@ static int vmk80xx_do_bits(struct comedi_device *dev,
if (data[0]) if (data[0])
dir |= DIR_OUT; dir |= DIR_OUT;
if (boardinfo->model == VMK8061_MODEL) if (devpriv->model == VMK8061_MODEL)
dir |= DIR_IN; dir |= DIR_IN;
retval = rudimentary_check(devpriv, dir); retval = rudimentary_check(devpriv, dir);
...@@ -862,7 +854,7 @@ static int vmk80xx_do_bits(struct comedi_device *dev, ...@@ -862,7 +854,7 @@ static int vmk80xx_do_bits(struct comedi_device *dev,
tx_buf = devpriv->usb_tx_buf; tx_buf = devpriv->usb_tx_buf;
if (data[0]) { if (data[0]) {
if (boardinfo->model == VMK8055_MODEL) { if (devpriv->model == VMK8055_MODEL) {
reg = VMK8055_DO_REG; reg = VMK8055_DO_REG;
cmd = VMK8055_CMD_WRT_AD; cmd = VMK8055_CMD_WRT_AD;
} else { /* VMK8061_MODEL */ } else { /* VMK8061_MODEL */
...@@ -879,7 +871,7 @@ static int vmk80xx_do_bits(struct comedi_device *dev, ...@@ -879,7 +871,7 @@ static int vmk80xx_do_bits(struct comedi_device *dev,
goto out; goto out;
} }
if (boardinfo->model == VMK8061_MODEL) { if (devpriv->model == VMK8061_MODEL) {
reg = VMK8061_DO_REG; reg = VMK8061_DO_REG;
tx_buf[0] = VMK8061_CMD_RD_DO; tx_buf[0] = VMK8061_CMD_RD_DO;
...@@ -904,7 +896,6 @@ static int vmk80xx_cnt_rinsn(struct comedi_device *dev, ...@@ -904,7 +896,6 @@ static int vmk80xx_cnt_rinsn(struct comedi_device *dev,
struct comedi_subdevice *s, struct comedi_subdevice *s,
struct comedi_insn *insn, unsigned int *data) struct comedi_insn *insn, unsigned int *data)
{ {
const struct vmk80xx_board *boardinfo = comedi_board(dev);
struct vmk80xx_private *devpriv = dev->private; struct vmk80xx_private *devpriv = dev->private;
int chan; int chan;
int reg[2]; int reg[2];
...@@ -917,7 +908,7 @@ static int vmk80xx_cnt_rinsn(struct comedi_device *dev, ...@@ -917,7 +908,7 @@ static int vmk80xx_cnt_rinsn(struct comedi_device *dev,
down(&devpriv->limit_sem); down(&devpriv->limit_sem);
chan = CR_CHAN(insn->chanspec); chan = CR_CHAN(insn->chanspec);
switch (boardinfo->model) { switch (devpriv->model) {
case VMK8055_MODEL: case VMK8055_MODEL:
if (!chan) if (!chan)
reg[0] = VMK8055_CNT1_REG; reg[0] = VMK8055_CNT1_REG;
...@@ -936,7 +927,7 @@ static int vmk80xx_cnt_rinsn(struct comedi_device *dev, ...@@ -936,7 +927,7 @@ static int vmk80xx_cnt_rinsn(struct comedi_device *dev,
if (vmk80xx_read_packet(devpriv)) if (vmk80xx_read_packet(devpriv))
break; break;
if (boardinfo->model == VMK8055_MODEL) if (devpriv->model == VMK8055_MODEL)
data[n] = devpriv->usb_rx_buf[reg[0]]; data[n] = devpriv->usb_rx_buf[reg[0]];
else /* VMK8061_MODEL */ else /* VMK8061_MODEL */
data[n] = devpriv->usb_rx_buf[reg[0] * (chan + 1) + 1] data[n] = devpriv->usb_rx_buf[reg[0] * (chan + 1) + 1]
...@@ -952,7 +943,6 @@ static int vmk80xx_cnt_cinsn(struct comedi_device *dev, ...@@ -952,7 +943,6 @@ static int vmk80xx_cnt_cinsn(struct comedi_device *dev,
struct comedi_subdevice *s, struct comedi_subdevice *s,
struct comedi_insn *insn, unsigned int *data) struct comedi_insn *insn, unsigned int *data)
{ {
const struct vmk80xx_board *boardinfo = comedi_board(dev);
struct vmk80xx_private *devpriv = dev->private; struct vmk80xx_private *devpriv = dev->private;
unsigned int insn_cmd; unsigned int insn_cmd;
int chan; int chan;
...@@ -972,7 +962,7 @@ static int vmk80xx_cnt_cinsn(struct comedi_device *dev, ...@@ -972,7 +962,7 @@ static int vmk80xx_cnt_cinsn(struct comedi_device *dev,
chan = CR_CHAN(insn->chanspec); chan = CR_CHAN(insn->chanspec);
if (boardinfo->model == VMK8055_MODEL) { if (devpriv->model == VMK8055_MODEL) {
if (!chan) { if (!chan) {
cmd = VMK8055_CMD_RST_CNT1; cmd = VMK8055_CMD_RST_CNT1;
reg = VMK8055_CNT1_REG; reg = VMK8055_CNT1_REG;
...@@ -1192,7 +1182,7 @@ static int vmk80xx_attach_common(struct comedi_device *dev) ...@@ -1192,7 +1182,7 @@ static int vmk80xx_attach_common(struct comedi_device *dev)
down(&devpriv->limit_sem); down(&devpriv->limit_sem);
if (boardinfo->model == VMK8055_MODEL) if (devpriv->model == VMK8055_MODEL)
n_subd = 5; n_subd = 5;
else else
n_subd = 6; n_subd = 6;
...@@ -1219,7 +1209,7 @@ static int vmk80xx_attach_common(struct comedi_device *dev) ...@@ -1219,7 +1209,7 @@ static int vmk80xx_attach_common(struct comedi_device *dev)
s->maxdata = 0x00ff; s->maxdata = 0x00ff;
s->range_table = boardinfo->range; s->range_table = boardinfo->range;
s->insn_write = vmk80xx_ao_winsn; s->insn_write = vmk80xx_ao_winsn;
if (boardinfo->model == VMK8061_MODEL) { if (devpriv->model == VMK8061_MODEL) {
s->subdev_flags |= SDF_READABLE; s->subdev_flags |= SDF_READABLE;
s->insn_read = vmk80xx_ao_rinsn; s->insn_read = vmk80xx_ao_rinsn;
} }
...@@ -1241,7 +1231,7 @@ static int vmk80xx_attach_common(struct comedi_device *dev) ...@@ -1241,7 +1231,7 @@ static int vmk80xx_attach_common(struct comedi_device *dev)
s->maxdata = 1; s->maxdata = 1;
s->insn_write = vmk80xx_do_winsn; s->insn_write = vmk80xx_do_winsn;
s->insn_bits = vmk80xx_do_bits; s->insn_bits = vmk80xx_do_bits;
if (boardinfo->model == VMK8061_MODEL) { if (devpriv->model == VMK8061_MODEL) {
s->subdev_flags |= SDF_READABLE; s->subdev_flags |= SDF_READABLE;
s->insn_read = vmk80xx_do_rinsn; s->insn_read = vmk80xx_do_rinsn;
} }
...@@ -1253,14 +1243,14 @@ static int vmk80xx_attach_common(struct comedi_device *dev) ...@@ -1253,14 +1243,14 @@ static int vmk80xx_attach_common(struct comedi_device *dev)
s->n_chan = 2; s->n_chan = 2;
s->insn_read = vmk80xx_cnt_rinsn; s->insn_read = vmk80xx_cnt_rinsn;
s->insn_config = vmk80xx_cnt_cinsn; s->insn_config = vmk80xx_cnt_cinsn;
if (boardinfo->model == VMK8055_MODEL) { if (devpriv->model == VMK8055_MODEL) {
s->subdev_flags |= SDF_WRITEABLE; s->subdev_flags |= SDF_WRITEABLE;
s->maxdata = (1 << boardinfo->cnt_bits) - 1; s->maxdata = (1 << boardinfo->cnt_bits) - 1;
s->insn_write = vmk80xx_cnt_winsn; s->insn_write = vmk80xx_cnt_winsn;
} }
/* PWM subdevice */ /* PWM subdevice */
if (boardinfo->model == VMK8061_MODEL) { if (devpriv->model == VMK8061_MODEL) {
s = &dev->subdevices[5]; s = &dev->subdevices[5];
s->type = COMEDI_SUBD_PWM; s->type = COMEDI_SUBD_PWM;
s->subdev_flags = SDF_READABLE | SDF_WRITEABLE; s->subdev_flags = SDF_READABLE | SDF_WRITEABLE;
...@@ -1294,7 +1284,7 @@ static int vmk80xx_auto_attach(struct comedi_device *dev, ...@@ -1294,7 +1284,7 @@ static int vmk80xx_auto_attach(struct comedi_device *dev,
devpriv->usb = interface_to_usbdev(intf); devpriv->usb = interface_to_usbdev(intf);
devpriv->intf = intf; devpriv->intf = intf;
devpriv->board = boardinfo; devpriv->model = boardinfo->model;
ret = vmk80xx_find_usb_endpoints(dev); ret = vmk80xx_find_usb_endpoints(dev);
if (ret) if (ret)
...@@ -1313,7 +1303,7 @@ static int vmk80xx_auto_attach(struct comedi_device *dev, ...@@ -1313,7 +1303,7 @@ static int vmk80xx_auto_attach(struct comedi_device *dev,
usb_set_intfdata(intf, devpriv); usb_set_intfdata(intf, devpriv);
if (boardinfo->model == VMK8061_MODEL) { if (devpriv->model == VMK8061_MODEL) {
vmk80xx_read_eeprom(devpriv, IC3_VERSION); vmk80xx_read_eeprom(devpriv, IC3_VERSION);
dev_info(&intf->dev, "%s\n", devpriv->fw.ic3_vers); dev_info(&intf->dev, "%s\n", devpriv->fw.ic3_vers);
...@@ -1325,7 +1315,7 @@ static int vmk80xx_auto_attach(struct comedi_device *dev, ...@@ -1325,7 +1315,7 @@ static int vmk80xx_auto_attach(struct comedi_device *dev,
} }
} }
if (boardinfo->model == VMK8055_MODEL) if (devpriv->model == VMK8055_MODEL)
vmk80xx_reset_device(devpriv); vmk80xx_reset_device(devpriv);
return vmk80xx_attach_common(dev); return vmk80xx_attach_common(dev);
......
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