Commit ed752e5d authored by Oliver Neukum's avatar Oliver Neukum Committed by Dmitry Torokhov

Input: gtco - stop saving struct usb_device

The device can now easily be derived from the interface.
Stop leaving a private copy.
Signed-off-by: default avatarOliver Neukum <oneukum@suse.com>
Signed-off-by: default avatarDmitry Torokhov <dmitry.torokhov@gmail.com>
parent c6309018
...@@ -104,7 +104,6 @@ MODULE_DEVICE_TABLE (usb, gtco_usbid_table); ...@@ -104,7 +104,6 @@ MODULE_DEVICE_TABLE (usb, gtco_usbid_table);
struct gtco { struct gtco {
struct input_dev *inputdevice; /* input device struct pointer */ struct input_dev *inputdevice; /* input device struct pointer */
struct usb_device *usbdev; /* the usb device for this device */
struct usb_interface *intf; /* the usb interface for this device */ struct usb_interface *intf; /* the usb interface for this device */
struct urb *urbinfo; /* urb for incoming reports */ struct urb *urbinfo; /* urb for incoming reports */
dma_addr_t buf_dma; /* dma addr of the data buffer*/ dma_addr_t buf_dma; /* dma addr of the data buffer*/
...@@ -540,7 +539,7 @@ static int gtco_input_open(struct input_dev *inputdev) ...@@ -540,7 +539,7 @@ static int gtco_input_open(struct input_dev *inputdev)
{ {
struct gtco *device = input_get_drvdata(inputdev); struct gtco *device = input_get_drvdata(inputdev);
device->urbinfo->dev = device->usbdev; device->urbinfo->dev = interface_to_usbdev(device->intf);
if (usb_submit_urb(device->urbinfo, GFP_KERNEL)) if (usb_submit_urb(device->urbinfo, GFP_KERNEL))
return -EIO; return -EIO;
...@@ -824,6 +823,7 @@ static int gtco_probe(struct usb_interface *usbinterface, ...@@ -824,6 +823,7 @@ static int gtco_probe(struct usb_interface *usbinterface,
int result = 0, retry; int result = 0, retry;
int error; int error;
struct usb_endpoint_descriptor *endpoint; struct usb_endpoint_descriptor *endpoint;
struct usb_device *udev = interface_to_usbdev(usbinterface);
/* Allocate memory for device structure */ /* Allocate memory for device structure */
gtco = kzalloc(sizeof(struct gtco), GFP_KERNEL); gtco = kzalloc(sizeof(struct gtco), GFP_KERNEL);
...@@ -838,11 +838,10 @@ static int gtco_probe(struct usb_interface *usbinterface, ...@@ -838,11 +838,10 @@ static int gtco_probe(struct usb_interface *usbinterface,
gtco->inputdevice = input_dev; gtco->inputdevice = input_dev;
/* Save interface information */ /* Save interface information */
gtco->usbdev = interface_to_usbdev(usbinterface);
gtco->intf = usbinterface; gtco->intf = usbinterface;
/* Allocate some data for incoming reports */ /* Allocate some data for incoming reports */
gtco->buffer = usb_alloc_coherent(gtco->usbdev, REPORT_MAX_SIZE, gtco->buffer = usb_alloc_coherent(udev, REPORT_MAX_SIZE,
GFP_KERNEL, &gtco->buf_dma); GFP_KERNEL, &gtco->buf_dma);
if (!gtco->buffer) { if (!gtco->buffer) {
dev_err(&usbinterface->dev, "No more memory for us buffers\n"); dev_err(&usbinterface->dev, "No more memory for us buffers\n");
...@@ -899,8 +898,8 @@ static int gtco_probe(struct usb_interface *usbinterface, ...@@ -899,8 +898,8 @@ static int gtco_probe(struct usb_interface *usbinterface,
/* Couple of tries to get reply */ /* Couple of tries to get reply */
for (retry = 0; retry < 3; retry++) { for (retry = 0; retry < 3; retry++) {
result = usb_control_msg(gtco->usbdev, result = usb_control_msg(udev,
usb_rcvctrlpipe(gtco->usbdev, 0), usb_rcvctrlpipe(udev, 0),
USB_REQ_GET_DESCRIPTOR, USB_REQ_GET_DESCRIPTOR,
USB_RECIP_INTERFACE | USB_DIR_IN, USB_RECIP_INTERFACE | USB_DIR_IN,
REPORT_DEVICE_TYPE << 8, REPORT_DEVICE_TYPE << 8,
...@@ -928,7 +927,7 @@ static int gtco_probe(struct usb_interface *usbinterface, ...@@ -928,7 +927,7 @@ static int gtco_probe(struct usb_interface *usbinterface,
} }
/* Create a device file node */ /* Create a device file node */
usb_make_path(gtco->usbdev, gtco->usbpath, sizeof(gtco->usbpath)); usb_make_path(udev, gtco->usbpath, sizeof(gtco->usbpath));
strlcat(gtco->usbpath, "/input0", sizeof(gtco->usbpath)); strlcat(gtco->usbpath, "/input0", sizeof(gtco->usbpath));
/* Set Input device functions */ /* Set Input device functions */
...@@ -945,15 +944,15 @@ static int gtco_probe(struct usb_interface *usbinterface, ...@@ -945,15 +944,15 @@ static int gtco_probe(struct usb_interface *usbinterface,
gtco_setup_caps(input_dev); gtco_setup_caps(input_dev);
/* Set input device required ID information */ /* Set input device required ID information */
usb_to_input_id(gtco->usbdev, &input_dev->id); usb_to_input_id(udev, &input_dev->id);
input_dev->dev.parent = &usbinterface->dev; input_dev->dev.parent = &usbinterface->dev;
/* Setup the URB, it will be posted later on open of input device */ /* Setup the URB, it will be posted later on open of input device */
endpoint = &usbinterface->altsetting[0].endpoint[0].desc; endpoint = &usbinterface->altsetting[0].endpoint[0].desc;
usb_fill_int_urb(gtco->urbinfo, usb_fill_int_urb(gtco->urbinfo,
gtco->usbdev, udev,
usb_rcvintpipe(gtco->usbdev, usb_rcvintpipe(udev,
endpoint->bEndpointAddress), endpoint->bEndpointAddress),
gtco->buffer, gtco->buffer,
REPORT_MAX_SIZE, REPORT_MAX_SIZE,
...@@ -977,7 +976,7 @@ static int gtco_probe(struct usb_interface *usbinterface, ...@@ -977,7 +976,7 @@ static int gtco_probe(struct usb_interface *usbinterface,
err_free_urb: err_free_urb:
usb_free_urb(gtco->urbinfo); usb_free_urb(gtco->urbinfo);
err_free_buf: err_free_buf:
usb_free_coherent(gtco->usbdev, REPORT_MAX_SIZE, usb_free_coherent(udev, REPORT_MAX_SIZE,
gtco->buffer, gtco->buf_dma); gtco->buffer, gtco->buf_dma);
err_free_devs: err_free_devs:
input_free_device(input_dev); input_free_device(input_dev);
...@@ -994,13 +993,14 @@ static void gtco_disconnect(struct usb_interface *interface) ...@@ -994,13 +993,14 @@ static void gtco_disconnect(struct usb_interface *interface)
{ {
/* Grab private device ptr */ /* Grab private device ptr */
struct gtco *gtco = usb_get_intfdata(interface); struct gtco *gtco = usb_get_intfdata(interface);
struct usb_device *udev = interface_to_usbdev(interface);
/* Now reverse all the registration stuff */ /* Now reverse all the registration stuff */
if (gtco) { if (gtco) {
input_unregister_device(gtco->inputdevice); input_unregister_device(gtco->inputdevice);
usb_kill_urb(gtco->urbinfo); usb_kill_urb(gtco->urbinfo);
usb_free_urb(gtco->urbinfo); usb_free_urb(gtco->urbinfo);
usb_free_coherent(gtco->usbdev, REPORT_MAX_SIZE, usb_free_coherent(udev, REPORT_MAX_SIZE,
gtco->buffer, gtco->buf_dma); gtco->buffer, gtco->buf_dma);
kfree(gtco); kfree(gtco);
} }
......
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