Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

USB: serial: option: improve Quectel EP06 detection

The Quectel EP06 (and EM06/EG06) LTE modem supports updating the USB
configuration, without the VID/PID or configuration number changing.
When the configuration is updated and interfaces are added/removed, the
interface numbers are updated. This causes our current code for matching
EP06 not to work as intended, as the assumption about reserved
interfaces no longer holds. If for example the diagnostic (first)
interface is removed, option will (try to) bind to the QMI interface.

This patch improves EP06 detection by replacing the current match with
two matches, and those matches check class, subclass and protocol as
well as VID and PID. The diag interface exports class, subclass and
protocol as 0xff. For the other serial interfaces, class is 0xff and
subclass and protocol are both 0x0.

The modem can export the following devices and always in this order:
diag, nmea, at, ppp. qmi and adb. This means that diag can only ever be
interface 0, and interface numbers 1-5 should be marked as reserved. The
three other serial devices can have interface numbers 0-3, but I have
not marked any interfaces as reserved. The reason is that the serial
devices are the only interfaces exported by the device where subclass
and protocol is 0x0.

QMI exports the same class, subclass and protocol values as the diag
interface. However, the two interfaces have different number of
endpoints, QMI has three and diag two. I have added a check for number
of interfaces if VID/PID matches the EP06, and we ignore the device if
number of interfaces equals three (and subclass is set).

Signed-off-by: Kristian Evensen <kristian.evensen@gmail.com>
Acked-by: Dan Williams <dcbw@redhat.com>
[ johan: drop uneeded RSVD(5) for ADB ]
Cc: stable <stable@vger.kernel.org>
Signed-off-by: Johan Hovold <johan@kernel.org>

authored by

Kristian Evensen and committed by
Johan Hovold
36cae568 5dfdd24e

+16 -2
+16 -2
drivers/usb/serial/option.c
··· 1081 1081 .driver_info = RSVD(4) }, 1082 1082 { USB_DEVICE(QUECTEL_VENDOR_ID, QUECTEL_PRODUCT_BG96), 1083 1083 .driver_info = RSVD(4) }, 1084 - { USB_DEVICE(QUECTEL_VENDOR_ID, QUECTEL_PRODUCT_EP06), 1085 - .driver_info = RSVD(4) | RSVD(5) }, 1084 + { 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) }, 1086 + { USB_DEVICE_AND_INTERFACE_INFO(QUECTEL_VENDOR_ID, QUECTEL_PRODUCT_EP06, 0xff, 0, 0) }, 1086 1087 { USB_DEVICE(CMOTECH_VENDOR_ID, CMOTECH_PRODUCT_6001) }, 1087 1088 { USB_DEVICE(CMOTECH_VENDOR_ID, CMOTECH_PRODUCT_CMU_300) }, 1088 1089 { USB_DEVICE(CMOTECH_VENDOR_ID, CMOTECH_PRODUCT_6003), ··· 1986 1985 { 1987 1986 struct usb_interface_descriptor *iface_desc = 1988 1987 &serial->interface->cur_altsetting->desc; 1988 + struct usb_device_descriptor *dev_desc = &serial->dev->descriptor; 1989 1989 unsigned long device_flags = id->driver_info; 1990 1990 1991 1991 /* Never bind to the CD-Rom emulation interface */ ··· 2000 1998 */ 2001 1999 if (device_flags & RSVD(iface_desc->bInterfaceNumber)) 2002 2000 return -ENODEV; 2001 + 2002 + /* 2003 + * Don't bind to the QMI device of the Quectel EP06/EG06/EM06. Class, 2004 + * subclass and protocol is 0xff for both the diagnostic port and the 2005 + * QMI interface, but the diagnostic port only has two endpoints (QMI 2006 + * has three). 2007 + */ 2008 + if (dev_desc->idVendor == cpu_to_le16(QUECTEL_VENDOR_ID) && 2009 + dev_desc->idProduct == cpu_to_le16(QUECTEL_PRODUCT_EP06) && 2010 + iface_desc->bInterfaceSubClass && iface_desc->bNumEndpoints == 3) { 2011 + return -ENODEV; 2012 + } 2003 2013 2004 2014 /* Store the device flags so we can use them during attach. */ 2005 2015 usb_set_serial_data(serial, (void *)device_flags);