Commit 2438c3a1 authored by Daniele Palmas's avatar Daniele Palmas Committed by Johan Hovold

USB: serial: option: add ZLP support for 0x1bc7/0x9010

Telit FN980 flashing device 0x1bc7/0x9010 requires zero packet
to be sent if out data size is is equal to the endpoint max size.
Signed-off-by: default avatarDaniele Palmas <dnlplm@gmail.com>
[ johan: switch operands in conditional ]
Cc: stable <stable@vger.kernel.org>
Signed-off-by: default avatarJohan Hovold <johan@kernel.org>
parent 0d3010fa
...@@ -567,6 +567,9 @@ static void option_instat_callback(struct urb *urb); ...@@ -567,6 +567,9 @@ static void option_instat_callback(struct urb *urb);
/* Interface must have two endpoints */ /* Interface must have two endpoints */
#define NUMEP2 BIT(16) #define NUMEP2 BIT(16)
/* Device needs ZLP */
#define ZLP BIT(17)
static const struct usb_device_id option_ids[] = { static const struct usb_device_id option_ids[] = {
{ USB_DEVICE(OPTION_VENDOR_ID, OPTION_PRODUCT_COLT) }, { USB_DEVICE(OPTION_VENDOR_ID, OPTION_PRODUCT_COLT) },
...@@ -1198,6 +1201,8 @@ static const struct usb_device_id option_ids[] = { ...@@ -1198,6 +1201,8 @@ static const struct usb_device_id option_ids[] = {
.driver_info = NCTRL(0) | RSVD(1) }, .driver_info = NCTRL(0) | RSVD(1) },
{ USB_DEVICE_INTERFACE_CLASS(TELIT_VENDOR_ID, 0x1901, 0xff), /* Telit LN940 (MBIM) */ { USB_DEVICE_INTERFACE_CLASS(TELIT_VENDOR_ID, 0x1901, 0xff), /* Telit LN940 (MBIM) */
.driver_info = NCTRL(0) }, .driver_info = NCTRL(0) },
{ USB_DEVICE(TELIT_VENDOR_ID, 0x9010), /* Telit SBL FN980 flashing device */
.driver_info = NCTRL(0) | ZLP },
{ USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, ZTE_PRODUCT_MF622, 0xff, 0xff, 0xff) }, /* ZTE WCDMA products */ { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, ZTE_PRODUCT_MF622, 0xff, 0xff, 0xff) }, /* ZTE WCDMA products */
{ USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0002, 0xff, 0xff, 0xff), { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0002, 0xff, 0xff, 0xff),
.driver_info = RSVD(1) }, .driver_info = RSVD(1) },
...@@ -2099,6 +2104,9 @@ static int option_attach(struct usb_serial *serial) ...@@ -2099,6 +2104,9 @@ static int option_attach(struct usb_serial *serial)
if (!(device_flags & NCTRL(iface_desc->bInterfaceNumber))) if (!(device_flags & NCTRL(iface_desc->bInterfaceNumber)))
data->use_send_setup = 1; data->use_send_setup = 1;
if (device_flags & ZLP)
data->use_zlp = 1;
spin_lock_init(&data->susp_lock); spin_lock_init(&data->susp_lock);
usb_set_serial_data(serial, data); usb_set_serial_data(serial, data);
......
...@@ -38,6 +38,7 @@ struct usb_wwan_intf_private { ...@@ -38,6 +38,7 @@ struct usb_wwan_intf_private {
spinlock_t susp_lock; spinlock_t susp_lock;
unsigned int suspended:1; unsigned int suspended:1;
unsigned int use_send_setup:1; unsigned int use_send_setup:1;
unsigned int use_zlp:1;
int in_flight; int in_flight;
unsigned int open_ports; unsigned int open_ports;
void *private; void *private;
......
...@@ -461,6 +461,7 @@ static struct urb *usb_wwan_setup_urb(struct usb_serial_port *port, ...@@ -461,6 +461,7 @@ static struct urb *usb_wwan_setup_urb(struct usb_serial_port *port,
void (*callback) (struct urb *)) void (*callback) (struct urb *))
{ {
struct usb_serial *serial = port->serial; struct usb_serial *serial = port->serial;
struct usb_wwan_intf_private *intfdata = usb_get_serial_data(serial);
struct urb *urb; struct urb *urb;
urb = usb_alloc_urb(0, GFP_KERNEL); /* No ISO */ urb = usb_alloc_urb(0, GFP_KERNEL); /* No ISO */
...@@ -471,6 +472,9 @@ static struct urb *usb_wwan_setup_urb(struct usb_serial_port *port, ...@@ -471,6 +472,9 @@ static struct urb *usb_wwan_setup_urb(struct usb_serial_port *port,
usb_sndbulkpipe(serial->dev, endpoint) | dir, usb_sndbulkpipe(serial->dev, endpoint) | dir,
buf, len, callback, ctx); buf, len, callback, ctx);
if (intfdata->use_zlp && dir == USB_DIR_OUT)
urb->transfer_flags |= URB_ZERO_PACKET;
return urb; return urb;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment