usb: ks_bridge: Check for received data upon unlinking the urb
There is a possibility of runtime suspend in the middle of
data transfer on the rx data path of driver. This results in
the completion of data transfer on bulk IN endpoint with short
packet or integral multiple of 512 bytes. Hence for -ENOENT
transfer status check for non-zero data length and pass it to
the consumer in the userspace. Also, replace printk with
DBG-level message in driver suspend function and in rx
callback function for -EPROTO urb status.
Change-Id: Id7f9602e61e98f5bbd38c2f2f8121616b5661591
CRs-Fixed: 394954
Signed-off-by: Hemant Kumar <hemantk@codeaurora.org>
Signed-off-by: Neha Pandey <nehap@codeaurora.org>
diff --git a/drivers/usb/misc/ks_bridge.c b/drivers/usb/misc/ks_bridge.c
index d317e8f..7e1bf1e 100644
--- a/drivers/usb/misc/ks_bridge.c
+++ b/drivers/usb/misc/ks_bridge.c
@@ -440,8 +440,13 @@
pr_debug("status:%d actual:%d", urb->status, urb->actual_length);
+ /*non zero len of data received while unlinking urb*/
+ if (urb->status == -ENOENT && urb->actual_length > 0)
+ goto add_to_list;
+
if (urb->status < 0) {
- if (urb->status != -ESHUTDOWN && urb->status != -ENOENT)
+ if (urb->status != -ESHUTDOWN && urb->status != -ENOENT
+ && urb->status != -EPROTO)
pr_err_ratelimited("urb failed with err:%d",
urb->status);
ksb_free_data_pkt(pkt);
@@ -455,6 +460,7 @@
goto resubmit_urb;
}
+add_to_list:
spin_lock(&ksb->lock);
pkt->len = urb->actual_length;
list_add_tail(&pkt->list, &ksb->to_ks_list);
@@ -602,7 +608,7 @@
dbg_log_event(ksb, "SUSPEND", 0, 0);
- pr_info("read cnt: %d", ksb->alloced_read_pkts);
+ pr_debug("read cnt: %d", ksb->alloced_read_pkts);
usb_kill_anchored_urbs(&ksb->submitted);