Skip to contentSkip to conversation

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

PATCH Superseded Daniele Palmas 2 participants 2 messages Dec 6, 2019

Subsystems (2)

v2 of 3 Superseded Latest is v3 →

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 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 equal to the endpoint max size.

---
V2: removed transfer_length calculations

---
 drivers/usb/serial/option.c   | 8 ++++++++
 drivers/usb/serial/usb-wwan.h | 1 +
 drivers/usb/serial/usb_wwan.c | 2 ++
 3 files changed, 11 insertions(+)
drivers/usb/serial/option.c +8 -0
index 06ab016be0b6..f74277c64dbc 100644
@@ -566,6 +566,9 @@ static void option_instat_callback(struct urb *urb);
 /* Interface must have two endpoints */
 #define NUMEP2		BIT(16)
 
+/* Device needs ZLP */
+#define ZLP		BIT(17)
+
 
 static const struct usb_device_id option_ids[] = {
 	{ USB_DEVICE(OPTION_VENDOR_ID, OPTION_PRODUCT_COLT) },
@@ -1193,6 +1196,8 @@ static const struct usb_device_id option_ids[] = {
 	  .driver_info = NCTRL(0) | RSVD(1) },
 	{ USB_DEVICE_INTERFACE_CLASS(TELIT_VENDOR_ID, 0x1901, 0xff),	/* Telit LN940 (MBIM) */
 	  .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, 0x0002, 0xff, 0xff, 0xff),
 	  .driver_info = RSVD(1) },
@@ -2090,6 +2095,9 @@ static int option_attach(struct usb_serial *serial)
 	if (!(device_flags & NCTRL(iface_desc->bInterfaceNumber)))
 		data->use_send_setup = 1;
 
+	if (device_flags & ZLP)
+		data->use_zlp = 1;
+
 	spin_lock_init(&data->susp_lock);
 
 	usb_set_serial_data(serial, data);
drivers/usb/serial/usb-wwan.h +1 -0
index 1c120eaf4091..934e9361cf6b 100644
@@ -38,6 +38,7 @@ struct usb_wwan_intf_private {
 	spinlock_t susp_lock;
 	unsigned int suspended:1;
 	unsigned int use_send_setup:1;
+	unsigned int use_zlp:1;
 	int in_flight;
 	unsigned int open_ports;
 	void *private;
drivers/usb/serial/usb_wwan.c +2 -0
index 7e855c87e4f7..5e5a284a4ba3 100644
@@ -228,6 +228,8 @@ int usb_wwan_write(struct tty_struct *tty, struct usb_serial_port *port,
 		} else {
 			intfdata->in_flight++;
 			spin_unlock_irqrestore(&intfdata->susp_lock, flags);
+			if (intfdata->use_zlp)
+				this_urb->transfer_flags |= URB_ZERO_PACKET;
 			err = usb_submit_urb(this_urb, GFP_ATOMIC);
 			if (err) {
 				dev_err(&port->dev,
Signature · 1 line
2.17.1
maintainer
#1 lore raw
Quoted 24 lines · Daniele Palmas

Telit FN980 flashing device 0x1bc7/0x9010 requires zero packet to be sent if out data size is equal to the endpoint max size.

---
V2: removed transfer_length calculations

drivers/usb/serial/usb-wwan.h +1 -0
index 1c120eaf4091..934e9361cf6b 100644
@@ -38,6 +38,7 @@ struct usb_wwan_intf_private {
 	spinlock_t susp_lock;
 	unsigned int suspended:1;
 	unsigned int use_send_setup:1;
+	unsigned int use_zlp:1;
 	int in_flight;
 	unsigned int open_ports;
 	void *private;
drivers/usb/serial/usb_wwan.c +0 -0
index 7e855c87e4f7..5e5a284a4ba3 100644

drivers/usb/serial/usb_wwan.c int usb_wwan_write(struct tty_struct *tty, struct usb_serial_port *port, · line 232

Quoted 5 lines
drivers/usb/serial/usb_wwan.c +2 -0
@@ -228,6 +228,8 @@ int usb_wwan_write(struct tty_struct *tty, struct usb_serial_port *port,
 		} else {
 			intfdata->in_flight++;
 			spin_unlock_irqrestore(&intfdata->susp_lock, flags);
+			if (intfdata->use_zlp)
+				this_urb->transfer_flags |= URB_ZERO_PACKET;

Just set it once when allocating the URBs at port_probe.

drivers/usb/serial/usb_wwan.c int usb_wwan_write(struct tty_struct *tty, struct usb_serial_port *port, · line 235

Quoted 3 lines
drivers/usb/serial/usb_wwan.c +0 -0
 			err = usb_submit_urb(this_urb, GFP_ATOMIC);
 			if (err) {
 				dev_err(&port->dev,

Johan