Skip to content

Commit

Permalink
[PATCH] USB: gadget section fixups
Browse files Browse the repository at this point in the history
Recent section changes broke gadget builds on some platforms.  This patch
is the best fix that's available until better section markings exist:

 - There's a lot of cleanup code that gets used in both init and exit paths;
   stop marking it as "__exit".

   (Best fix for this would be an "__init_or_exit" section marking, putting
   the cleanup in __init when __exit sections get discarded else in __exit.)

 - Stop marking the use-once probe routines as "__init" since references
   to those routines are not allowed from driver structures.  They're now
   marked "__devinit", which in practice is a net lose.

   (Best fix for this is likely to separate such use-once probe routines
   from the driver structure ... but in general, all busses that aren't
   hotpluggable will be forced to waste memory for all probe-only code.)

In general these broken section rules waste an average of two to four kBytes
per driver of code bloat ... because none of the relevant code can ever be
reused after module initialization.

Signed-off-by: David Brownell <dbrownell@users.sourceforge.net>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
  • Loading branch information
David Brownell authored and Greg Kroah-Hartman committed Jul 12, 2006
1 parent 5501a48 commit a353678
Show file tree
Hide file tree
Showing 8 changed files with 19 additions and 19 deletions.
16 changes: 8 additions & 8 deletions drivers/usb/gadget/epautoconf.c
Original file line number Diff line number Diff line change
Expand Up @@ -34,12 +34,12 @@


/* we must assign addresses for configurable endpoints (like net2280) */
static __initdata unsigned epnum;
static __devinitdata unsigned epnum;

// #define MANY_ENDPOINTS
#ifdef MANY_ENDPOINTS
/* more than 15 configurable endpoints */
static __initdata unsigned in_epnum;
static __devinitdata unsigned in_epnum;
#endif


Expand All @@ -59,7 +59,7 @@ static __initdata unsigned in_epnum;
* NOTE: each endpoint is unidirectional, as specified by its USB
* descriptor; and isn't specific to a configuration or altsetting.
*/
static int __init
static int __devinit
ep_matches (
struct usb_gadget *gadget,
struct usb_ep *ep,
Expand All @@ -73,7 +73,7 @@ ep_matches (
/* endpoint already claimed? */
if (0 != ep->driver_data)
return 0;

/* only support ep0 for portable CONTROL traffic */
type = desc->bmAttributes & USB_ENDPOINT_XFERTYPE_MASK;
if (USB_ENDPOINT_XFER_CONTROL == type)
Expand Down Expand Up @@ -186,7 +186,7 @@ ep_matches (
return 1;
}

static struct usb_ep * __init
static struct usb_ep * __devinit
find_ep (struct usb_gadget *gadget, const char *name)
{
struct usb_ep *ep;
Expand Down Expand Up @@ -228,7 +228,7 @@ find_ep (struct usb_gadget *gadget, const char *name)
*
* On failure, this returns a null endpoint descriptor.
*/
struct usb_ep * __init usb_ep_autoconfig (
struct usb_ep * __devinit usb_ep_autoconfig (
struct usb_gadget *gadget,
struct usb_endpoint_descriptor *desc
)
Expand Down Expand Up @@ -276,7 +276,7 @@ struct usb_ep * __init usb_ep_autoconfig (
return ep;
}

/* Second, look at endpoints until an unclaimed one looks usable */
/* Second, look at endpoints until an unclaimed one looks usable */
list_for_each_entry (ep, &gadget->ep_list, ep_list) {
if (ep_matches (gadget, ep, desc))
return ep;
Expand All @@ -295,7 +295,7 @@ struct usb_ep * __init usb_ep_autoconfig (
* state such as ep->driver_data and the record of assigned endpoints
* used by usb_ep_autoconfig().
*/
void __init usb_ep_autoconfig_reset (struct usb_gadget *gadget)
void __devinit usb_ep_autoconfig_reset (struct usb_gadget *gadget)
{
struct usb_ep *ep;

Expand Down
8 changes: 4 additions & 4 deletions drivers/usb/gadget/ether.c
Original file line number Diff line number Diff line change
Expand Up @@ -2131,7 +2131,7 @@ eth_req_free (struct usb_ep *ep, struct usb_request *req)
}


static void __exit
static void /* __init_or_exit */
eth_unbind (struct usb_gadget *gadget)
{
struct eth_dev *dev = get_gadget_data (gadget);
Expand All @@ -2158,7 +2158,7 @@ eth_unbind (struct usb_gadget *gadget)
set_gadget_data (gadget, NULL);
}

static u8 __init nibble (unsigned char c)
static u8 __devinit nibble (unsigned char c)
{
if (likely (isdigit (c)))
return c - '0';
Expand All @@ -2168,7 +2168,7 @@ static u8 __init nibble (unsigned char c)
return 0;
}

static int __init get_ether_addr(const char *str, u8 *dev_addr)
static int __devinit get_ether_addr(const char *str, u8 *dev_addr)
{
if (str) {
unsigned i;
Expand All @@ -2189,7 +2189,7 @@ static int __init get_ether_addr(const char *str, u8 *dev_addr)
return 1;
}

static int __init
static int __devinit
eth_bind (struct usb_gadget *gadget)
{
struct eth_dev *dev;
Expand Down
2 changes: 1 addition & 1 deletion drivers/usb/gadget/file_storage.c
Original file line number Diff line number Diff line change
Expand Up @@ -3691,7 +3691,7 @@ static void lun_release(struct device *dev)
kref_put(&fsg->ref, fsg_release);
}

static void __exit fsg_unbind(struct usb_gadget *gadget)
static void /* __init_or_exit */ fsg_unbind(struct usb_gadget *gadget)
{
struct fsg_dev *fsg = get_gadget_data(gadget);
int i;
Expand Down
2 changes: 1 addition & 1 deletion drivers/usb/gadget/rndis.c
Original file line number Diff line number Diff line change
Expand Up @@ -1398,7 +1398,7 @@ static struct proc_dir_entry *rndis_connect_state [RNDIS_MAX_CONFIGS];
#endif /* CONFIG_USB_GADGET_DEBUG_FILES */


int __init rndis_init (void)
int __devinit rndis_init (void)
{
u8 i;

Expand Down
2 changes: 1 addition & 1 deletion drivers/usb/gadget/rndis.h
Original file line number Diff line number Diff line change
Expand Up @@ -264,7 +264,7 @@ int rndis_signal_disconnect (int configNr);
int rndis_state (int configNr);
extern void rndis_set_host_mac (int configNr, const u8 *addr);

int __init rndis_init (void);
int __devinit rndis_init (void);
void rndis_exit (void);

#endif /* _LINUX_RNDIS_H */
2 changes: 1 addition & 1 deletion drivers/usb/gadget/serial.c
Original file line number Diff line number Diff line change
Expand Up @@ -1473,7 +1473,7 @@ static int __init gs_bind(struct usb_gadget *gadget)
* Called on module unload. Frees the control request and device
* structure.
*/
static void __exit gs_unbind(struct usb_gadget *gadget)
static void /* __init_or_exit */ gs_unbind(struct usb_gadget *gadget)
{
struct gs_dev *dev = get_gadget_data(gadget);

Expand Down
2 changes: 1 addition & 1 deletion drivers/usb/gadget/zero.c
Original file line number Diff line number Diff line change
Expand Up @@ -1121,7 +1121,7 @@ zero_autoresume (unsigned long _dev)

/*-------------------------------------------------------------------------*/

static void __exit
static void /* __init_or_exit */
zero_unbind (struct usb_gadget *gadget)
{
struct zero_dev *dev = get_gadget_data (gadget);
Expand Down
4 changes: 2 additions & 2 deletions include/linux/usb_gadget.h
Original file line number Diff line number Diff line change
Expand Up @@ -872,9 +872,9 @@ int usb_gadget_config_buf(const struct usb_config_descriptor *config,
/* utility wrapping a simple endpoint selection policy */

extern struct usb_ep *usb_ep_autoconfig (struct usb_gadget *,
struct usb_endpoint_descriptor *) __init;
struct usb_endpoint_descriptor *) __devinit;

extern void usb_ep_autoconfig_reset (struct usb_gadget *) __init;
extern void usb_ep_autoconfig_reset (struct usb_gadget *) __devinit;

#endif /* __KERNEL__ */

Expand Down

0 comments on commit a353678

Please sign in to comment.