aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChris Bagwell <chris@cnpbagwell.com>2012-03-26 02:25:45 -0400
committerDmitry Torokhov <dmitry.torokhov@gmail.com>2012-03-26 02:31:27 -0400
commit3aac0ef10bf5c76ba4262cfd9b044a6c067d5aae (patch)
treefdfcee90cf5d0306accd9aaf0892ec3d8266e8c3
parent727f9b480754dfcb82e36d431e85984893011b79 (diff)
Input: wacom - isolate input registration
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>
-rw-r--r--drivers/input/tablet/wacom_sys.c53
1 files changed, 33 insertions, 20 deletions
diff --git a/drivers/input/tablet/wacom_sys.c b/drivers/input/tablet/wacom_sys.c
index 39205eddf71..f6da2f8a9c1 100644
--- a/drivers/input/tablet/wacom_sys.c
+++ b/drivers/input/tablet/wacom_sys.c
@@ -822,6 +822,37 @@ static void wacom_destroy_leds(struct wacom *wacom)
822 } 822 }
823} 823}
824 824
825static int wacom_register_input(struct wacom *wacom)
826{
827 struct input_dev *input_dev;
828 struct usb_interface *intf = wacom->intf;
829 struct usb_device *dev = interface_to_usbdev(intf);
830 struct wacom_wac *wacom_wac = &(wacom->wacom_wac);
831 int error;
832
833 input_dev = input_allocate_device();
834 if (!input_dev)
835 return -ENOMEM;
836
837 input_dev->name = wacom_wac->name;
838 input_dev->dev.parent = &intf->dev;
839 input_dev->open = wacom_open;
840 input_dev->close = wacom_close;
841 usb_to_input_id(dev, &input_dev->id);
842 input_set_drvdata(input_dev, wacom);
843
844 wacom_wac->input = input_dev;
845 wacom_setup_input_capabilities(input_dev, wacom_wac);
846
847 error = input_register_device(input_dev);
848 if (error) {
849 input_free_device(input_dev);
850 wacom_wac->input = NULL;
851 }
852
853 return error;
854}
855
825static int wacom_probe(struct usb_interface *intf, const struct usb_device_id *id) 856static int wacom_probe(struct usb_interface *intf, const struct usb_device_id *id)
826{ 857{
827 struct usb_device *dev = interface_to_usbdev(intf); 858 struct usb_device *dev = interface_to_usbdev(intf);
@@ -829,18 +860,12 @@ static int wacom_probe(struct usb_interface *intf, const struct usb_device_id *i
829 struct wacom *wacom; 860 struct wacom *wacom;
830 struct wacom_wac *wacom_wac; 861 struct wacom_wac *wacom_wac;
831 struct wacom_features *features; 862 struct wacom_features *features;
832 struct input_dev *input_dev;
833 int error; 863 int error;
834 864
835 if (!id->driver_info) 865 if (!id->driver_info)
836 return -EINVAL; 866 return -EINVAL;
837 867
838 wacom = kzalloc(sizeof(struct wacom), GFP_KERNEL); 868 wacom = kzalloc(sizeof(struct wacom), GFP_KERNEL);
839 input_dev = input_allocate_device();
840 if (!wacom || !input_dev) {
841 error = -ENOMEM;
842 goto fail1;
843 }
844 869
845 wacom_wac = &wacom->wacom_wac; 870 wacom_wac = &wacom->wacom_wac;
846 wacom_wac->features = *((struct wacom_features *)id->driver_info); 871 wacom_wac->features = *((struct wacom_features *)id->driver_info);
@@ -869,8 +894,6 @@ static int wacom_probe(struct usb_interface *intf, const struct usb_device_id *i
869 usb_make_path(dev, wacom->phys, sizeof(wacom->phys)); 894 usb_make_path(dev, wacom->phys, sizeof(wacom->phys));
870 strlcat(wacom->phys, "/input0", sizeof(wacom->phys)); 895 strlcat(wacom->phys, "/input0", sizeof(wacom->phys));
871 896
872 wacom_wac->input = input_dev;
873
874 endpoint = &intf->cur_altsetting->endpoint[0].desc; 897 endpoint = &intf->cur_altsetting->endpoint[0].desc;
875 898
876 /* Retrieve the physical and logical size for OEM devices */ 899 /* Retrieve the physical and logical size for OEM devices */
@@ -894,15 +917,6 @@ static int wacom_probe(struct usb_interface *intf, const struct usb_device_id *i
894 goto fail3; 917 goto fail3;
895 } 918 }
896 919
897 input_dev->name = wacom_wac->name;
898 input_dev->dev.parent = &intf->dev;
899 input_dev->open = wacom_open;
900 input_dev->close = wacom_close;
901 usb_to_input_id(dev, &input_dev->id);
902 input_set_drvdata(input_dev, wacom);
903
904 wacom_setup_input_capabilities(input_dev, wacom_wac);
905
906 usb_fill_int_urb(wacom->irq, dev, 920 usb_fill_int_urb(wacom->irq, dev,
907 usb_rcvintpipe(dev, endpoint->bEndpointAddress), 921 usb_rcvintpipe(dev, endpoint->bEndpointAddress),
908 wacom_wac->data, features->pktlen, 922 wacom_wac->data, features->pktlen,
@@ -914,7 +928,7 @@ static int wacom_probe(struct usb_interface *intf, const struct usb_device_id *i
914 if (error) 928 if (error)
915 goto fail4; 929 goto fail4;
916 930
917 error = input_register_device(input_dev); 931 error = wacom_register_input(wacom);
918 if (error) 932 if (error)
919 goto fail5; 933 goto fail5;
920 934
@@ -928,8 +942,7 @@ static int wacom_probe(struct usb_interface *intf, const struct usb_device_id *i
928 fail4: wacom_remove_shared_data(wacom_wac); 942 fail4: wacom_remove_shared_data(wacom_wac);
929 fail3: usb_free_urb(wacom->irq); 943 fail3: usb_free_urb(wacom->irq);
930 fail2: usb_free_coherent(dev, WACOM_PKGLEN_MAX, wacom_wac->data, wacom->data_dma); 944 fail2: usb_free_coherent(dev, WACOM_PKGLEN_MAX, wacom_wac->data, wacom->data_dma);
931 fail1: input_free_device(input_dev); 945 fail1: kfree(wacom);
932 kfree(wacom);
933 return error; 946 return error;
934} 947}
935 948