Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 354440
b: refs/heads/master
c: 52d895d
h: refs/heads/master
v: v3
  • Loading branch information
H Hartley Sweeten authored and Greg Kroah-Hartman committed Feb 6, 2013
1 parent 5424e01 commit e496519
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 36 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 57cf09aeeeadf35ef7f678a870139894d67a794f
refs/heads/master: 52d895d3672dd58c0067c2efca4b825e4d733d0c
60 changes: 25 additions & 35 deletions trunk/drivers/staging/comedi/drivers/vmk80xx.c
Original file line number Diff line number Diff line change
Expand Up @@ -202,14 +202,14 @@ struct vmk80xx_private {
struct usb_endpoint_descriptor *ep_tx;
struct usb_anchor rx_anchor;
struct usb_anchor tx_anchor;
const struct vmk80xx_board *board;
struct firmware_version fw;
struct semaphore limit_sem;
wait_queue_head_t read_wait;
wait_queue_head_t write_wait;
unsigned char *usb_rx_buf;
unsigned char *usb_tx_buf;
unsigned long flags;
enum vmk80xx_model model;
};

static void vmk80xx_tx_callback(struct urb *urb)
Expand Down Expand Up @@ -423,7 +423,6 @@ static void vmk80xx_do_bulk_msg(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;
struct urb *urb;
int retval;
Expand All @@ -437,7 +436,7 @@ static int vmk80xx_read_packet(struct vmk80xx_private *devpriv)
!test_bit(TRANS_IN_BUSY, flags)))
return -ERESTART;

if (boardinfo->model == VMK8061_MODEL) {
if (devpriv->model == VMK8061_MODEL) {
vmk80xx_do_bulk_msg(devpriv);

return 0;
Expand Down Expand Up @@ -470,7 +469,6 @@ static int vmk80xx_read_packet(struct vmk80xx_private *devpriv)

static int vmk80xx_write_packet(struct vmk80xx_private *devpriv, int cmd)
{
const struct vmk80xx_board *boardinfo = devpriv->board;
unsigned long *flags = &devpriv->flags;
struct urb *urb;
int retval;
Expand All @@ -483,7 +481,7 @@ static int vmk80xx_write_packet(struct vmk80xx_private *devpriv, int cmd)
!test_bit(TRANS_OUT_BUSY, flags)))
return -ERESTART;

if (boardinfo->model == VMK8061_MODEL) {
if (devpriv->model == VMK8061_MODEL) {
devpriv->usb_tx_buf[0] = cmd;
vmk80xx_do_bulk_msg(devpriv);

Expand Down Expand Up @@ -539,7 +537,6 @@ static int vmk80xx_ai_rinsn(struct comedi_device *dev,
struct comedi_subdevice *s,
struct comedi_insn *insn, unsigned int *data)
{
const struct vmk80xx_board *boardinfo = comedi_board(dev);
struct vmk80xx_private *devpriv = dev->private;
int chan;
int reg[2];
Expand All @@ -552,7 +549,7 @@ static int vmk80xx_ai_rinsn(struct comedi_device *dev,
down(&devpriv->limit_sem);
chan = CR_CHAN(insn->chanspec);

switch (boardinfo->model) {
switch (devpriv->model) {
case VMK8055_MODEL:
if (!chan)
reg[0] = VMK8055_AI1_REG;
Expand All @@ -572,7 +569,7 @@ static int vmk80xx_ai_rinsn(struct comedi_device *dev,
if (vmk80xx_read_packet(devpriv))
break;

if (boardinfo->model == VMK8055_MODEL) {
if (devpriv->model == VMK8055_MODEL) {
data[n] = devpriv->usb_rx_buf[reg[0]];
continue;
}
Expand All @@ -591,7 +588,6 @@ static int vmk80xx_ao_winsn(struct comedi_device *dev,
struct comedi_subdevice *s,
struct comedi_insn *insn, unsigned int *data)
{
const struct vmk80xx_board *boardinfo = comedi_board(dev);
struct vmk80xx_private *devpriv = dev->private;
int chan;
int cmd;
Expand All @@ -605,7 +601,7 @@ static int vmk80xx_ao_winsn(struct comedi_device *dev,
down(&devpriv->limit_sem);
chan = CR_CHAN(insn->chanspec);

switch (boardinfo->model) {
switch (devpriv->model) {
case VMK8055_MODEL:
cmd = VMK8055_CMD_WRT_AD;
if (!chan)
Expand Down Expand Up @@ -668,7 +664,6 @@ static int vmk80xx_di_bits(struct comedi_device *dev,
struct comedi_subdevice *s,
struct comedi_insn *insn, unsigned int *data)
{
const struct vmk80xx_board *boardinfo = comedi_board(dev);
struct vmk80xx_private *devpriv = dev->private;
unsigned char *rx_buf;
int reg;
Expand All @@ -682,7 +677,7 @@ static int vmk80xx_di_bits(struct comedi_device *dev,

rx_buf = devpriv->usb_rx_buf;

if (boardinfo->model == VMK8061_MODEL) {
if (devpriv->model == VMK8061_MODEL) {
reg = VMK8061_DI_REG;
devpriv->usb_tx_buf[0] = VMK8061_CMD_RD_DI;
} else {
Expand All @@ -692,7 +687,7 @@ static int vmk80xx_di_bits(struct comedi_device *dev,
retval = vmk80xx_read_packet(devpriv);

if (!retval) {
if (boardinfo->model == VMK8055_MODEL)
if (devpriv->model == VMK8055_MODEL)
data[1] = (((rx_buf[reg] >> 4) & 0x03) |
((rx_buf[reg] << 2) & 0x04) |
((rx_buf[reg] >> 3) & 0x18));
Expand All @@ -711,7 +706,6 @@ static int vmk80xx_di_rinsn(struct comedi_device *dev,
struct comedi_subdevice *s,
struct comedi_insn *insn, unsigned int *data)
{
const struct vmk80xx_board *boardinfo = comedi_board(dev);
struct vmk80xx_private *devpriv = dev->private;
int chan;
unsigned char *rx_buf;
Expand All @@ -728,7 +722,7 @@ static int vmk80xx_di_rinsn(struct comedi_device *dev,

rx_buf = devpriv->usb_rx_buf;

if (boardinfo->model == VMK8061_MODEL) {
if (devpriv->model == VMK8061_MODEL) {
reg = VMK8061_DI_REG;
devpriv->usb_tx_buf[0] = VMK8061_CMD_RD_DI;
} else {
Expand All @@ -738,7 +732,7 @@ static int vmk80xx_di_rinsn(struct comedi_device *dev,
if (vmk80xx_read_packet(devpriv))
break;

if (boardinfo->model == VMK8055_MODEL)
if (devpriv->model == VMK8055_MODEL)
inp = (((rx_buf[reg] >> 4) & 0x03) |
((rx_buf[reg] << 2) & 0x04) |
((rx_buf[reg] >> 3) & 0x18));
Expand All @@ -757,7 +751,6 @@ static int vmk80xx_do_winsn(struct comedi_device *dev,
struct comedi_subdevice *s,
struct comedi_insn *insn, unsigned int *data)
{
const struct vmk80xx_board *boardinfo = comedi_board(dev);
struct vmk80xx_private *devpriv = dev->private;
int chan;
unsigned char *tx_buf;
Expand All @@ -775,7 +768,7 @@ static int vmk80xx_do_winsn(struct comedi_device *dev,
tx_buf = devpriv->usb_tx_buf;

for (n = 0; n < insn->n; n++) {
if (boardinfo->model == VMK8055_MODEL) {
if (devpriv->model == VMK8055_MODEL) {
reg = VMK8055_DO_REG;
cmd = VMK8055_CMD_WRT_AD;
if (data[n] == 1)
Expand Down Expand Up @@ -838,7 +831,6 @@ static int vmk80xx_do_bits(struct comedi_device *dev,
struct comedi_subdevice *s,
struct comedi_insn *insn, unsigned int *data)
{
const struct vmk80xx_board *boardinfo = comedi_board(dev);
struct vmk80xx_private *devpriv = dev->private;
unsigned char *rx_buf, *tx_buf;
int dir, reg, cmd;
Expand All @@ -849,7 +841,7 @@ static int vmk80xx_do_bits(struct comedi_device *dev,
if (data[0])
dir |= DIR_OUT;

if (boardinfo->model == VMK8061_MODEL)
if (devpriv->model == VMK8061_MODEL)
dir |= DIR_IN;

retval = rudimentary_check(devpriv, dir);
Expand All @@ -862,7 +854,7 @@ static int vmk80xx_do_bits(struct comedi_device *dev,
tx_buf = devpriv->usb_tx_buf;

if (data[0]) {
if (boardinfo->model == VMK8055_MODEL) {
if (devpriv->model == VMK8055_MODEL) {
reg = VMK8055_DO_REG;
cmd = VMK8055_CMD_WRT_AD;
} else { /* VMK8061_MODEL */
Expand All @@ -879,7 +871,7 @@ static int vmk80xx_do_bits(struct comedi_device *dev,
goto out;
}

if (boardinfo->model == VMK8061_MODEL) {
if (devpriv->model == VMK8061_MODEL) {
reg = VMK8061_DO_REG;
tx_buf[0] = VMK8061_CMD_RD_DO;

Expand All @@ -904,7 +896,6 @@ static int vmk80xx_cnt_rinsn(struct comedi_device *dev,
struct comedi_subdevice *s,
struct comedi_insn *insn, unsigned int *data)
{
const struct vmk80xx_board *boardinfo = comedi_board(dev);
struct vmk80xx_private *devpriv = dev->private;
int chan;
int reg[2];
Expand All @@ -917,7 +908,7 @@ static int vmk80xx_cnt_rinsn(struct comedi_device *dev,
down(&devpriv->limit_sem);
chan = CR_CHAN(insn->chanspec);

switch (boardinfo->model) {
switch (devpriv->model) {
case VMK8055_MODEL:
if (!chan)
reg[0] = VMK8055_CNT1_REG;
Expand All @@ -936,7 +927,7 @@ static int vmk80xx_cnt_rinsn(struct comedi_device *dev,
if (vmk80xx_read_packet(devpriv))
break;

if (boardinfo->model == VMK8055_MODEL)
if (devpriv->model == VMK8055_MODEL)
data[n] = devpriv->usb_rx_buf[reg[0]];
else /* VMK8061_MODEL */
data[n] = devpriv->usb_rx_buf[reg[0] * (chan + 1) + 1]
Expand All @@ -952,7 +943,6 @@ static int vmk80xx_cnt_cinsn(struct comedi_device *dev,
struct comedi_subdevice *s,
struct comedi_insn *insn, unsigned int *data)
{
const struct vmk80xx_board *boardinfo = comedi_board(dev);
struct vmk80xx_private *devpriv = dev->private;
unsigned int insn_cmd;
int chan;
Expand All @@ -972,7 +962,7 @@ static int vmk80xx_cnt_cinsn(struct comedi_device *dev,

chan = CR_CHAN(insn->chanspec);

if (boardinfo->model == VMK8055_MODEL) {
if (devpriv->model == VMK8055_MODEL) {
if (!chan) {
cmd = VMK8055_CMD_RST_CNT1;
reg = VMK8055_CNT1_REG;
Expand Down Expand Up @@ -1192,7 +1182,7 @@ static int vmk80xx_attach_common(struct comedi_device *dev)

down(&devpriv->limit_sem);

if (boardinfo->model == VMK8055_MODEL)
if (devpriv->model == VMK8055_MODEL)
n_subd = 5;
else
n_subd = 6;
Expand All @@ -1219,7 +1209,7 @@ static int vmk80xx_attach_common(struct comedi_device *dev)
s->maxdata = 0x00ff;
s->range_table = boardinfo->range;
s->insn_write = vmk80xx_ao_winsn;
if (boardinfo->model == VMK8061_MODEL) {
if (devpriv->model == VMK8061_MODEL) {
s->subdev_flags |= SDF_READABLE;
s->insn_read = vmk80xx_ao_rinsn;
}
Expand All @@ -1241,7 +1231,7 @@ static int vmk80xx_attach_common(struct comedi_device *dev)
s->maxdata = 1;
s->insn_write = vmk80xx_do_winsn;
s->insn_bits = vmk80xx_do_bits;
if (boardinfo->model == VMK8061_MODEL) {
if (devpriv->model == VMK8061_MODEL) {
s->subdev_flags |= SDF_READABLE;
s->insn_read = vmk80xx_do_rinsn;
}
Expand All @@ -1253,14 +1243,14 @@ static int vmk80xx_attach_common(struct comedi_device *dev)
s->n_chan = 2;
s->insn_read = vmk80xx_cnt_rinsn;
s->insn_config = vmk80xx_cnt_cinsn;
if (boardinfo->model == VMK8055_MODEL) {
if (devpriv->model == VMK8055_MODEL) {
s->subdev_flags |= SDF_WRITEABLE;
s->maxdata = (1 << boardinfo->cnt_bits) - 1;
s->insn_write = vmk80xx_cnt_winsn;
}

/* PWM subdevice */
if (boardinfo->model == VMK8061_MODEL) {
if (devpriv->model == VMK8061_MODEL) {
s = &dev->subdevices[5];
s->type = COMEDI_SUBD_PWM;
s->subdev_flags = SDF_READABLE | SDF_WRITEABLE;
Expand Down Expand Up @@ -1294,7 +1284,7 @@ static int vmk80xx_auto_attach(struct comedi_device *dev,

devpriv->usb = interface_to_usbdev(intf);
devpriv->intf = intf;
devpriv->board = boardinfo;
devpriv->model = boardinfo->model;

ret = vmk80xx_find_usb_endpoints(dev);
if (ret)
Expand All @@ -1313,7 +1303,7 @@ static int vmk80xx_auto_attach(struct comedi_device *dev,

usb_set_intfdata(intf, devpriv);

if (boardinfo->model == VMK8061_MODEL) {
if (devpriv->model == VMK8061_MODEL) {
vmk80xx_read_eeprom(devpriv, IC3_VERSION);
dev_info(&intf->dev, "%s\n", devpriv->fw.ic3_vers);

Expand All @@ -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);

return vmk80xx_attach_common(dev);
Expand Down

0 comments on commit e496519

Please sign in to comment.