summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPeter Chen <peter.chen@freescale.com>2015-09-01 09:48:02 +0800
committerFelipe Balbi <balbi@ti.com>2015-09-27 10:54:31 -0500
commit046839098c34f0ade17b7060e7385bd581151b3b (patch)
tree9e4004bfb33dfd1a52c5222d9ef2ac6cad49010e
parentb9a6e8e1001e28fecbd74c073f5503dac2790563 (diff)
downloadlinux-046839098c34f0ade17b7060e7385bd581151b3b.tar.bz2
usb: gadget: f_sourcesink: format data pattern according to max packet size
Since the host and gadget can't agree with transfer length before each transfer, but they agree with max packet size for each endpoint, we use max packet size to format data pattern. Acked-by: Michal Nazarewicz <mina86@mina86.com> Signed-off-by: Peter Chen <peter.chen@freescale.com> Signed-off-by: Felipe Balbi <balbi@ti.com>
-rw-r--r--drivers/usb/gadget/function/f_sourcesink.c6
1 files changed, 4 insertions, 2 deletions
diff --git a/drivers/usb/gadget/function/f_sourcesink.c b/drivers/usb/gadget/function/f_sourcesink.c
index cbfaf86fe456..37c7a51bd898 100644
--- a/drivers/usb/gadget/function/f_sourcesink.c
+++ b/drivers/usb/gadget/function/f_sourcesink.c
@@ -489,6 +489,7 @@ static int check_read_data(struct f_sourcesink *ss, struct usb_request *req)
unsigned i;
u8 *buf = req->buf;
struct usb_composite_dev *cdev = ss->function.config->cdev;
+ int max_packet_size = le16_to_cpu(ss->out_ep->desc->wMaxPacketSize);
if (pattern == 2)
return 0;
@@ -510,7 +511,7 @@ static int check_read_data(struct f_sourcesink *ss, struct usb_request *req)
* stutter for any reason, including buffer duplication...)
*/
case 1:
- if (*buf == (u8)(i % 63))
+ if (*buf == (u8)((i % max_packet_size) % 63))
continue;
break;
}
@@ -525,6 +526,7 @@ static void reinit_write_data(struct usb_ep *ep, struct usb_request *req)
{
unsigned i;
u8 *buf = req->buf;
+ int max_packet_size = le16_to_cpu(ep->desc->wMaxPacketSize);
switch (pattern) {
case 0:
@@ -532,7 +534,7 @@ static void reinit_write_data(struct usb_ep *ep, struct usb_request *req)
break;
case 1:
for (i = 0; i < req->length; i++)
- *buf++ = (u8) (i % 63);
+ *buf++ = (u8) ((i % max_packet_size) % 63);
break;
case 2:
break;