Skip to content

Commit bf810cf

Browse files
DextersHubtoddpoynor
authored andcommitted
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: Anson Jacob <ansonkuzhumbil@gmail.com>
1 parent a079459 commit bf810cf

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

drivers/usb/gadget/f_accessory.c

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -638,10 +638,17 @@ static ssize_t acc_write(struct file *fp, const char __user *buf,
638638
break;
639639
}
640640

641-
if (count > BULK_BUFFER_SIZE)
641+
if (count > BULK_BUFFER_SIZE) {
642642
xfer = BULK_BUFFER_SIZE;
643-
else
643+
/* ZLP, They will be more TX requests so not yet. */
644+
req->zero = 0;
645+
} else {
644646
xfer = count;
647+
/* If the data length is a multple of the
648+
* maxpacket size then send a zero length packet(ZLP).
649+
*/
650+
req->zero = ((xfer % dev->ep_in->maxpacket) == 0);
651+
}
645652
if (copy_from_user(req->buf, buf, xfer)) {
646653
r = -EFAULT;
647654
break;

0 commit comments

Comments
 (0)