From 0bf324da22d947baab4a05d33107fe5f0b3f9f65 Mon Sep 17 00:00:00 2001 From: William Wu Date: Mon, 29 Apr 2024 11:22:24 +0800 Subject: [PATCH] usb: gadget: f_hid: fix zero length packet transfer for ep0 If the hid transfer with size divisible to EP0 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: Iae8c06966efe49c3a33213f9c36dd752633e8bd1 --- 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 35987d4619fe..034ea7fb8b9c 100644 --- a/drivers/usb/gadget/function/f_hid.c +++ b/drivers/usb/gadget/function/f_hid.c @@ -760,7 +760,7 @@ stall: return -EOPNOTSUPP; respond: - req->zero = 0; + req->zero = ((length % cdev->gadget->ep0->maxpacket) == 0); req->length = length; status = usb_ep_queue(cdev->gadget->ep0, req, GFP_ATOMIC); if (status < 0)