Commit 33376c1c authored by David Brownell's avatar David Brownell Committed by Greg Kroah-Hartman

usb gadget: link fixes for network gadget

Change how the Ethernet/RNDIS gadget 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 ...".

This is a bit more complicated than most of the others
because it had to resolve a few symbol collisions.
Signed-off-by: default avatarDavid Brownell <dbrownell@users.sourceforge.net>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@suse.de>
parent 8a1ce2c0
...@@ -22,10 +22,8 @@ obj-$(CONFIG_USB_M66592) += m66592-udc.o ...@@ -22,10 +22,8 @@ obj-$(CONFIG_USB_M66592) += m66592-udc.o
# #
# USB gadget drivers # USB gadget drivers
# #
C_UTILS = composite.o usbstring.o config.o epautoconf.o
g_zero-objs := zero.o g_zero-objs := zero.o
g_ether-objs := ether.o u_ether.o f_subset.o f_ecm.o $(C_UTILS) g_ether-objs := ether.o
g_serial-objs := serial.o g_serial-objs := serial.o
g_midi-objs := gmidi.o g_midi-objs := gmidi.o
gadgetfs-objs := inode.o gadgetfs-objs := inode.o
...@@ -33,10 +31,6 @@ g_file_storage-objs := file_storage.o ...@@ -33,10 +31,6 @@ g_file_storage-objs := file_storage.o
g_printer-objs := printer.o g_printer-objs := printer.o
g_cdc-objs := cdc2.o g_cdc-objs := cdc2.o
ifeq ($(CONFIG_USB_ETH_RNDIS),y)
g_ether-objs += f_rndis.o rndis.o
endif
obj-$(CONFIG_USB_ZERO) += g_zero.o obj-$(CONFIG_USB_ZERO) += g_zero.o
obj-$(CONFIG_USB_ETH) += g_ether.o obj-$(CONFIG_USB_ETH) += g_ether.o
obj-$(CONFIG_USB_GADGETFS) += gadgetfs.o obj-$(CONFIG_USB_GADGETFS) += gadgetfs.o
......
...@@ -96,6 +96,28 @@ static inline bool has_rndis(void) ...@@ -96,6 +96,28 @@ static inline bool has_rndis(void)
/*-------------------------------------------------------------------------*/ /*-------------------------------------------------------------------------*/
/*
* Kbuild is not very cooperative with respect to linking separately
* compiled library objects into one module. So for now we won't use
* separate compilation ... ensuring init/exit sections work to shrink
* the runtime footprint, and giving us at least some parts of what
* a "gcc --combine ... part1.c part2.c part3.c ... " build would.
*/
#include "composite.c"
#include "usbstring.c"
#include "config.c"
#include "epautoconf.c"
#include "f_ecm.c"
#include "f_subset.c"
#ifdef CONFIG_USB_ETH_RNDIS
#include "f_rndis.c"
#include "rndis.c"
#endif
#include "u_ether.c"
/*-------------------------------------------------------------------------*/
/* DO NOT REUSE THESE IDs with a protocol-incompatible driver!! Ever!! /* DO NOT REUSE THESE IDs with a protocol-incompatible driver!! Ever!!
* Instead: allocate your own, using normal USB-IF procedures. * Instead: allocate your own, using normal USB-IF procedures.
*/ */
...@@ -293,7 +315,8 @@ static int __init eth_bind(struct usb_composite_dev *cdev) ...@@ -293,7 +315,8 @@ static int __init eth_bind(struct usb_composite_dev *cdev)
* but if the controller isn't recognized at all then * but if the controller isn't recognized at all then
* that assumption is a bit more likely to be wrong. * that assumption is a bit more likely to be wrong.
*/ */
WARNING(cdev, "controller '%s' not recognized; trying %s\n", dev_warn(&gadget->dev,
"controller '%s' not recognized; trying %s\n",
gadget->name, gadget->name,
eth_config_driver.label); eth_config_driver.label);
device_desc.bcdDevice = device_desc.bcdDevice =
...@@ -332,7 +355,8 @@ static int __init eth_bind(struct usb_composite_dev *cdev) ...@@ -332,7 +355,8 @@ static int __init eth_bind(struct usb_composite_dev *cdev)
if (status < 0) if (status < 0)
goto fail; goto fail;
INFO(cdev, "%s, version: " DRIVER_VERSION "\n", DRIVER_DESC); dev_info(&gadget->dev, "%s, version: " DRIVER_VERSION "\n",
DRIVER_DESC);
return 0; return 0;
......
This diff is collapsed.
...@@ -103,8 +103,8 @@ static struct usb_interface_descriptor subset_data_intf __initdata = { ...@@ -103,8 +103,8 @@ static struct usb_interface_descriptor subset_data_intf __initdata = {
/* .iInterface = DYNAMIC */ /* .iInterface = DYNAMIC */
}; };
static struct usb_cdc_header_desc header_desc __initdata = { static struct usb_cdc_header_desc mdlm_header_desc __initdata = {
.bLength = sizeof header_desc, .bLength = sizeof mdlm_header_desc,
.bDescriptorType = USB_DT_CS_INTERFACE, .bDescriptorType = USB_DT_CS_INTERFACE,
.bDescriptorSubType = USB_CDC_HEADER_TYPE, .bDescriptorSubType = USB_CDC_HEADER_TYPE,
...@@ -152,7 +152,7 @@ static struct usb_cdc_ether_desc ether_desc __initdata = { ...@@ -152,7 +152,7 @@ static struct usb_cdc_ether_desc ether_desc __initdata = {
/* full speed support: */ /* full speed support: */
static struct usb_endpoint_descriptor fs_in_desc __initdata = { static struct usb_endpoint_descriptor fs_subset_in_desc __initdata = {
.bLength = USB_DT_ENDPOINT_SIZE, .bLength = USB_DT_ENDPOINT_SIZE,
.bDescriptorType = USB_DT_ENDPOINT, .bDescriptorType = USB_DT_ENDPOINT,
...@@ -160,7 +160,7 @@ static struct usb_endpoint_descriptor fs_in_desc __initdata = { ...@@ -160,7 +160,7 @@ static struct usb_endpoint_descriptor fs_in_desc __initdata = {
.bmAttributes = USB_ENDPOINT_XFER_BULK, .bmAttributes = USB_ENDPOINT_XFER_BULK,
}; };
static struct usb_endpoint_descriptor fs_out_desc __initdata = { static struct usb_endpoint_descriptor fs_subset_out_desc __initdata = {
.bLength = USB_DT_ENDPOINT_SIZE, .bLength = USB_DT_ENDPOINT_SIZE,
.bDescriptorType = USB_DT_ENDPOINT, .bDescriptorType = USB_DT_ENDPOINT,
...@@ -170,18 +170,18 @@ static struct usb_endpoint_descriptor fs_out_desc __initdata = { ...@@ -170,18 +170,18 @@ static struct usb_endpoint_descriptor fs_out_desc __initdata = {
static struct usb_descriptor_header *fs_eth_function[] __initdata = { static struct usb_descriptor_header *fs_eth_function[] __initdata = {
(struct usb_descriptor_header *) &subset_data_intf, (struct usb_descriptor_header *) &subset_data_intf,
(struct usb_descriptor_header *) &header_desc, (struct usb_descriptor_header *) &mdlm_header_desc,
(struct usb_descriptor_header *) &mdlm_desc, (struct usb_descriptor_header *) &mdlm_desc,
(struct usb_descriptor_header *) &mdlm_detail_desc, (struct usb_descriptor_header *) &mdlm_detail_desc,
(struct usb_descriptor_header *) &ether_desc, (struct usb_descriptor_header *) &ether_desc,
(struct usb_descriptor_header *) &fs_in_desc, (struct usb_descriptor_header *) &fs_subset_in_desc,
(struct usb_descriptor_header *) &fs_out_desc, (struct usb_descriptor_header *) &fs_subset_out_desc,
NULL, NULL,
}; };
/* high speed support: */ /* high speed support: */
static struct usb_endpoint_descriptor hs_in_desc __initdata = { static struct usb_endpoint_descriptor hs_subset_in_desc __initdata = {
.bLength = USB_DT_ENDPOINT_SIZE, .bLength = USB_DT_ENDPOINT_SIZE,
.bDescriptorType = USB_DT_ENDPOINT, .bDescriptorType = USB_DT_ENDPOINT,
...@@ -189,7 +189,7 @@ static struct usb_endpoint_descriptor hs_in_desc __initdata = { ...@@ -189,7 +189,7 @@ static struct usb_endpoint_descriptor hs_in_desc __initdata = {
.wMaxPacketSize = __constant_cpu_to_le16(512), .wMaxPacketSize = __constant_cpu_to_le16(512),
}; };
static struct usb_endpoint_descriptor hs_out_desc __initdata = { static struct usb_endpoint_descriptor hs_subset_out_desc __initdata = {
.bLength = USB_DT_ENDPOINT_SIZE, .bLength = USB_DT_ENDPOINT_SIZE,
.bDescriptorType = USB_DT_ENDPOINT, .bDescriptorType = USB_DT_ENDPOINT,
...@@ -199,12 +199,12 @@ static struct usb_endpoint_descriptor hs_out_desc __initdata = { ...@@ -199,12 +199,12 @@ static struct usb_endpoint_descriptor hs_out_desc __initdata = {
static struct usb_descriptor_header *hs_eth_function[] __initdata = { static struct usb_descriptor_header *hs_eth_function[] __initdata = {
(struct usb_descriptor_header *) &subset_data_intf, (struct usb_descriptor_header *) &subset_data_intf,
(struct usb_descriptor_header *) &header_desc, (struct usb_descriptor_header *) &mdlm_header_desc,
(struct usb_descriptor_header *) &mdlm_desc, (struct usb_descriptor_header *) &mdlm_desc,
(struct usb_descriptor_header *) &mdlm_detail_desc, (struct usb_descriptor_header *) &mdlm_detail_desc,
(struct usb_descriptor_header *) &ether_desc, (struct usb_descriptor_header *) &ether_desc,
(struct usb_descriptor_header *) &hs_in_desc, (struct usb_descriptor_header *) &hs_subset_in_desc,
(struct usb_descriptor_header *) &hs_out_desc, (struct usb_descriptor_header *) &hs_subset_out_desc,
NULL, NULL,
}; };
...@@ -281,13 +281,13 @@ geth_bind(struct usb_configuration *c, struct usb_function *f) ...@@ -281,13 +281,13 @@ geth_bind(struct usb_configuration *c, struct usb_function *f)
status = -ENODEV; status = -ENODEV;
/* allocate instance-specific endpoints */ /* allocate instance-specific endpoints */
ep = usb_ep_autoconfig(cdev->gadget, &fs_in_desc); ep = usb_ep_autoconfig(cdev->gadget, &fs_subset_in_desc);
if (!ep) if (!ep)
goto fail; goto fail;
geth->port.in_ep = ep; geth->port.in_ep = ep;
ep->driver_data = cdev; /* claim */ ep->driver_data = cdev; /* claim */
ep = usb_ep_autoconfig(cdev->gadget, &fs_out_desc); ep = usb_ep_autoconfig(cdev->gadget, &fs_subset_out_desc);
if (!ep) if (!ep)
goto fail; goto fail;
geth->port.out_ep = ep; geth->port.out_ep = ep;
...@@ -297,9 +297,9 @@ geth_bind(struct usb_configuration *c, struct usb_function *f) ...@@ -297,9 +297,9 @@ geth_bind(struct usb_configuration *c, struct usb_function *f)
f->descriptors = usb_copy_descriptors(fs_eth_function); f->descriptors = usb_copy_descriptors(fs_eth_function);
geth->fs.in = usb_find_endpoint(fs_eth_function, geth->fs.in = usb_find_endpoint(fs_eth_function,
f->descriptors, &fs_in_desc); f->descriptors, &fs_subset_in_desc);
geth->fs.out = usb_find_endpoint(fs_eth_function, geth->fs.out = usb_find_endpoint(fs_eth_function,
f->descriptors, &fs_out_desc); f->descriptors, &fs_subset_out_desc);
/* support all relevant hardware speeds... we expect that when /* support all relevant hardware speeds... we expect that when
...@@ -307,18 +307,18 @@ geth_bind(struct usb_configuration *c, struct usb_function *f) ...@@ -307,18 +307,18 @@ geth_bind(struct usb_configuration *c, struct usb_function *f)
* both speeds * both speeds
*/ */
if (gadget_is_dualspeed(c->cdev->gadget)) { if (gadget_is_dualspeed(c->cdev->gadget)) {
hs_in_desc.bEndpointAddress = hs_subset_in_desc.bEndpointAddress =
fs_in_desc.bEndpointAddress; fs_subset_in_desc.bEndpointAddress;
hs_out_desc.bEndpointAddress = hs_subset_out_desc.bEndpointAddress =
fs_out_desc.bEndpointAddress; fs_subset_out_desc.bEndpointAddress;
/* copy descriptors, and track endpoint copies */ /* copy descriptors, and track endpoint copies */
f->hs_descriptors = usb_copy_descriptors(hs_eth_function); f->hs_descriptors = usb_copy_descriptors(hs_eth_function);
geth->hs.in = usb_find_endpoint(hs_eth_function, geth->hs.in = usb_find_endpoint(hs_eth_function,
f->hs_descriptors, &hs_in_desc); f->hs_descriptors, &hs_subset_in_desc);
geth->hs.out = usb_find_endpoint(hs_eth_function, geth->hs.out = usb_find_endpoint(hs_eth_function,
f->hs_descriptors, &hs_out_desc); f->hs_descriptors, &hs_subset_out_desc);
} }
/* NOTE: all that is done without knowing or caring about /* NOTE: all that is done without knowing or caring about
......
This diff is collapsed.
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment