Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 21c3ee93 authored by Igor Kotrasinski's avatar Igor Kotrasinski Committed by Felipe Balbi
Browse files

usb: gadget: dummy_hcd: emulate sending zlp in packet logic



currently, when a zlp flag is set and an urb/usb_request
buffer is filled without a short packet, transfer() leaves
its status at -EINPROGRESS and does not rescan for short
packet.

In a scenario where ep.maxpacket bytes are copied,
URB_ZERO_PACKET is set, urb buffer is filled and usb_request
buffer is not, transfer() returns with an urb with
-EINPROGRESS status, which dummy_hcd treats as incomplete
transfer.

Check for zlp and rescan appropriately.

Signed-off-by: default avatarIgor Kotrasinski <i.kotrasinsk@samsung.com>
Signed-off-by: default avatarFelipe Balbi <balbi@ti.com>
parent b8239dcc
Loading
Loading
Loading
Loading
+17 −8
Original line number Diff line number Diff line
@@ -1429,16 +1429,25 @@ static int transfer(struct dummy_hcd *dum_hcd, struct urb *urb,
					req->req.status = 0;
			}

		/* many requests terminate without a short packet */
		/*
		 * many requests terminate without a short packet.
		 * send a zlp if demanded by flags.
		 */
		} else {
			if (req->req.length == req->req.actual
					&& !req->req.zero)
			if (req->req.length == req->req.actual) {
				if (req->req.zero && to_host)
					rescan = 1;
				else
					req->req.status = 0;
			if (urb->transfer_buffer_length == urb->actual_length
					&& !(urb->transfer_flags
						& URB_ZERO_PACKET))
			}
			if (urb->transfer_buffer_length == urb->actual_length) {
				if (urb->transfer_flags & URB_ZERO_PACKET &&
				    !to_host)
					rescan = 1;
				else
					*status = 0;
			}
		}

		/* device side completion --> continuable */
		if (req->req.status != -EINPROGRESS) {