diff options
author | Johan Hovold <johan@kernel.org> | 2018-09-13 05:21:50 -0400 |
---|---|---|
committer | Johan Hovold <johan@kernel.org> | 2018-09-14 04:37:41 -0400 |
commit | 35aecc02b5b621782111f64cbb032c7f6a90bb32 (patch) | |
tree | 5b8b6b47dbdb0497e8636dd72abfff671bd23752 | |
parent | 36cae568404a298a19a6e8a3f18641075d4cab04 (diff) |
USB: serial: option: add two-endpoints device-id flag
Allow matching on interfaces having two endpoints by adding a new
device-id flag.
This allows for the handling of devices whose interface numbers can
change (e.g. Quectel EP06) to be contained in the device-id table.
Tested-by: Kristian Evensen <kristian.evensen@gmail.com>
Cc: stable <stable@vger.kernel.org>
Signed-off-by: Johan Hovold <johan@kernel.org>
-rw-r--r-- | drivers/usb/serial/option.c | 17 |
1 files changed, 7 insertions, 10 deletions
diff --git a/drivers/usb/serial/option.c b/drivers/usb/serial/option.c index 382feafbd127..e72ad9f81c73 100644 --- a/drivers/usb/serial/option.c +++ b/drivers/usb/serial/option.c | |||
@@ -561,6 +561,9 @@ static void option_instat_callback(struct urb *urb); | |||
561 | /* Interface is reserved */ | 561 | /* Interface is reserved */ |
562 | #define RSVD(ifnum) ((BIT(ifnum) & 0xff) << 0) | 562 | #define RSVD(ifnum) ((BIT(ifnum) & 0xff) << 0) |
563 | 563 | ||
564 | /* Interface must have two endpoints */ | ||
565 | #define NUMEP2 BIT(16) | ||
566 | |||
564 | 567 | ||
565 | static const struct usb_device_id option_ids[] = { | 568 | static const struct usb_device_id option_ids[] = { |
566 | { USB_DEVICE(OPTION_VENDOR_ID, OPTION_PRODUCT_COLT) }, | 569 | { USB_DEVICE(OPTION_VENDOR_ID, OPTION_PRODUCT_COLT) }, |
@@ -1082,7 +1085,7 @@ static const struct usb_device_id option_ids[] = { | |||
1082 | { USB_DEVICE(QUECTEL_VENDOR_ID, QUECTEL_PRODUCT_BG96), | 1085 | { USB_DEVICE(QUECTEL_VENDOR_ID, QUECTEL_PRODUCT_BG96), |
1083 | .driver_info = RSVD(4) }, | 1086 | .driver_info = RSVD(4) }, |
1084 | { USB_DEVICE_AND_INTERFACE_INFO(QUECTEL_VENDOR_ID, QUECTEL_PRODUCT_EP06, 0xff, 0xff, 0xff), | 1087 | { USB_DEVICE_AND_INTERFACE_INFO(QUECTEL_VENDOR_ID, QUECTEL_PRODUCT_EP06, 0xff, 0xff, 0xff), |
1085 | .driver_info = RSVD(1) | RSVD(2) | RSVD(3) | RSVD(4) }, | 1088 | .driver_info = RSVD(1) | RSVD(2) | RSVD(3) | RSVD(4) | NUMEP2 }, |
1086 | { USB_DEVICE_AND_INTERFACE_INFO(QUECTEL_VENDOR_ID, QUECTEL_PRODUCT_EP06, 0xff, 0, 0) }, | 1089 | { USB_DEVICE_AND_INTERFACE_INFO(QUECTEL_VENDOR_ID, QUECTEL_PRODUCT_EP06, 0xff, 0, 0) }, |
1087 | { USB_DEVICE(CMOTECH_VENDOR_ID, CMOTECH_PRODUCT_6001) }, | 1090 | { USB_DEVICE(CMOTECH_VENDOR_ID, CMOTECH_PRODUCT_6001) }, |
1088 | { USB_DEVICE(CMOTECH_VENDOR_ID, CMOTECH_PRODUCT_CMU_300) }, | 1091 | { USB_DEVICE(CMOTECH_VENDOR_ID, CMOTECH_PRODUCT_CMU_300) }, |
@@ -1986,7 +1989,6 @@ static int option_probe(struct usb_serial *serial, | |||
1986 | { | 1989 | { |
1987 | struct usb_interface_descriptor *iface_desc = | 1990 | struct usb_interface_descriptor *iface_desc = |
1988 | &serial->interface->cur_altsetting->desc; | 1991 | &serial->interface->cur_altsetting->desc; |
1989 | struct usb_device_descriptor *dev_desc = &serial->dev->descriptor; | ||
1990 | unsigned long device_flags = id->driver_info; | 1992 | unsigned long device_flags = id->driver_info; |
1991 | 1993 | ||
1992 | /* Never bind to the CD-Rom emulation interface */ | 1994 | /* Never bind to the CD-Rom emulation interface */ |
@@ -2002,16 +2004,11 @@ static int option_probe(struct usb_serial *serial, | |||
2002 | return -ENODEV; | 2004 | return -ENODEV; |
2003 | 2005 | ||
2004 | /* | 2006 | /* |
2005 | * Don't bind to the QMI device of the Quectel EP06/EG06/EM06. Class, | 2007 | * Allow matching on bNumEndpoints for devices whose interface numbers |
2006 | * subclass and protocol is 0xff for both the diagnostic port and the | 2008 | * can change (e.g. Quectel EP06). |
2007 | * QMI interface, but the diagnostic port only has two endpoints (QMI | ||
2008 | * has three). | ||
2009 | */ | 2009 | */ |
2010 | if (dev_desc->idVendor == cpu_to_le16(QUECTEL_VENDOR_ID) && | 2010 | if (device_flags & NUMEP2 && iface_desc->bNumEndpoints != 2) |
2011 | dev_desc->idProduct == cpu_to_le16(QUECTEL_PRODUCT_EP06) && | ||
2012 | iface_desc->bInterfaceSubClass && iface_desc->bNumEndpoints == 3) { | ||
2013 | return -ENODEV; | 2011 | return -ENODEV; |
2014 | } | ||
2015 | 2012 | ||
2016 | /* Store the device flags so we can use them during attach. */ | 2013 | /* Store the device flags so we can use them during attach. */ |
2017 | usb_set_serial_data(serial, (void *)device_flags); | 2014 | usb_set_serial_data(serial, (void *)device_flags); |