summaryrefslogtreecommitdiffstats
path: root/meta/packages/uboot/u-boot-mkimage-openmoko-native/usbdcore-multiple_configs.patch
diff options
context:
space:
mode:
Diffstat (limited to 'meta/packages/uboot/u-boot-mkimage-openmoko-native/usbdcore-multiple_configs.patch')
-rw-r--r--meta/packages/uboot/u-boot-mkimage-openmoko-native/usbdcore-multiple_configs.patch63
1 files changed, 63 insertions, 0 deletions
diff --git a/meta/packages/uboot/u-boot-mkimage-openmoko-native/usbdcore-multiple_configs.patch b/meta/packages/uboot/u-boot-mkimage-openmoko-native/usbdcore-multiple_configs.patch
new file mode 100644
index 0000000000..339289699a
--- /dev/null
+++ b/meta/packages/uboot/u-boot-mkimage-openmoko-native/usbdcore-multiple_configs.patch
@@ -0,0 +1,63 @@
1This patch fixes bugs in usbdcore*.c related to the use of devices
2with multiple configurations.
3
4The original code made mistakes about the meaning of configuration value and
5configuration index, and the resulting off-by-one errors resulted in:
6
7* SET_CONFIGURATION always selected the first configuration, no matter what
8 wValue is being passed.
9* GET_DESCRIPTOR/CONFIGURATION always returned the descriptor for the first
10 configuration (index 0).
11
12Signed-off-by: Harald Welte <laforge@openmoko.org>
13
14Index: u-boot/drivers/usbdcore_ep0.c
15===================================================================
16--- u-boot.orig/drivers/usbdcore_ep0.c 2007-03-14 20:29:05.000000000 +0100
17+++ u-boot/drivers/usbdcore_ep0.c 2007-03-14 20:29:06.000000000 +0100
18@@ -233,8 +233,8 @@
19 return -1;
20 }
21 /*dbg_ep0(2, "%d %d", index, device_descriptor->bNumConfigurations); */
22- if (index > device_descriptor->bNumConfigurations) {
23- dbg_ep0 (0, "index too large: %d > %d", index,
24+ if (index >= device_descriptor->bNumConfigurations) {
25+ dbg_ep0 (0, "index too large: %d >= %d", index,
26 device_descriptor->
27 bNumConfigurations);
28 return -1;
29@@ -593,13 +593,8 @@
30
31 case USB_REQ_SET_CONFIGURATION:
32 /* c.f. 9.4.7 - the top half of wValue is reserved */
33- /* */
34- if ((device->configuration =
35- le16_to_cpu (request->wValue) & 0x7f) != 0) {
36- /* c.f. 9.4.7 - zero is the default or addressed state, in our case this */
37- /* is the same is configuration zero */
38- device->configuration = 0; /* TBR - ?????? */
39- }
40+ device->configuration = le16_to_cpu(request->wValue) & 0xff;
41+
42 /* reset interface and alternate settings */
43 device->interface = device->alternate = 0;
44
45Index: u-boot/drivers/usbdcore.c
46===================================================================
47--- u-boot.orig/drivers/usbdcore.c 2007-03-14 20:29:05.000000000 +0100
48+++ u-boot/drivers/usbdcore.c 2007-03-14 20:37:37.000000000 +0100
49@@ -147,12 +147,9 @@
50 static struct usb_configuration_instance *usbd_device_configuration_instance (struct usb_device_instance *device,
51 unsigned int port, unsigned int configuration)
52 {
53- /* XXX */
54- configuration = configuration ? configuration - 1 : 0;
55-
56- if (configuration >= device->configurations) {
57+ if (configuration >= device->configurations)
58 return NULL;
59- }
60+
61 return device->configuration_instance_array + configuration;
62 }
63