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 <william.wu@rock-chips.com>
Change-Id: Iae8c06966efe49c3a33213f9c36dd752633e8bd1
This commit is contained in:
William Wu 2024-04-29 11:22:24 +08:00 committed by Tao Huang
commit 0bf324da22

View file

@ -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)