[PATCH v2 3/5] usb: gadget: dummy_hcd: round down transfer when over frame limit

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



When close to transfer limit for a frame, transfer() decreases
data length to send to limit. This can cause an erroneous short
packet transfer to be simulated.

Rework transfer logic to decrease data to tranfer to multiple of
maxpacket.

Signed-off-by: Igor Kotrasinski <i.kotrasinsk@xxxxxxxxxxx>
---
 drivers/usb/gadget/udc/dummy_hcd.c | 12 ++++++++----
 1 file changed, 8 insertions(+), 4 deletions(-)

diff --git a/drivers/usb/gadget/udc/dummy_hcd.c b/drivers/usb/gadget/udc/dummy_hcd.c
index 183e368..552c533 100644
--- a/drivers/usb/gadget/udc/dummy_hcd.c
+++ b/drivers/usb/gadget/udc/dummy_hcd.c
@@ -1313,10 +1313,14 @@ top:
 		if (unlikely(len == 0))
 			is_short = 1;
 		else {
-			/* not enough bandwidth left? */
-			if (limit < ep->ep.maxpacket && limit < len)
-				break;
-			len = min_t(unsigned, len, limit);
+			/* not enough bandwidth left?
+			 * only send multiple of maxpacket to avoid
+			 * unwarranted short packet.
+			 */
+			if (limit < len) {
+				len = limit;
+				len -= (len % ep->ep.maxpacket);
+			}
 			if (len == 0)
 				break;
 
-- 
1.9.1

--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html



[Index of Archives]     [Linux Media]     [Linux Input]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [Old Linux USB Devel Archive]

  Powered by Linux