aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/usb/input/yealink.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/usb/input/yealink.c')
-rw-r--r--drivers/usb/input/yealink.c48
1 files changed, 20 insertions, 28 deletions
diff --git a/drivers/usb/input/yealink.c b/drivers/usb/input/yealink.c
index 1bfc105ad4d6..37d2f0ba0319 100644
--- a/drivers/usb/input/yealink.c
+++ b/drivers/usb/input/yealink.c
@@ -59,7 +59,7 @@
59#include "map_to_7segment.h" 59#include "map_to_7segment.h"
60#include "yealink.h" 60#include "yealink.h"
61 61
62#define DRIVER_VERSION "yld-20050816" 62#define DRIVER_VERSION "yld-20051230"
63#define DRIVER_AUTHOR "Henk Vergonet" 63#define DRIVER_AUTHOR "Henk Vergonet"
64#define DRIVER_DESC "Yealink phone driver" 64#define DRIVER_DESC "Yealink phone driver"
65 65
@@ -786,16 +786,25 @@ static struct attribute_group yld_attr_group = {
786 * Linux interface and usb initialisation 786 * Linux interface and usb initialisation
787 ******************************************************************************/ 787 ******************************************************************************/
788 788
789static const struct yld_device { 789struct driver_info {
790 u16 idVendor;
791 u16 idProduct;
792 char *name; 790 char *name;
793} yld_device[] = {
794 { 0x6993, 0xb001, "Yealink usb-p1k" },
795}; 791};
796 792
797static struct usb_device_id usb_table [] = { 793static const struct driver_info info_P1K = {
798 { USB_INTERFACE_INFO(USB_CLASS_HID, 0, 0) }, 794 .name = "Yealink usb-p1k",
795};
796
797static const struct usb_device_id usb_table [] = {
798 {
799 .match_flags = USB_DEVICE_ID_MATCH_DEVICE |
800 USB_DEVICE_ID_MATCH_INT_INFO,
801 .idVendor = 0x6993,
802 .idProduct = 0xb001,
803 .bInterfaceClass = USB_CLASS_HID,
804 .bInterfaceSubClass = 0,
805 .bInterfaceProtocol = 0,
806 .driver_info = (kernel_ulong_t)&info_P1K
807 },
799 { } 808 { }
800}; 809};
801 810
@@ -842,33 +851,16 @@ static void usb_disconnect(struct usb_interface *intf)
842 usb_cleanup(yld, 0); 851 usb_cleanup(yld, 0);
843} 852}
844 853
845static int usb_match(struct usb_device *udev)
846{
847 int i;
848 u16 idVendor = le16_to_cpu(udev->descriptor.idVendor);
849 u16 idProduct = le16_to_cpu(udev->descriptor.idProduct);
850
851 for (i = 0; i < ARRAY_SIZE(yld_device); i++) {
852 if ((idVendor == yld_device[i].idVendor) &&
853 (idProduct == yld_device[i].idProduct))
854 return i;
855 }
856 return -ENODEV;
857}
858
859static int usb_probe(struct usb_interface *intf, const struct usb_device_id *id) 854static int usb_probe(struct usb_interface *intf, const struct usb_device_id *id)
860{ 855{
861 struct usb_device *udev = interface_to_usbdev (intf); 856 struct usb_device *udev = interface_to_usbdev (intf);
857 struct driver_info *nfo = (struct driver_info *)id->driver_info;
862 struct usb_host_interface *interface; 858 struct usb_host_interface *interface;
863 struct usb_endpoint_descriptor *endpoint; 859 struct usb_endpoint_descriptor *endpoint;
864 struct yealink_dev *yld; 860 struct yealink_dev *yld;
865 struct input_dev *input_dev; 861 struct input_dev *input_dev;
866 int ret, pipe, i; 862 int ret, pipe, i;
867 863
868 i = usb_match(udev);
869 if (i < 0)
870 return -ENODEV;
871
872 interface = intf->cur_altsetting; 864 interface = intf->cur_altsetting;
873 endpoint = &interface->endpoint[0].desc; 865 endpoint = &interface->endpoint[0].desc;
874 if (!(endpoint->bEndpointAddress & USB_DIR_IN)) 866 if (!(endpoint->bEndpointAddress & USB_DIR_IN))
@@ -915,7 +907,7 @@ static int usb_probe(struct usb_interface *intf, const struct usb_device_id *id)
915 pipe = usb_rcvintpipe(udev, endpoint->bEndpointAddress); 907 pipe = usb_rcvintpipe(udev, endpoint->bEndpointAddress);
916 ret = usb_maxpacket(udev, pipe, usb_pipeout(pipe)); 908 ret = usb_maxpacket(udev, pipe, usb_pipeout(pipe));
917 if (ret != USB_PKT_LEN) 909 if (ret != USB_PKT_LEN)
918 err("invalid payload size %d, expected %d", ret, USB_PKT_LEN); 910 err("invalid payload size %d, expected %zd", ret, USB_PKT_LEN);
919 911
920 /* initialise irq urb */ 912 /* initialise irq urb */
921 usb_fill_int_urb(yld->urb_irq, udev, pipe, yld->irq_data, 913 usb_fill_int_urb(yld->urb_irq, udev, pipe, yld->irq_data,
@@ -948,7 +940,7 @@ static int usb_probe(struct usb_interface *intf, const struct usb_device_id *id)
948 strlcat(yld->phys, "/input0", sizeof(yld->phys)); 940 strlcat(yld->phys, "/input0", sizeof(yld->phys));
949 941
950 /* register settings for the input device */ 942 /* register settings for the input device */
951 input_dev->name = yld_device[i].name; 943 input_dev->name = nfo->name;
952 input_dev->phys = yld->phys; 944 input_dev->phys = yld->phys;
953 usb_to_input_id(udev, &input_dev->id); 945 usb_to_input_id(udev, &input_dev->id);
954 input_dev->cdev.dev = &intf->dev; 946 input_dev->cdev.dev = &intf->dev;