summaryrefslogtreecommitdiffstats
path: root/drivers/usb/serial/xr_serial.c
diff options
context:
space:
mode:
authorJohan Hovold <johan@kernel.org>2021-03-30 16:38:20 +0200
committerJohan Hovold <johan@kernel.org>2021-04-01 10:04:21 +0200
commit5fec21e74bfc1db764fdab013162d839cc889290 (patch)
treee25318e15e9b93d71cf7e02330642b98788eee54 /drivers/usb/serial/xr_serial.c
parent5de03c99691d5b0b6253fda1d1d3bbc8239aadb8 (diff)
downloadlinux-5fec21e74bfc1db764fdab013162d839cc889290.tar.bz2
USB: serial: xr: claim both interfaces
Use the new multi-interface support in USB serial core to properly claim also the control interface during probe. This prevents having another driver claim the control interface and makes core allocate resources also for the interrupt endpoint (currently unused). Switch to probing only Communication Class interfaces and use the Union functional descriptor to determine the corresponding data interface. Reviewed-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org> Signed-off-by: Johan Hovold <johan@kernel.org>
Diffstat (limited to 'drivers/usb/serial/xr_serial.c')
-rw-r--r--drivers/usb/serial/xr_serial.c26
1 files changed, 23 insertions, 3 deletions
diff --git a/drivers/usb/serial/xr_serial.c b/drivers/usb/serial/xr_serial.c
index c59c8b47a120..88c73f88cb26 100644
--- a/drivers/usb/serial/xr_serial.c
+++ b/drivers/usb/serial/xr_serial.c
@@ -16,6 +16,7 @@
#include <linux/slab.h>
#include <linux/tty.h>
#include <linux/usb.h>
+#include <linux/usb/cdc.h>
#include <linux/usb/serial.h>
struct xr_txrx_clk_mask {
@@ -550,15 +551,34 @@ static void xr_close(struct usb_serial_port *port)
static int xr_probe(struct usb_serial *serial, const struct usb_device_id *id)
{
- /* Don't bind to control interface */
- if (serial->interface->cur_altsetting->desc.bInterfaceNumber == 0)
+ struct usb_interface *control = serial->interface;
+ struct usb_host_interface *alt = control->cur_altsetting;
+ struct usb_cdc_parsed_header hdrs;
+ struct usb_cdc_union_desc *desc;
+ struct usb_interface *data;
+ int ret;
+
+ ret = cdc_parse_cdc_header(&hdrs, control, alt->extra, alt->extralen);
+ if (ret < 0)
return -ENODEV;
+ desc = hdrs.usb_cdc_union_desc;
+ if (!desc)
+ return -ENODEV;
+
+ data = usb_ifnum_to_if(serial->dev, desc->bSlaveInterface0);
+ if (!data)
+ return -ENODEV;
+
+ ret = usb_serial_claim_interface(serial, data);
+ if (ret)
+ return ret;
+
return 0;
}
static const struct usb_device_id id_table[] = {
- { USB_DEVICE(0x04e2, 0x1410) }, /* XR21V141X */
+ { USB_DEVICE_INTERFACE_CLASS(0x04e2, 0x1410, USB_CLASS_COMM) }, /* XR21V141X */
{ }
};
MODULE_DEVICE_TABLE(usb, id_table);