Skip to content

Commit

Permalink
staging: comedi: vmk80xx: don't pass the private data directly
Browse files Browse the repository at this point in the history
Instead of passing the private data to the internal functions. pass
the comedi_device pointer and get the private data from it.

Signed-off-by: H Hartley Sweeten <[email protected]>
Cc Ian Abbott <[email protected]>
Signed-off-by: Greg Kroah-Hartman <[email protected]>
  • Loading branch information
bigguiness authored and gregkh committed May 21, 2013
1 parent 0a92de2 commit 0703c95
Showing 1 changed file with 31 additions and 25 deletions.
56 changes: 31 additions & 25 deletions drivers/staging/comedi/drivers/vmk80xx.c
Original file line number Diff line number Diff line change
Expand Up @@ -165,8 +165,9 @@ struct vmk80xx_private {
enum vmk80xx_model model;
};

static int vmk80xx_check_data_link(struct vmk80xx_private *devpriv)
static int vmk80xx_check_data_link(struct comedi_device *dev)
{
struct vmk80xx_private *devpriv = dev->private;
struct usb_device *usb = devpriv->usb;
unsigned int tx_pipe;
unsigned int rx_pipe;
Expand All @@ -189,8 +190,9 @@ static int vmk80xx_check_data_link(struct vmk80xx_private *devpriv)
return (int)rx[1];
}

static void vmk80xx_read_eeprom(struct vmk80xx_private *devpriv, int flag)
static void vmk80xx_read_eeprom(struct comedi_device *dev, int flag)
{
struct vmk80xx_private *devpriv = dev->private;
struct usb_device *usb = devpriv->usb;
unsigned int tx_pipe;
unsigned int rx_pipe;
Expand Down Expand Up @@ -218,8 +220,9 @@ static void vmk80xx_read_eeprom(struct vmk80xx_private *devpriv, int flag)
strncpy(devpriv->fw.ic6_vers, rx + 25, 24);
}

static void vmk80xx_do_bulk_msg(struct vmk80xx_private *devpriv)
static void vmk80xx_do_bulk_msg(struct comedi_device *dev)
{
struct vmk80xx_private *devpriv = dev->private;
struct usb_device *usb = devpriv->usb;
__u8 tx_addr;
__u8 rx_addr;
Expand All @@ -243,8 +246,9 @@ static void vmk80xx_do_bulk_msg(struct vmk80xx_private *devpriv)
usb_bulk_msg(usb, rx_pipe, devpriv->usb_rx_buf, size, NULL, HZ * 10);
}

static int vmk80xx_read_packet(struct vmk80xx_private *devpriv)
static int vmk80xx_read_packet(struct comedi_device *dev)
{
struct vmk80xx_private *devpriv = dev->private;
struct usb_device *usb;
struct usb_endpoint_descriptor *ep;
unsigned int pipe;
Expand All @@ -253,7 +257,7 @@ static int vmk80xx_read_packet(struct vmk80xx_private *devpriv)
return -ENODEV;

if (devpriv->model == VMK8061_MODEL) {
vmk80xx_do_bulk_msg(devpriv);
vmk80xx_do_bulk_msg(dev);
return 0;
}

Expand All @@ -265,8 +269,9 @@ static int vmk80xx_read_packet(struct vmk80xx_private *devpriv)
HZ * 10);
}

static int vmk80xx_write_packet(struct vmk80xx_private *devpriv, int cmd)
static int vmk80xx_write_packet(struct comedi_device *dev, int cmd)
{
struct vmk80xx_private *devpriv = dev->private;
struct usb_device *usb;
struct usb_endpoint_descriptor *ep;
unsigned int pipe;
Expand All @@ -277,7 +282,7 @@ static int vmk80xx_write_packet(struct vmk80xx_private *devpriv, int cmd)
devpriv->usb_tx_buf[0] = cmd;

if (devpriv->model == VMK8061_MODEL) {
vmk80xx_do_bulk_msg(devpriv);
vmk80xx_do_bulk_msg(dev);
return 0;
}

Expand All @@ -289,18 +294,19 @@ static int vmk80xx_write_packet(struct vmk80xx_private *devpriv, int cmd)
HZ * 10);
}

static int vmk80xx_reset_device(struct vmk80xx_private *devpriv)
static int vmk80xx_reset_device(struct comedi_device *dev)
{
struct vmk80xx_private *devpriv = dev->private;
size_t size;
int retval;

size = le16_to_cpu(devpriv->ep_tx->wMaxPacketSize);
memset(devpriv->usb_tx_buf, 0, size);
retval = vmk80xx_write_packet(devpriv, VMK8055_CMD_RST);
retval = vmk80xx_write_packet(dev, VMK8055_CMD_RST);
if (retval)
return retval;
/* set outputs to known state as we cannot read them */
return vmk80xx_write_packet(devpriv, VMK8055_CMD_WRT_AD);
return vmk80xx_write_packet(dev, VMK8055_CMD_WRT_AD);
}

static int vmk80xx_ai_insn_read(struct comedi_device *dev,
Expand Down Expand Up @@ -333,7 +339,7 @@ static int vmk80xx_ai_insn_read(struct comedi_device *dev,
}

for (n = 0; n < insn->n; n++) {
if (vmk80xx_read_packet(devpriv))
if (vmk80xx_read_packet(dev))
break;

if (devpriv->model == VMK8055_MODEL) {
Expand Down Expand Up @@ -383,7 +389,7 @@ static int vmk80xx_ao_insn_write(struct comedi_device *dev,
for (n = 0; n < insn->n; n++) {
devpriv->usb_tx_buf[reg] = data[n];

if (vmk80xx_write_packet(devpriv, cmd))
if (vmk80xx_write_packet(dev, cmd))
break;
}

Expand All @@ -410,7 +416,7 @@ static int vmk80xx_ao_insn_read(struct comedi_device *dev,
devpriv->usb_tx_buf[0] = VMK8061_CMD_RD_AO;

for (n = 0; n < insn->n; n++) {
if (vmk80xx_read_packet(devpriv))
if (vmk80xx_read_packet(dev))
break;

data[n] = devpriv->usb_rx_buf[reg + chan];
Expand Down Expand Up @@ -442,7 +448,7 @@ static int vmk80xx_di_insn_bits(struct comedi_device *dev,
reg = VMK8055_DI_REG;
}

retval = vmk80xx_read_packet(devpriv);
retval = vmk80xx_read_packet(dev);

if (!retval) {
if (devpriv->model == VMK8055_MODEL)
Expand Down Expand Up @@ -487,7 +493,7 @@ static int vmk80xx_do_insn_bits(struct comedi_device *dev,
tx_buf[reg] &= ~data[0];
tx_buf[reg] |= (data[0] & data[1]);

retval = vmk80xx_write_packet(devpriv, cmd);
retval = vmk80xx_write_packet(dev, cmd);

if (retval)
goto out;
Expand All @@ -496,7 +502,7 @@ static int vmk80xx_do_insn_bits(struct comedi_device *dev,
if (devpriv->model == VMK8061_MODEL) {
tx_buf[0] = VMK8061_CMD_RD_DO;

retval = vmk80xx_read_packet(devpriv);
retval = vmk80xx_read_packet(dev);

if (!retval) {
data[1] = rx_buf[reg];
Expand Down Expand Up @@ -542,7 +548,7 @@ static int vmk80xx_cnt_insn_read(struct comedi_device *dev,
}

for (n = 0; n < insn->n; n++) {
if (vmk80xx_read_packet(devpriv))
if (vmk80xx_read_packet(dev))
break;

if (devpriv->model == VMK8055_MODEL)
Expand Down Expand Up @@ -592,7 +598,7 @@ static int vmk80xx_cnt_insn_config(struct comedi_device *dev,
}

for (n = 0; n < insn->n; n++)
if (vmk80xx_write_packet(devpriv, cmd))
if (vmk80xx_write_packet(dev, cmd))
break;

up(&devpriv->limit_sem);
Expand Down Expand Up @@ -635,7 +641,7 @@ static int vmk80xx_cnt_insn_write(struct comedi_device *dev,

devpriv->usb_tx_buf[6 + chan] = val;

if (vmk80xx_write_packet(devpriv, cmd))
if (vmk80xx_write_packet(dev, cmd))
break;
}

Expand Down Expand Up @@ -666,7 +672,7 @@ static int vmk80xx_pwm_insn_read(struct comedi_device *dev,
tx_buf[0] = VMK8061_CMD_RD_PWM;

for (n = 0; n < insn->n; n++) {
if (vmk80xx_read_packet(devpriv))
if (vmk80xx_read_packet(dev))
break;

data[n] = rx_buf[reg[0]] + 4 * rx_buf[reg[1]];
Expand Down Expand Up @@ -714,7 +720,7 @@ static int vmk80xx_pwm_insn_write(struct comedi_device *dev,
tx_buf[reg[0]] = (unsigned char)(data[n] & 0x03);
tx_buf[reg[1]] = (unsigned char)(data[n] >> 2) & 0xff;

if (vmk80xx_write_packet(devpriv, cmd))
if (vmk80xx_write_packet(dev, cmd))
break;
}

Expand Down Expand Up @@ -901,17 +907,17 @@ static int vmk80xx_auto_attach(struct comedi_device *dev,
usb_set_intfdata(intf, devpriv);

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

if (vmk80xx_check_data_link(devpriv)) {
vmk80xx_read_eeprom(devpriv, IC6_VERSION);
if (vmk80xx_check_data_link(dev)) {
vmk80xx_read_eeprom(dev, IC6_VERSION);
dev_info(&intf->dev, "%s\n", devpriv->fw.ic6_vers);
}
}

if (devpriv->model == VMK8055_MODEL)
vmk80xx_reset_device(devpriv);
vmk80xx_reset_device(dev);

return vmk80xx_init_subdevices(dev);
}
Expand Down

0 comments on commit 0703c95

Please sign in to comment.