From e9ef27fa36ee19589c71606f49ce6c953864c4b9 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 1d10d29c115b..21b32e25165f 100644 --- a/drivers/usb/gadget/function/f_hid.c +++ b/drivers/usb/gadget/function/f_hid.c @@ -398,7 +398,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;