Skip to content

Commit

Permalink
Input: wacom - isolate input registration
Browse files Browse the repository at this point in the history
Although this better co-locates input registration logic,
the main goal is to make it easier to optionally create
input devices or delay creation to later time periods.

Signed-off-by: Chris Bagwell <chris@cnpbagwell.com>
Tested-by: Jason Gerecke <killertofu@gmail.com>
Acked-by: Ping Cheng <pingc@wacom.com>
Signed-off-by: Dmitry Torokhov <dtor@mail.ru>
  • Loading branch information
Chris Bagwell authored and Dmitry Torokhov committed Mar 26, 2012
1 parent 727f9b4 commit 3aac0ef
Showing 1 changed file with 33 additions and 20 deletions.
53 changes: 33 additions & 20 deletions drivers/input/tablet/wacom_sys.c
Original file line number Diff line number Diff line change
Expand Up @@ -822,25 +822,50 @@ static void wacom_destroy_leds(struct wacom *wacom)
}
}

static int wacom_register_input(struct wacom *wacom)
{
struct input_dev *input_dev;
struct usb_interface *intf = wacom->intf;
struct usb_device *dev = interface_to_usbdev(intf);
struct wacom_wac *wacom_wac = &(wacom->wacom_wac);
int error;

input_dev = input_allocate_device();
if (!input_dev)
return -ENOMEM;

input_dev->name = wacom_wac->name;
input_dev->dev.parent = &intf->dev;
input_dev->open = wacom_open;
input_dev->close = wacom_close;
usb_to_input_id(dev, &input_dev->id);
input_set_drvdata(input_dev, wacom);

wacom_wac->input = input_dev;
wacom_setup_input_capabilities(input_dev, wacom_wac);

error = input_register_device(input_dev);
if (error) {
input_free_device(input_dev);
wacom_wac->input = NULL;
}

return error;
}

static int wacom_probe(struct usb_interface *intf, const struct usb_device_id *id)
{
struct usb_device *dev = interface_to_usbdev(intf);
struct usb_endpoint_descriptor *endpoint;
struct wacom *wacom;
struct wacom_wac *wacom_wac;
struct wacom_features *features;
struct input_dev *input_dev;
int error;

if (!id->driver_info)
return -EINVAL;

wacom = kzalloc(sizeof(struct wacom), GFP_KERNEL);
input_dev = input_allocate_device();
if (!wacom || !input_dev) {
error = -ENOMEM;
goto fail1;
}

wacom_wac = &wacom->wacom_wac;
wacom_wac->features = *((struct wacom_features *)id->driver_info);
Expand Down Expand Up @@ -869,8 +894,6 @@ static int wacom_probe(struct usb_interface *intf, const struct usb_device_id *i
usb_make_path(dev, wacom->phys, sizeof(wacom->phys));
strlcat(wacom->phys, "/input0", sizeof(wacom->phys));

wacom_wac->input = input_dev;

endpoint = &intf->cur_altsetting->endpoint[0].desc;

/* Retrieve the physical and logical size for OEM devices */
Expand All @@ -894,15 +917,6 @@ static int wacom_probe(struct usb_interface *intf, const struct usb_device_id *i
goto fail3;
}

input_dev->name = wacom_wac->name;
input_dev->dev.parent = &intf->dev;
input_dev->open = wacom_open;
input_dev->close = wacom_close;
usb_to_input_id(dev, &input_dev->id);
input_set_drvdata(input_dev, wacom);

wacom_setup_input_capabilities(input_dev, wacom_wac);

usb_fill_int_urb(wacom->irq, dev,
usb_rcvintpipe(dev, endpoint->bEndpointAddress),
wacom_wac->data, features->pktlen,
Expand All @@ -914,7 +928,7 @@ static int wacom_probe(struct usb_interface *intf, const struct usb_device_id *i
if (error)
goto fail4;

error = input_register_device(input_dev);
error = wacom_register_input(wacom);
if (error)
goto fail5;

Expand All @@ -928,8 +942,7 @@ static int wacom_probe(struct usb_interface *intf, const struct usb_device_id *i
fail4: wacom_remove_shared_data(wacom_wac);
fail3: usb_free_urb(wacom->irq);
fail2: usb_free_coherent(dev, WACOM_PKGLEN_MAX, wacom_wac->data, wacom->data_dma);
fail1: input_free_device(input_dev);
kfree(wacom);
fail1: kfree(wacom);
return error;
}

Expand Down

0 comments on commit 3aac0ef

Please sign in to comment.