From 75c18f725bbb21c65e4b6ccadcbe1bead4ffd818 Mon Sep 17 00:00:00 2001 From: yan Date: Mon, 20 Jul 2020 10:53:37 +0800 Subject: [PATCH] Add HUAWEI ME906s LTE Module support Signed-off-by: yan --- drivers/usb/serial/option.c | 7 +++++++ drivers/usb/serial/usb_wwan.c | 13 +++++++++++++ 2 files changed, 20 insertions(+) diff --git a/drivers/usb/serial/option.c b/drivers/usb/serial/option.c index 07aab4b..27be746 100644 --- a/drivers/usb/serial/option.c +++ b/drivers/usb/serial/option.c @@ -971,6 +971,7 @@ static const struct usb_device_id option_ids[] = { { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x06, 0x7A) }, { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x06, 0x7B) }, { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x06, 0x7C) }, + { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x06, 0x7C) }, /* Motorola devices */ { USB_DEVICE_AND_INTERFACE_INFO(0x22b8, 0x2a70, 0xff, 0xff, 0xff) }, /* mdm6600 */ @@ -2113,6 +2114,12 @@ static int option_attach(struct usb_serial *serial) struct usb_wwan_intf_private *data; unsigned long device_flags; + if (serial->dev->descriptor.idVendor == HUAWEI_VENDOR_ID) { + if ( 0 != (serial->dev->config->desc.bmAttributes & 0x20)){ + usb_enable_autosuspend(serial->dev); + } + } + data = kzalloc(sizeof(struct usb_wwan_intf_private), GFP_KERNEL); if (!data) return -ENOMEM; diff --git a/drivers/usb/serial/usb_wwan.c b/drivers/usb/serial/usb_wwan.c index 4569a8a..10c5e55 100644 --- a/drivers/usb/serial/usb_wwan.c +++ b/drivers/usb/serial/usb_wwan.c @@ -36,6 +36,9 @@ #include #include "usb-wwan.h" +#define HW_bcdUSB 0x0110 +#define HUAWEI_VENDOR_ID 0x12d1 + /* * Generate DTR/RTS signals on the port using the SET_CONTROL_LINE_STATE request * in CDC ACM. @@ -217,6 +220,7 @@ int usb_wwan_write(struct tty_struct *tty, struct usb_serial_port *port, { struct usb_wwan_port_private *portdata; struct usb_wwan_intf_private *intfdata; + struct usb_host_endpoint *ep; int i; int left, todo; struct urb *this_urb = NULL; /* spurious */ @@ -256,6 +260,15 @@ int usb_wwan_write(struct tty_struct *tty, struct usb_serial_port *port, memcpy(this_urb->transfer_buffer, buf, todo); this_urb->transfer_buffer_length = todo; + if((HUAWEI_VENDOR_ID == port->serial->dev->descriptor.idVendor) + && (HW_bcdUSB != port->serial->dev->descriptor.bcdUSB)){ + ep = usb_pipe_endpoint(this_urb->dev, this_urb->pipe); + if(ep && (0 != this_urb->transfer_buffer_length) + && (0 == this_urb->transfer_buffer_length % ep->desc.wMaxPacketSize)){ + this_urb->transfer_flags |= URB_ZERO_PACKET; + } + } + spin_lock_irqsave(&intfdata->susp_lock, flags); if (intfdata->suspended) { usb_anchor_urb(this_urb, &portdata->delayed); -- 2.7.4