diff options
author | Henk <Henk.Vergonet@gmail.com> | 2005-12-30 13:41:11 -0500 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@suse.de> | 2006-01-31 20:23:37 -0500 |
commit | 8e2ce4f92a0f34e8c3316ec58fd6eb6aa282448e (patch) | |
tree | cbb996b43ecc036d69d32bbdcf61e607c9dc676f /drivers/usb/input/yealink.c | |
parent | 09c280a24650ff74e713742e94120fdf7765cda8 (diff) |
[PATCH] drivers/usb/input/yealink.c: Cleanup device matching code
This should fix things mentioned below:
"I was curious why my firewall was loading a 'phone driver'.
It turns out that the probing in the yealink driver is
a little too assuming..
static struct usb_device_id usb_table [] = {
{ USB_INTERFACE_INFO(USB_CLASS_HID, 0, 0) },
{ }
};
So it picked up my UPS, and loaded the driver.
Whilst no harm came, because it later checks the vendor/product IDs,
this driver should probably be rewritten to only probe
for the device IDs it actually knows about.
Dave"
Signed-off-by: Henk Vergonet <henk.vergonet@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
Diffstat (limited to 'drivers/usb/input/yealink.c')
-rw-r--r-- | drivers/usb/input/yealink.c | 46 |
1 files changed, 19 insertions, 27 deletions
diff --git a/drivers/usb/input/yealink.c b/drivers/usb/input/yealink.c index 1bfc105ad4d6..067be34b4241 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 | ||
789 | static const struct yld_device { | 789 | struct 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 | ||
797 | static struct usb_device_id usb_table [] = { | 793 | static const struct driver_info info_P1K = { |
798 | { USB_INTERFACE_INFO(USB_CLASS_HID, 0, 0) }, | 794 | .name = "Yealink usb-p1k", |
795 | }; | ||
796 | |||
797 | static 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 | ||
845 | static 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 | |||
859 | static int usb_probe(struct usb_interface *intf, const struct usb_device_id *id) | 854 | static 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)) |
@@ -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; |