Commit 8e2ce4f9 authored by Henk's avatar Henk Committed by Greg Kroah-Hartman

[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: default avatarHenk Vergonet <henk.vergonet@gmail.com>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@suse.de>
parent 09c280a2
...@@ -59,7 +59,7 @@ ...@@ -59,7 +59,7 @@
#include "map_to_7segment.h" #include "map_to_7segment.h"
#include "yealink.h" #include "yealink.h"
#define DRIVER_VERSION "yld-20050816" #define DRIVER_VERSION "yld-20051230"
#define DRIVER_AUTHOR "Henk Vergonet" #define DRIVER_AUTHOR "Henk Vergonet"
#define DRIVER_DESC "Yealink phone driver" #define DRIVER_DESC "Yealink phone driver"
...@@ -786,16 +786,25 @@ static struct attribute_group yld_attr_group = { ...@@ -786,16 +786,25 @@ static struct attribute_group yld_attr_group = {
* Linux interface and usb initialisation * Linux interface and usb initialisation
******************************************************************************/ ******************************************************************************/
static const struct yld_device { struct driver_info {
u16 idVendor;
u16 idProduct;
char *name; char *name;
} yld_device[] = {
{ 0x6993, 0xb001, "Yealink usb-p1k" },
}; };
static struct usb_device_id usb_table [] = { static const struct driver_info info_P1K = {
{ USB_INTERFACE_INFO(USB_CLASS_HID, 0, 0) }, .name = "Yealink usb-p1k",
};
static const struct usb_device_id usb_table [] = {
{
.match_flags = USB_DEVICE_ID_MATCH_DEVICE |
USB_DEVICE_ID_MATCH_INT_INFO,
.idVendor = 0x6993,
.idProduct = 0xb001,
.bInterfaceClass = USB_CLASS_HID,
.bInterfaceSubClass = 0,
.bInterfaceProtocol = 0,
.driver_info = (kernel_ulong_t)&info_P1K
},
{ } { }
}; };
...@@ -842,33 +851,16 @@ static void usb_disconnect(struct usb_interface *intf) ...@@ -842,33 +851,16 @@ static void usb_disconnect(struct usb_interface *intf)
usb_cleanup(yld, 0); usb_cleanup(yld, 0);
} }
static int usb_match(struct usb_device *udev)
{
int i;
u16 idVendor = le16_to_cpu(udev->descriptor.idVendor);
u16 idProduct = le16_to_cpu(udev->descriptor.idProduct);
for (i = 0; i < ARRAY_SIZE(yld_device); i++) {
if ((idVendor == yld_device[i].idVendor) &&
(idProduct == yld_device[i].idProduct))
return i;
}
return -ENODEV;
}
static int usb_probe(struct usb_interface *intf, const struct usb_device_id *id) static int usb_probe(struct usb_interface *intf, const struct usb_device_id *id)
{ {
struct usb_device *udev = interface_to_usbdev (intf); struct usb_device *udev = interface_to_usbdev (intf);
struct driver_info *nfo = (struct driver_info *)id->driver_info;
struct usb_host_interface *interface; struct usb_host_interface *interface;
struct usb_endpoint_descriptor *endpoint; struct usb_endpoint_descriptor *endpoint;
struct yealink_dev *yld; struct yealink_dev *yld;
struct input_dev *input_dev; struct input_dev *input_dev;
int ret, pipe, i; int ret, pipe, i;
i = usb_match(udev);
if (i < 0)
return -ENODEV;
interface = intf->cur_altsetting; interface = intf->cur_altsetting;
endpoint = &interface->endpoint[0].desc; endpoint = &interface->endpoint[0].desc;
if (!(endpoint->bEndpointAddress & USB_DIR_IN)) 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,7 +940,7 @@ static int usb_probe(struct usb_interface *intf, const struct usb_device_id *id)
strlcat(yld->phys, "/input0", sizeof(yld->phys)); strlcat(yld->phys, "/input0", sizeof(yld->phys));
/* register settings for the input device */ /* register settings for the input device */
input_dev->name = yld_device[i].name; input_dev->name = nfo->name;
input_dev->phys = yld->phys; input_dev->phys = yld->phys;
usb_to_input_id(udev, &input_dev->id); usb_to_input_id(udev, &input_dev->id);
input_dev->cdev.dev = &intf->dev; input_dev->cdev.dev = &intf->dev;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment