usb: serial: option: add ZLP support for 0x1bc7/0x9010
Subsystems (2)
PATCH 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.
--- drivers/usb/serial/option.c | 8 ++++++++ drivers/usb/serial/usb-wwan.h | 1 + drivers/usb/serial/usb_wwan.c | 9 +++++++++ 3 files changed, 18 insertions(+)
drivers/usb/serial/option.c +8 -0
@@ -565,6 +565,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 ) },
@@ -1184,6 +1187,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) },
@@ -2079,6 +2084,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
@@ -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 +9 -0
@@ -228,6 +228,15 @@ 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) { +unsigned int ep_maxp; + + ep_maxp =usb_maxpacket (port->serial->dev, + this_urb->pipe,1 ); + +if (ep_maxp && (todo % ep_maxp ==0 )) + 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
Hello Johan,
Il giorno ven 20 set 2019 alle ore 12:24 Daniele Palmas <[email protected]> ha scritto:
Quoted 5 lines
Telit FN980 flashing device 0x1bc7/0x9010 requires zero packet to be sent if out data size is equal to the endpoint max size.
Signed-off-by Daniele Palmas <[email protected]>
should I resend this one or is there a problem with the patch?
Thanks,
Daniele
Quoted 74 lines
--- drivers/usb/serial/option.c | 8 ++++++++ drivers/usb/serial/usb-wwan.h | 1 + drivers/usb/serial/usb_wwan.c | 9 +++++++++ 3 files changed, 18 insertions(+)drivers/usb/serial/option.c +8
-0@@ -565,6 +565,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 ) },@@ -1184,6 +1187,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) },@@ -2079,6 +2084,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@@ -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 +9
-1@@ -228,6 +228,15 @@ 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) { +unsigned int ep_maxp; + + ep_maxp =usb_maxpacket (port->serial->dev, + this_urb->pipe,1 ); + +if (ep_maxp && (todo % ep_maxp ==0 )) + this_urb->transfer_flags |=URB_ZERO_PACKET ; + } err =usb_submit_urb (this_urb,GFP_ATOMIC );if (err) { dev_err(&port->dev, --2.17.1
Johan Hovold
maintainerHi Daniele,
Quoted 11 lines · Daniele Palmas
Hello Johan,
Il giorno ven 20 set 2019 alle ore 12:24 Daniele Palmas <[email protected]> ha scritto:
Quoted 5 lines
Telit FN980 flashing device 0x1bc7/0x9010 requires zero packet to be sent if out data size is equal to the endpoint max size.
Signed-off-by Daniele Palmas <[email protected]>should I resend this one or is there a problem with the patch?
This is the first time I see this one. Must have gotten stuck in a spam filter or something. Sorry about that.
Would you mind resending, and I'll take a look?
Johan
Il giorno ven 15 nov 2019 alle ore 12:29 Johan Hovold <[email protected]> ha scritto:
Quoted 12 lines
Hi Daniele,
Quoted 8 lines · Daniele Palmas
Hello Johan,
Il giorno ven 20 set 2019 alle ore 12:24 Daniele Palmas <[email protected]> ha scritto:
Quoted 4 lines
Telit FN980 flashing device 0x1bc7/0x9010 requires zero packet to be sent if out data size is equal to the endpoint max size.
Quoted 9 lines
Quoted 3 lines
Quoted 1 line
Signed-off-by Daniele Palmas <[email protected]>should I resend this one or is there a problem with the patch?
This is the first time I see this one. Must have gotten stuck in a spam filter or something. Sorry about that.
Would you mind resending, and I'll take a look?
Sure, I'll do.
Thanks,
Daniele
Quoted 1 line
Johan