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

staging: comedi: usbduxfast: remove 'usb' from the private data

The usb_device pointer can be fetched when needed from the comedi_device
by using comedi_to_usb_interface() then interface_to_usbdev().

Do that instead and remove the pointer from the private data.
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 a71a65b1
...@@ -148,7 +148,6 @@ static const struct comedi_lrange range_usbduxfast_ai_range = { ...@@ -148,7 +148,6 @@ static const struct comedi_lrange range_usbduxfast_ai_range = {
* one sub device just now: A/D * one sub device just now: A/D
*/ */
struct usbduxfast_private { struct usbduxfast_private {
struct usb_device *usb; /* pointer to the usb-device */
struct urb *urbIn; /* BULK-transfer handling: urb */ struct urb *urbIn; /* BULK-transfer handling: urb */
int8_t *transfer_buffer; int8_t *transfer_buffer;
int16_t *insnBuffer; /* input buffer for single insn */ int16_t *insnBuffer; /* input buffer for single insn */
...@@ -169,13 +168,14 @@ struct usbduxfast_private { ...@@ -169,13 +168,14 @@ struct usbduxfast_private {
static int send_dux_commands(struct comedi_device *dev, int cmd_type) static int send_dux_commands(struct comedi_device *dev, int cmd_type)
{ {
struct usb_interface *intf = comedi_to_usb_interface(dev);
struct usb_device *usb = interface_to_usbdev(intf);
struct usbduxfast_private *devpriv = dev->private; struct usbduxfast_private *devpriv = dev->private;
int tmp, nsent; int tmp, nsent;
devpriv->dux_commands[0] = cmd_type; devpriv->dux_commands[0] = cmd_type;
tmp = usb_bulk_msg(devpriv->usb, tmp = usb_bulk_msg(usb, usb_sndbulkpipe(usb, CHANNELLISTEP),
usb_sndbulkpipe(devpriv->usb, CHANNELLISTEP),
devpriv->dux_commands, devpriv->dux_commands,
SIZEOFDUXBUFFER, &nsent, 10000); SIZEOFDUXBUFFER, &nsent, 10000);
if (tmp < 0) if (tmp < 0)
...@@ -261,6 +261,8 @@ static void usbduxfast_ai_interrupt(struct urb *urb) ...@@ -261,6 +261,8 @@ static void usbduxfast_ai_interrupt(struct urb *urb)
struct comedi_device *dev = urb->context; struct comedi_device *dev = urb->context;
struct comedi_subdevice *s = dev->read_subdev; struct comedi_subdevice *s = dev->read_subdev;
struct comedi_async *async = s->async; struct comedi_async *async = s->async;
struct usb_interface *intf = comedi_to_usb_interface(dev);
struct usb_device *usb = interface_to_usbdev(intf);
struct usbduxfast_private *devpriv = dev->private; struct usbduxfast_private *devpriv = dev->private;
int n, err; int n, err;
...@@ -346,7 +348,7 @@ static void usbduxfast_ai_interrupt(struct urb *urb) ...@@ -346,7 +348,7 @@ static void usbduxfast_ai_interrupt(struct urb *urb)
* command is still running * command is still running
* resubmit urb for BULK transfer * resubmit urb for BULK transfer
*/ */
urb->dev = devpriv->usb; urb->dev = usb;
urb->status = 0; urb->status = 0;
err = usb_submit_urb(urb, GFP_ATOMIC); err = usb_submit_urb(urb, GFP_ATOMIC);
if (err < 0) { if (err < 0) {
...@@ -361,7 +363,8 @@ static void usbduxfast_ai_interrupt(struct urb *urb) ...@@ -361,7 +363,8 @@ static void usbduxfast_ai_interrupt(struct urb *urb)
static int usbduxfastsub_start(struct comedi_device *dev) static int usbduxfastsub_start(struct comedi_device *dev)
{ {
struct usbduxfast_private *devpriv = dev->private; struct usb_interface *intf = comedi_to_usb_interface(dev);
struct usb_device *usb = interface_to_usbdev(intf);
unsigned char *local_transfer_buffer; unsigned char *local_transfer_buffer;
int ret; int ret;
...@@ -372,7 +375,7 @@ static int usbduxfastsub_start(struct comedi_device *dev) ...@@ -372,7 +375,7 @@ static int usbduxfastsub_start(struct comedi_device *dev)
/* 7f92 to zero */ /* 7f92 to zero */
*local_transfer_buffer = 0; *local_transfer_buffer = 0;
/* bRequest, "Firmware" */ /* bRequest, "Firmware" */
ret = usb_control_msg(devpriv->usb, usb_sndctrlpipe(devpriv->usb, 0), ret = usb_control_msg(usb, usb_sndctrlpipe(usb, 0),
USBDUXFASTSUB_FIRMWARE, USBDUXFASTSUB_FIRMWARE,
VENDOR_DIR_OUT, /* bmRequestType */ VENDOR_DIR_OUT, /* bmRequestType */
USBDUXFASTSUB_CPUCS, /* Value */ USBDUXFASTSUB_CPUCS, /* Value */
...@@ -390,7 +393,8 @@ static int usbduxfastsub_start(struct comedi_device *dev) ...@@ -390,7 +393,8 @@ static int usbduxfastsub_start(struct comedi_device *dev)
static int usbduxfastsub_stop(struct comedi_device *dev) static int usbduxfastsub_stop(struct comedi_device *dev)
{ {
struct usbduxfast_private *devpriv = dev->private; struct usb_interface *intf = comedi_to_usb_interface(dev);
struct usb_device *usb = interface_to_usbdev(intf);
unsigned char *local_transfer_buffer; unsigned char *local_transfer_buffer;
int ret; int ret;
...@@ -401,7 +405,7 @@ static int usbduxfastsub_stop(struct comedi_device *dev) ...@@ -401,7 +405,7 @@ static int usbduxfastsub_stop(struct comedi_device *dev)
/* 7f92 to one */ /* 7f92 to one */
*local_transfer_buffer = 1; *local_transfer_buffer = 1;
/* bRequest, "Firmware" */ /* bRequest, "Firmware" */
ret = usb_control_msg(devpriv->usb, usb_sndctrlpipe(devpriv->usb, 0), ret = usb_control_msg(usb, usb_sndctrlpipe(usb, 0),
USBDUXFASTSUB_FIRMWARE, USBDUXFASTSUB_FIRMWARE,
VENDOR_DIR_OUT, /* bmRequestType */ VENDOR_DIR_OUT, /* bmRequestType */
USBDUXFASTSUB_CPUCS, /* Value */ USBDUXFASTSUB_CPUCS, /* Value */
...@@ -419,11 +423,12 @@ static int usbduxfastsub_upload(struct comedi_device *dev, ...@@ -419,11 +423,12 @@ static int usbduxfastsub_upload(struct comedi_device *dev,
unsigned char *local_transfer_buffer, unsigned char *local_transfer_buffer,
unsigned int startAddr, unsigned int len) unsigned int startAddr, unsigned int len)
{ {
struct usbduxfast_private *devpriv = dev->private; struct usb_interface *intf = comedi_to_usb_interface(dev);
struct usb_device *usb = interface_to_usbdev(intf);
int ret; int ret;
/* brequest, firmware */ /* brequest, firmware */
ret = usb_control_msg(devpriv->usb, usb_sndctrlpipe(devpriv->usb, 0), ret = usb_control_msg(usb, usb_sndctrlpipe(usb, 0),
USBDUXFASTSUB_FIRMWARE, USBDUXFASTSUB_FIRMWARE,
VENDOR_DIR_OUT, /* bmRequestType */ VENDOR_DIR_OUT, /* bmRequestType */
startAddr, /* value */ startAddr, /* value */
...@@ -442,14 +447,15 @@ static int usbduxfastsub_upload(struct comedi_device *dev, ...@@ -442,14 +447,15 @@ static int usbduxfastsub_upload(struct comedi_device *dev,
static int usbduxfastsub_submit_InURBs(struct comedi_device *dev) static int usbduxfastsub_submit_InURBs(struct comedi_device *dev)
{ {
struct usb_interface *intf = comedi_to_usb_interface(dev);
struct usb_device *usb = interface_to_usbdev(intf);
struct usbduxfast_private *devpriv = dev->private; struct usbduxfast_private *devpriv = dev->private;
int ret; int ret;
if (!devpriv) if (!devpriv)
return -EFAULT; return -EFAULT;
usb_fill_bulk_urb(devpriv->urbIn, devpriv->usb, usb_fill_bulk_urb(devpriv->urbIn, usb, usb_rcvbulkpipe(usb, BULKINEP),
usb_rcvbulkpipe(devpriv->usb, BULKINEP),
devpriv->transfer_buffer, SIZEINBUF, devpriv->transfer_buffer, SIZEINBUF,
usbduxfast_ai_interrupt, dev); usbduxfast_ai_interrupt, dev);
...@@ -1045,6 +1051,8 @@ static int usbduxfast_ai_insn_read(struct comedi_device *dev, ...@@ -1045,6 +1051,8 @@ static int usbduxfast_ai_insn_read(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)
{ {
struct usb_interface *intf = comedi_to_usb_interface(dev);
struct usb_device *usb = interface_to_usbdev(intf);
struct usbduxfast_private *devpriv = dev->private; struct usbduxfast_private *devpriv = dev->private;
int i, j, n, actual_length; int i, j, n, actual_length;
int chan, range, rngmask; int chan, range, rngmask;
...@@ -1121,8 +1129,7 @@ static int usbduxfast_ai_insn_read(struct comedi_device *dev, ...@@ -1121,8 +1129,7 @@ static int usbduxfast_ai_insn_read(struct comedi_device *dev,
} }
for (i = 0; i < PACKETS_TO_IGNORE; i++) { for (i = 0; i < PACKETS_TO_IGNORE; i++) {
err = usb_bulk_msg(devpriv->usb, err = usb_bulk_msg(usb, usb_rcvbulkpipe(usb, BULKINEP),
usb_rcvbulkpipe(devpriv->usb, BULKINEP),
devpriv->transfer_buffer, SIZEINBUF, devpriv->transfer_buffer, SIZEINBUF,
&actual_length, 10000); &actual_length, 10000);
if (err < 0) { if (err < 0) {
...@@ -1133,8 +1140,7 @@ static int usbduxfast_ai_insn_read(struct comedi_device *dev, ...@@ -1133,8 +1140,7 @@ static int usbduxfast_ai_insn_read(struct comedi_device *dev,
} }
/* data points */ /* data points */
for (i = 0; i < insn->n;) { for (i = 0; i < insn->n;) {
err = usb_bulk_msg(devpriv->usb, err = usb_bulk_msg(usb, usb_rcvbulkpipe(usb, BULKINEP),
usb_rcvbulkpipe(devpriv->usb, BULKINEP),
devpriv->transfer_buffer, SIZEINBUF, devpriv->transfer_buffer, SIZEINBUF,
&actual_length, 10000); &actual_length, 10000);
if (err < 0) { if (err < 0) {
...@@ -1273,7 +1279,6 @@ static int usbduxfast_auto_attach(struct comedi_device *dev, ...@@ -1273,7 +1279,6 @@ static int usbduxfast_auto_attach(struct comedi_device *dev,
dev->private = devpriv; dev->private = devpriv;
sema_init(&devpriv->sem, 1); sema_init(&devpriv->sem, 1);
devpriv->usb = usb;
usb_set_intfdata(intf, devpriv); usb_set_intfdata(intf, devpriv);
devpriv->dux_commands = kmalloc(SIZEOFDUXBUFFER, GFP_KERNEL); devpriv->dux_commands = kmalloc(SIZEOFDUXBUFFER, GFP_KERNEL);
...@@ -1284,7 +1289,7 @@ static int usbduxfast_auto_attach(struct comedi_device *dev, ...@@ -1284,7 +1289,7 @@ static int usbduxfast_auto_attach(struct comedi_device *dev,
if (!devpriv->insnBuffer) if (!devpriv->insnBuffer)
return -ENOMEM; return -ENOMEM;
ret = usb_set_interface(devpriv->usb, ret = usb_set_interface(usb,
intf->altsetting->desc.bInterfaceNumber, 1); intf->altsetting->desc.bInterfaceNumber, 1);
if (ret < 0) { if (ret < 0) {
dev_err(dev->class_dev, dev_err(dev->class_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