提交 c33a20b7 编写于 作者: C Chris Rorvick 提交者: Takashi Iwai

staging: line6: Index properties array with device type

The current logic uses the index of the matched entry from the device
table as an offset to the corresponding properties entry.  The values
of the new `line6_device_type' enum are ordered such that they can be
used as an index into either of these arrays.  Drop the device entry
lookup logic and use the device type (via the .driver_info member)
instead.
Signed-off-by: NChris Rorvick <chris@rorvick.com>
Reviewed-by: NStefan Hajnoczi <stefanha@gmail.com>
Signed-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: NTakashi Iwai <tiwai@suse.de>
上级 410dca8d
......@@ -624,7 +624,7 @@ static void line6_destruct(struct usb_interface *interface)
static int line6_probe(struct usb_interface *interface,
const struct usb_device_id *id)
{
int devtype;
enum line6_device_type devtype;
struct usb_device *usbdev;
struct usb_line6 *line6;
const struct line6_properties *properties;
......@@ -646,20 +646,7 @@ static int line6_probe(struct usb_interface *interface,
goto err_put;
}
/* check vendor and product id */
for (devtype = ARRAY_SIZE(line6_id_table) - 1; devtype--;) {
u16 idVendor = le16_to_cpu(usbdev->descriptor.idVendor);
u16 idProduct = le16_to_cpu(usbdev->descriptor.idProduct);
if (idVendor == line6_id_table[devtype].idVendor &&
idProduct == line6_id_table[devtype].idProduct)
break;
}
if (devtype < 0) {
ret = -ENODEV;
goto err_put;
}
devtype = id->driver_info;
/* initialize device info: */
properties = &line6_properties_table[devtype];
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册