aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDavid Brownell <dbrownell@users.sourceforge.net>2008-08-18 20:41:31 -0400
committerGreg Kroah-Hartman <gregkh@suse.de>2008-10-16 12:24:46 -0400
commit7e75bc0f9006e995a0fa25f0a285addc3d5fd5cb (patch)
treefdd7210c5c7277129a12cad58695903287f36482
parent4e9ba518ec19c6c961bf6074ec05ae1a927230bc (diff)
usb gadget: link fixes for gadget zero
Change how the Gadget Zero driver builds: don't use separate compilation, since it works poorly when key parts are library code (with init sections etc). Instead be as close as we can to "gcc --combine ...". Signed-off-by: David Brownell <dbrownell@users.sourceforge.net> Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
-rw-r--r--drivers/usb/gadget/Makefile2
-rw-r--r--drivers/usb/gadget/f_loopback.c34
-rw-r--r--drivers/usb/gadget/zero.c17
3 files changed, 36 insertions, 17 deletions
diff --git a/drivers/usb/gadget/Makefile b/drivers/usb/gadget/Makefile
index 853dd0229431..55f589131e38 100644
--- a/drivers/usb/gadget/Makefile
+++ b/drivers/usb/gadget/Makefile
@@ -24,7 +24,7 @@ obj-$(CONFIG_USB_M66592) += m66592-udc.o
24# 24#
25C_UTILS = composite.o usbstring.o config.o epautoconf.o 25C_UTILS = composite.o usbstring.o config.o epautoconf.o
26 26
27g_zero-objs := zero.o f_sourcesink.o f_loopback.o $(C_UTILS) 27g_zero-objs := zero.o
28g_ether-objs := ether.o u_ether.o f_subset.o f_ecm.o $(C_UTILS) 28g_ether-objs := ether.o u_ether.o f_subset.o f_ecm.o $(C_UTILS)
29g_serial-objs := serial.o 29g_serial-objs := serial.o
30g_midi-objs := gmidi.o usbstring.o config.o epautoconf.o 30g_midi-objs := gmidi.o usbstring.o config.o epautoconf.o
diff --git a/drivers/usb/gadget/f_loopback.c b/drivers/usb/gadget/f_loopback.c
index eda4cde72c82..87dde012dacc 100644
--- a/drivers/usb/gadget/f_loopback.c
+++ b/drivers/usb/gadget/f_loopback.c
@@ -70,7 +70,7 @@ static struct usb_interface_descriptor loopback_intf = {
70 70
71/* full speed support: */ 71/* full speed support: */
72 72
73static struct usb_endpoint_descriptor fs_source_desc = { 73static struct usb_endpoint_descriptor fs_loop_source_desc = {
74 .bLength = USB_DT_ENDPOINT_SIZE, 74 .bLength = USB_DT_ENDPOINT_SIZE,
75 .bDescriptorType = USB_DT_ENDPOINT, 75 .bDescriptorType = USB_DT_ENDPOINT,
76 76
@@ -78,7 +78,7 @@ static struct usb_endpoint_descriptor fs_source_desc = {
78 .bmAttributes = USB_ENDPOINT_XFER_BULK, 78 .bmAttributes = USB_ENDPOINT_XFER_BULK,
79}; 79};
80 80
81static struct usb_endpoint_descriptor fs_sink_desc = { 81static struct usb_endpoint_descriptor fs_loop_sink_desc = {
82 .bLength = USB_DT_ENDPOINT_SIZE, 82 .bLength = USB_DT_ENDPOINT_SIZE,
83 .bDescriptorType = USB_DT_ENDPOINT, 83 .bDescriptorType = USB_DT_ENDPOINT,
84 84
@@ -88,14 +88,14 @@ static struct usb_endpoint_descriptor fs_sink_desc = {
88 88
89static struct usb_descriptor_header *fs_loopback_descs[] = { 89static struct usb_descriptor_header *fs_loopback_descs[] = {
90 (struct usb_descriptor_header *) &loopback_intf, 90 (struct usb_descriptor_header *) &loopback_intf,
91 (struct usb_descriptor_header *) &fs_sink_desc, 91 (struct usb_descriptor_header *) &fs_loop_sink_desc,
92 (struct usb_descriptor_header *) &fs_source_desc, 92 (struct usb_descriptor_header *) &fs_loop_source_desc,
93 NULL, 93 NULL,
94}; 94};
95 95
96/* high speed support: */ 96/* high speed support: */
97 97
98static struct usb_endpoint_descriptor hs_source_desc = { 98static struct usb_endpoint_descriptor hs_loop_source_desc = {
99 .bLength = USB_DT_ENDPOINT_SIZE, 99 .bLength = USB_DT_ENDPOINT_SIZE,
100 .bDescriptorType = USB_DT_ENDPOINT, 100 .bDescriptorType = USB_DT_ENDPOINT,
101 101
@@ -103,7 +103,7 @@ static struct usb_endpoint_descriptor hs_source_desc = {
103 .wMaxPacketSize = __constant_cpu_to_le16(512), 103 .wMaxPacketSize = __constant_cpu_to_le16(512),
104}; 104};
105 105
106static struct usb_endpoint_descriptor hs_sink_desc = { 106static struct usb_endpoint_descriptor hs_loop_sink_desc = {
107 .bLength = USB_DT_ENDPOINT_SIZE, 107 .bLength = USB_DT_ENDPOINT_SIZE,
108 .bDescriptorType = USB_DT_ENDPOINT, 108 .bDescriptorType = USB_DT_ENDPOINT,
109 109
@@ -113,8 +113,8 @@ static struct usb_endpoint_descriptor hs_sink_desc = {
113 113
114static struct usb_descriptor_header *hs_loopback_descs[] = { 114static struct usb_descriptor_header *hs_loopback_descs[] = {
115 (struct usb_descriptor_header *) &loopback_intf, 115 (struct usb_descriptor_header *) &loopback_intf,
116 (struct usb_descriptor_header *) &hs_source_desc, 116 (struct usb_descriptor_header *) &hs_loop_source_desc,
117 (struct usb_descriptor_header *) &hs_sink_desc, 117 (struct usb_descriptor_header *) &hs_loop_sink_desc,
118 NULL, 118 NULL,
119}; 119};
120 120
@@ -152,7 +152,7 @@ loopback_bind(struct usb_configuration *c, struct usb_function *f)
152 152
153 /* allocate endpoints */ 153 /* allocate endpoints */
154 154
155 loop->in_ep = usb_ep_autoconfig(cdev->gadget, &fs_source_desc); 155 loop->in_ep = usb_ep_autoconfig(cdev->gadget, &fs_loop_source_desc);
156 if (!loop->in_ep) { 156 if (!loop->in_ep) {
157autoconf_fail: 157autoconf_fail:
158 ERROR(cdev, "%s: can't autoconfigure on %s\n", 158 ERROR(cdev, "%s: can't autoconfigure on %s\n",
@@ -161,17 +161,17 @@ autoconf_fail:
161 } 161 }
162 loop->in_ep->driver_data = cdev; /* claim */ 162 loop->in_ep->driver_data = cdev; /* claim */
163 163
164 loop->out_ep = usb_ep_autoconfig(cdev->gadget, &fs_sink_desc); 164 loop->out_ep = usb_ep_autoconfig(cdev->gadget, &fs_loop_sink_desc);
165 if (!loop->out_ep) 165 if (!loop->out_ep)
166 goto autoconf_fail; 166 goto autoconf_fail;
167 loop->out_ep->driver_data = cdev; /* claim */ 167 loop->out_ep->driver_data = cdev; /* claim */
168 168
169 /* support high speed hardware */ 169 /* support high speed hardware */
170 if (gadget_is_dualspeed(c->cdev->gadget)) { 170 if (gadget_is_dualspeed(c->cdev->gadget)) {
171 hs_source_desc.bEndpointAddress = 171 hs_loop_source_desc.bEndpointAddress =
172 fs_source_desc.bEndpointAddress; 172 fs_loop_source_desc.bEndpointAddress;
173 hs_sink_desc.bEndpointAddress = 173 hs_loop_sink_desc.bEndpointAddress =
174 fs_sink_desc.bEndpointAddress; 174 fs_loop_sink_desc.bEndpointAddress;
175 f->hs_descriptors = hs_loopback_descs; 175 f->hs_descriptors = hs_loopback_descs;
176 } 176 }
177 177
@@ -255,8 +255,10 @@ enable_loopback(struct usb_composite_dev *cdev, struct f_loopback *loop)
255 struct usb_request *req; 255 struct usb_request *req;
256 unsigned i; 256 unsigned i;
257 257
258 src = ep_choose(cdev->gadget, &hs_source_desc, &fs_source_desc); 258 src = ep_choose(cdev->gadget,
259 sink = ep_choose(cdev->gadget, &hs_sink_desc, &fs_sink_desc); 259 &hs_loop_source_desc, &fs_loop_source_desc);
260 sink = ep_choose(cdev->gadget,
261 &hs_loop_sink_desc, &fs_loop_sink_desc);
260 262
261 /* one endpoint writes data back IN to the host */ 263 /* one endpoint writes data back IN to the host */
262 ep = loop->in_ep; 264 ep = loop->in_ep;
diff --git a/drivers/usb/gadget/zero.c b/drivers/usb/gadget/zero.c
index aa0bd4f126a1..361d9659ac48 100644
--- a/drivers/usb/gadget/zero.c
+++ b/drivers/usb/gadget/zero.c
@@ -59,6 +59,23 @@
59 59
60/*-------------------------------------------------------------------------*/ 60/*-------------------------------------------------------------------------*/
61 61
62/*
63 * Kbuild is not very cooperative with respect to linking separately
64 * compiled library objects into one module. So for now we won't use
65 * separate compilation ... ensuring init/exit sections work to shrink
66 * the runtime footprint, and giving us at least some parts of what
67 * a "gcc --combine ... part1.c part2.c part3.c ... " build would.
68 */
69#include "composite.c"
70#include "usbstring.c"
71#include "config.c"
72#include "epautoconf.c"
73
74#include "f_sourcesink.c"
75#include "f_loopback.c"
76
77/*-------------------------------------------------------------------------*/
78
62#define DRIVER_VERSION "Cinco de Mayo 2008" 79#define DRIVER_VERSION "Cinco de Mayo 2008"
63 80
64static const char longname[] = "Gadget Zero"; 81static const char longname[] = "Gadget Zero";