From 553fbcde3481c98a076c9744a59ad08dbc61c099 Mon Sep 17 00:00:00 2001 From: Jassi Brar Date: Fri, 14 Jan 2011 11:55:53 +0900 Subject: [PATCH] USB: Gadget: Initialize wMaxPacketSize if not already set Currently, for ISO and INT, a protocol driver must chose the value for wMaxPacketSize arbitrarily. The value may be too low, resulting in lesser than efficient operation or high enough to not work with all UDC drivers. Take un-initialized wMaxPacketSize as a hint to provide maximum possible packetsize for the selected endpoint. The protocol may then choose a value not bigger than that. Signed-off-by: Jassi Brar Signed-off-by: Greg Kroah-Hartman --- drivers/usb/gadget/epautoconf.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/drivers/usb/gadget/epautoconf.c b/drivers/usb/gadget/epautoconf.c index 8a832488ccdd..9b7360ff5aa7 100644 --- a/drivers/usb/gadget/epautoconf.c +++ b/drivers/usb/gadget/epautoconf.c @@ -128,6 +128,13 @@ ep_matches ( } } + /* + * If the protocol driver hasn't yet decided on wMaxPacketSize + * and wants to know the maximum possible, provide the info. + */ + if (desc->wMaxPacketSize == 0) + desc->wMaxPacketSize = cpu_to_le16(ep->maxpacket); + /* endpoint maxpacket size is an input parameter, except for bulk * where it's an output parameter representing the full speed limit. * the usb spec fixes high speed bulk maxpacket at 512 bytes.