From 0ca707d0053efcab34b690b0ed616b1f4d4b2f13 Mon Sep 17 00:00:00 2001 From: William Wu Date: Mon, 24 Jan 2022 20:35:32 +0800 Subject: [PATCH] usb: gadget: f_hid: fix zero length packet transfer If the hid transfer with size divisible to EPs max packet size, it needs to set the req->zero to true, then the usb controller can transfer a zero length packet at the end according to the USB 2.0 spec. Signed-off-by: William Wu Change-Id: Ia63060b4551d30821beaf494c1ccd7dfb3b6ca22 --- drivers/usb/gadget/function/f_hid.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/usb/gadget/function/f_hid.c b/drivers/usb/gadget/function/f_hid.c index 6be6009f911e..35987d4619fe 100644 --- a/drivers/usb/gadget/function/f_hid.c +++ b/drivers/usb/gadget/function/f_hid.c @@ -489,7 +489,7 @@ try_again: } req->status = 0; - req->zero = 0; + req->zero = ((count % hidg->in_ep->maxpacket) == 0); req->length = count; req->complete = f_hidg_req_complete; req->context = hidg;