mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
synced 2025-01-12 16:19:53 +00:00
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: Oliver Neukum <oneukum@suse.com> Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
This commit is contained in:
parent
c630901860
commit
ed752e5dde
@ -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)
|
|||||||
{
|
{
|
||||||
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,
|
|||||||
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,
|
|||||||
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, >co->buf_dma);
|
GFP_KERNEL, >co->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,
|
|||||||
|
|
||||||
/* 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,
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* 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,
|
|||||||
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,
|
|||||||
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)
|
|||||||
{
|
{
|
||||||
/* 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);
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user