public inbox for u-boot@lists.denx.de
 help / color / mirror / Atom feed
* [U-Boot] [PATCH] usb:composite:fix Provide function data when addressing device with only one interface
@ 2013-03-01 14:30 Lukasz Majewski
  2013-03-01 14:34 ` Marek Vasut
                   ` (2 more replies)
  0 siblings, 3 replies; 15+ messages in thread
From: Lukasz Majewski @ 2013-03-01 14:30 UTC (permalink / raw)
  To: u-boot

This commit fixes problems with some non-standard requests send with
device address instead of interface address (bmRequestType.Receipent field).

This happens with dfu-util (debian version: 0.5), which address non standard
requests (like w_value=0x21 and bRequest=GET_DESCRIPTOR) to device.
Without this fix, the above request is STALLED, and hence causes dfu-util
to assume some standard configuration (packet size = 1024B instead of 4096B)
In turn it displays following errors:
Error obtaining DFU functional descriptor
Warning: Assuming DFU version 1.0
Warning: Transfer size can not be detected
...
Warning: Trying default transfer size 1024

This fix allows passing non-standard request to function setup code, where
it shall be handled.

Tested at: 	Trats (exynos4210)
Tested with:DFU and UMS gadgets

Signed-off-by: Lukasz Majewski <l.majewski@samsung.com>
Signed-off-by: Kyungmin Park <kyungmin.park@samsung.com>
---
This patch fixes problem pointed by Pantelis Antoniou.
It is supposed to replace following commit added to u-boot-usb repository:

"dfu: Send correct DFU response from composite_setup"
SHA1: fef31049fa06e516945114195eb14ac3549d0ad2
---
 drivers/usb/gadget/composite.c |   19 +++++++++++++++++++
 1 file changed, 19 insertions(+)

diff --git a/drivers/usb/gadget/composite.c b/drivers/usb/gadget/composite.c
index ebb5131..2c5600e 100644
--- a/drivers/usb/gadget/composite.c
+++ b/drivers/usb/gadget/composite.c
@@ -859,6 +859,25 @@ unknown:
 			if (&f->list == &cdev->config->functions)
 				f = NULL;
 			break;
+		/*
+		 * dfu-util (version 0.5) sets bmRequestType.Receipent = Device
+		 * for non-standard request (w_value = 0x21,
+		 * bRequest = GET_DESCRIPTOR in this case).
+		 * When only one interface is registered (as it is done now),
+		 * then this request shall be handled as it was requested for
+		 * interface.
+		 *
+		 * In the below code it is checked if only one interface is
+		 * present and proper function for it is extracted. Due to that
+		 * function's setup (f->setup) is called to handle this
+		 * special non-standard request.
+		 */
+		case USB_RECIP_DEVICE:
+			debug("cdev->config->next_interface_id: %d intf: %d\n",
+			       cdev->config->next_interface_id, intf);
+			if (cdev->config->next_interface_id == 1)
+				f = cdev->config->interface[intf];
+			break;
 		}
 
 		if (f && f->setup)
-- 
1.7.10.4

^ permalink raw reply related	[flat|nested] 15+ messages in thread

end of thread, other threads:[~2013-07-01  6:28 UTC | newest]

Thread overview: 15+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-03-01 14:30 [U-Boot] [PATCH] usb:composite:fix Provide function data when addressing device with only one interface Lukasz Majewski
2013-03-01 14:34 ` Marek Vasut
2013-03-01 15:34   ` Lukasz Majewski
2013-03-05 23:24     ` Marek Vasut
2013-03-05 23:44       ` Tom Rini
2013-03-05 23:54         ` Marek Vasut
2013-03-06  0:26           ` Tom Rini
2013-03-06  0:55             ` Marek Vasut
2013-03-06  1:38               ` Tom Rini
2013-03-06  7:42         ` Lukasz Majewski
2013-03-06  7:45           ` Pantelis Antoniou
2013-03-06 13:03             ` Tom Rini
2013-03-01 16:46 ` Tom Rini
2013-06-27 21:36 ` Tormod Volden
2013-07-01  6:28   ` Lukasz Majewski

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox