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

Commit b1d2d56c authored by Macpaul Lin's avatar Macpaul Lin Committed by Giuliano Procida
Browse files

ANDROID: usb: gadget: f_accessory: fix CTS test stuck



f_accessory: fix CTS test stuck since CTS 9.0.
 - Refine acc_read() process.

The data length that user (test program) wants to read is different
from they really requested. This will cause the test flow stuck on the
2nd or the 3rd transfers in accessory test.
(By connecting 2 phones with CtsVerifier.apk and
CtsVerifierUSBCompanion.apk installed.)

Bug: 174729307

Change-Id: I5367c8075ed37534e8bed94b60cc79135ae5aebc
Signed-off-by: default avatarMacpaul Lin <macpaul.lin@mediatek.com>
Signed-off-by: default avatarGiuliano Procida <gprocida@google.com>
parent ee532e86
Loading
Loading
Loading
Loading
+11 −1
Original line number Diff line number Diff line
@@ -568,6 +568,7 @@ static ssize_t acc_read(struct file *fp, char __user *buf,
	struct acc_dev *dev = fp->private_data;
	struct usb_request *req;
	ssize_t r = count;
	ssize_t data_length;
	unsigned xfer;
	int ret = 0;

@@ -589,6 +590,15 @@ static ssize_t acc_read(struct file *fp, char __user *buf,
		goto done;
	}

	/*
	 * Calculate the data length by considering termination character.
	 * Then compansite the difference of rounding up to
	 * integer multiple of maxpacket size.
	 */
	data_length = count;
	data_length += dev->ep_out->maxpacket - 1;
	data_length -= data_length % dev->ep_out->maxpacket;

	if (dev->rx_done) {
		// last req cancelled. try to get it.
		req = dev->rx_req[0];
@@ -598,7 +608,7 @@ static ssize_t acc_read(struct file *fp, char __user *buf,
requeue_req:
	/* queue a request */
	req = dev->rx_req[0];
	req->length = count;
	req->length = data_length;
	dev->rx_done = 0;
	ret = usb_ep_queue(dev->ep_out, req, GFP_KERNEL);
	if (ret < 0) {