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

Commit b6d704d6 authored by Anson Jacob's avatar Anson Jacob Committed by John Stultz
Browse files

usb: gadget: f_accessory: Enabled Zero Length Packet (ZLP) for acc_write



Accessory connected to Android Device requires
Zero Length Packet (ZLP) to be written when data
transferred out from the Android device are multiples
of wMaxPacketSize (64bytes (Full-Speed) / 512bytes (High-Speed))
to end the transfer.

Change-Id: Ib2c2c0ab98ef9afa10e74a720142deca5c0ed476
Signed-off-by: default avatarAnson Jacob <ansonkuzhumbil@gmail.com>
parent 43d61e6f
Loading
Loading
Loading
Loading
+9 −2
Original line number Diff line number Diff line
@@ -640,10 +640,17 @@ static ssize_t acc_write(struct file *fp, const char __user *buf,
			break;
		}

		if (count > BULK_BUFFER_SIZE)
		if (count > BULK_BUFFER_SIZE) {
			xfer = BULK_BUFFER_SIZE;
		else
			/* ZLP, They will be more TX requests so not yet. */
			req->zero = 0;
		} else {
			xfer = count;
			/* If the data length is a multple of the
			 * maxpacket size then send a zero length packet(ZLP).
			*/
			req->zero = ((xfer % dev->ep_in->maxpacket) == 0);
		}
		if (copy_from_user(req->buf, buf, xfer)) {
			r = -EFAULT;
			break;