From: H Hartley Sweeten Date: Mon, 20 May 2013 21:24:32 +0000 (-0700) Subject: staging: comedi: vmk80xx: don't pass the private data directly X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=0703c9553847b31cf34a7a04a839806fb361422f;p=GitHub%2Fmoto-9609%2Fandroid_kernel_motorola_exynos9610.git staging: comedi: vmk80xx: don't pass the private data directly 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 Cc Ian Abbott Signed-off-by: Greg Kroah-Hartman --- diff --git a/drivers/staging/comedi/drivers/vmk80xx.c b/drivers/staging/comedi/drivers/vmk80xx.c index f55c656d053c..5e67877601da 100644 --- a/drivers/staging/comedi/drivers/vmk80xx.c +++ b/drivers/staging/comedi/drivers/vmk80xx.c @@ -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; @@ -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; @@ -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; @@ -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; @@ -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; } @@ -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; @@ -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; } @@ -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, @@ -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) { @@ -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; } @@ -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]; @@ -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) @@ -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; @@ -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]; @@ -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) @@ -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); @@ -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; } @@ -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]]; @@ -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; } @@ -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); }