Skip to content

Commit

Permalink
usb: gadget: remove incorrect __init/__exit annotations
Browse files Browse the repository at this point in the history
A recent change introduced a link error for the composite
printer gadget driver:

`printer_unbind' referenced in section `.ref.data' of drivers/built-in.o: defined in discarded section `.exit.text' of drivers/built-in.o

Evidently the unbind function should not be marked __exit here,
because it is called through a callback pointer that is not necessarily
discarded, __composite_unbind() is indeed called from the error path of
composite_bind(), which can never work for a built-in driver.

Looking at the surrounding code, I found the same problem in all other
composite gadget drivers in both the bind and unbind functions, as
well as the udc platform driver 'remove' functions. Those will break
if anyone uses the 'unbind' sysfs attribute to detach a device from a
built-in driver.

This patch removes the incorrect annotations from all the gadget
drivers.

Signed-off-by: Arnd Bergmann <arnd@arndb.de>
Signed-off-by: Felipe Balbi <balbi@ti.com>
  • Loading branch information
Arnd Bergmann authored and Felipe Balbi committed Apr 27, 2015
1 parent 197d0bd commit c94e289
Show file tree
Hide file tree
Showing 23 changed files with 78 additions and 78 deletions.
10 changes: 5 additions & 5 deletions drivers/usb/gadget/legacy/acm_ms.c
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ static struct usb_function *f_msg;
/*
* We _always_ have both ACM and mass storage functions.
*/
static int __init acm_ms_do_config(struct usb_configuration *c)
static int acm_ms_do_config(struct usb_configuration *c)
{
struct fsg_opts *opts;
int status;
Expand Down Expand Up @@ -174,7 +174,7 @@ static struct usb_configuration acm_ms_config_driver = {

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

static int __init acm_ms_bind(struct usb_composite_dev *cdev)
static int acm_ms_bind(struct usb_composite_dev *cdev)
{
struct usb_gadget *gadget = cdev->gadget;
struct fsg_opts *opts;
Expand Down Expand Up @@ -249,7 +249,7 @@ static int __init acm_ms_bind(struct usb_composite_dev *cdev)
return status;
}

static int __exit acm_ms_unbind(struct usb_composite_dev *cdev)
static int acm_ms_unbind(struct usb_composite_dev *cdev)
{
usb_put_function(f_msg);
usb_put_function_instance(fi_msg);
Expand All @@ -258,13 +258,13 @@ static int __exit acm_ms_unbind(struct usb_composite_dev *cdev)
return 0;
}

static __refdata struct usb_composite_driver acm_ms_driver = {
static struct usb_composite_driver acm_ms_driver = {
.name = "g_acm_ms",
.dev = &device_desc,
.max_speed = USB_SPEED_SUPER,
.strings = dev_strings,
.bind = acm_ms_bind,
.unbind = __exit_p(acm_ms_unbind),
.unbind = acm_ms_unbind,
};

module_usb_composite_driver(acm_ms_driver);
Expand Down
10 changes: 5 additions & 5 deletions drivers/usb/gadget/legacy/audio.c
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ static const struct usb_descriptor_header *otg_desc[] = {

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

static int __init audio_do_config(struct usb_configuration *c)
static int audio_do_config(struct usb_configuration *c)
{
int status;

Expand Down Expand Up @@ -216,7 +216,7 @@ static struct usb_configuration audio_config_driver = {

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

static int __init audio_bind(struct usb_composite_dev *cdev)
static int audio_bind(struct usb_composite_dev *cdev)
{
#ifndef CONFIG_GADGET_UAC1
struct f_uac2_opts *uac2_opts;
Expand Down Expand Up @@ -276,7 +276,7 @@ static int __init audio_bind(struct usb_composite_dev *cdev)
return status;
}

static int __exit audio_unbind(struct usb_composite_dev *cdev)
static int audio_unbind(struct usb_composite_dev *cdev)
{
#ifdef CONFIG_GADGET_UAC1
if (!IS_ERR_OR_NULL(f_uac1))
Expand All @@ -292,13 +292,13 @@ static int __exit audio_unbind(struct usb_composite_dev *cdev)
return 0;
}

static __refdata struct usb_composite_driver audio_driver = {
static struct usb_composite_driver audio_driver = {
.name = "g_audio",
.dev = &device_desc,
.strings = audio_strings,
.max_speed = USB_SPEED_HIGH,
.bind = audio_bind,
.unbind = __exit_p(audio_unbind),
.unbind = audio_unbind,
};

module_usb_composite_driver(audio_driver);
Expand Down
10 changes: 5 additions & 5 deletions drivers/usb/gadget/legacy/cdc2.c
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ static struct usb_function_instance *fi_ecm;
/*
* We _always_ have both CDC ECM and CDC ACM functions.
*/
static int __init cdc_do_config(struct usb_configuration *c)
static int cdc_do_config(struct usb_configuration *c)
{
int status;

Expand Down Expand Up @@ -153,7 +153,7 @@ static struct usb_configuration cdc_config_driver = {

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

static int __init cdc_bind(struct usb_composite_dev *cdev)
static int cdc_bind(struct usb_composite_dev *cdev)
{
struct usb_gadget *gadget = cdev->gadget;
struct f_ecm_opts *ecm_opts;
Expand Down Expand Up @@ -211,7 +211,7 @@ static int __init cdc_bind(struct usb_composite_dev *cdev)
return status;
}

static int __exit cdc_unbind(struct usb_composite_dev *cdev)
static int cdc_unbind(struct usb_composite_dev *cdev)
{
usb_put_function(f_acm);
usb_put_function_instance(fi_serial);
Expand All @@ -222,13 +222,13 @@ static int __exit cdc_unbind(struct usb_composite_dev *cdev)
return 0;
}

static __refdata struct usb_composite_driver cdc_driver = {
static struct usb_composite_driver cdc_driver = {
.name = "g_cdc",
.dev = &device_desc,
.strings = dev_strings,
.max_speed = USB_SPEED_HIGH,
.bind = cdc_bind,
.unbind = __exit_p(cdc_unbind),
.unbind = cdc_unbind,
};

module_usb_composite_driver(cdc_driver);
Expand Down
4 changes: 2 additions & 2 deletions drivers/usb/gadget/legacy/dbgp.c
Original file line number Diff line number Diff line change
Expand Up @@ -284,7 +284,7 @@ static int dbgp_configure_endpoints(struct usb_gadget *gadget)
return -ENODEV;
}

static int __init dbgp_bind(struct usb_gadget *gadget,
static int dbgp_bind(struct usb_gadget *gadget,
struct usb_gadget_driver *driver)
{
int err, stp;
Expand Down Expand Up @@ -406,7 +406,7 @@ static int dbgp_setup(struct usb_gadget *gadget,
return err;
}

static __refdata struct usb_gadget_driver dbgp_driver = {
static struct usb_gadget_driver dbgp_driver = {
.function = "dbgp",
.max_speed = USB_SPEED_HIGH,
.bind = dbgp_bind,
Expand Down
12 changes: 6 additions & 6 deletions drivers/usb/gadget/legacy/ether.c
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,7 @@ static struct usb_function *f_rndis;
* the first one present. That's to make Microsoft's drivers happy,
* and to follow DOCSIS 1.0 (cable modem standard).
*/
static int __init rndis_do_config(struct usb_configuration *c)
static int rndis_do_config(struct usb_configuration *c)
{
int status;

Expand Down Expand Up @@ -264,7 +264,7 @@ MODULE_PARM_DESC(use_eem, "use CDC EEM mode");
/*
* We _always_ have an ECM, CDC Subset, or EEM configuration.
*/
static int __init eth_do_config(struct usb_configuration *c)
static int eth_do_config(struct usb_configuration *c)
{
int status = 0;

Expand Down Expand Up @@ -318,7 +318,7 @@ static struct usb_configuration eth_config_driver = {

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

static int __init eth_bind(struct usb_composite_dev *cdev)
static int eth_bind(struct usb_composite_dev *cdev)
{
struct usb_gadget *gadget = cdev->gadget;
struct f_eem_opts *eem_opts = NULL;
Expand Down Expand Up @@ -447,7 +447,7 @@ static int __init eth_bind(struct usb_composite_dev *cdev)
return status;
}

static int __exit eth_unbind(struct usb_composite_dev *cdev)
static int eth_unbind(struct usb_composite_dev *cdev)
{
if (has_rndis()) {
usb_put_function(f_rndis);
Expand All @@ -466,13 +466,13 @@ static int __exit eth_unbind(struct usb_composite_dev *cdev)
return 0;
}

static __refdata struct usb_composite_driver eth_driver = {
static struct usb_composite_driver eth_driver = {
.name = "g_ether",
.dev = &device_desc,
.strings = dev_strings,
.max_speed = USB_SPEED_SUPER,
.bind = eth_bind,
.unbind = __exit_p(eth_unbind),
.unbind = eth_unbind,
};

module_usb_composite_driver(eth_driver);
Expand Down
2 changes: 1 addition & 1 deletion drivers/usb/gadget/legacy/g_ffs.c
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ static int gfs_unbind(struct usb_composite_dev *cdev);
static int gfs_do_config(struct usb_configuration *c);


static __refdata struct usb_composite_driver gfs_driver = {
static struct usb_composite_driver gfs_driver = {
.name = DRIVER_NAME,
.dev = &gfs_dev_desc,
.strings = gfs_dev_strings,
Expand Down
10 changes: 5 additions & 5 deletions drivers/usb/gadget/legacy/gmidi.c
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ static struct usb_gadget_strings *dev_strings[] = {
static struct usb_function_instance *fi_midi;
static struct usb_function *f_midi;

static int __exit midi_unbind(struct usb_composite_dev *dev)
static int midi_unbind(struct usb_composite_dev *dev)
{
usb_put_function(f_midi);
usb_put_function_instance(fi_midi);
Expand All @@ -133,7 +133,7 @@ static struct usb_configuration midi_config = {
.MaxPower = CONFIG_USB_GADGET_VBUS_DRAW,
};

static int __init midi_bind_config(struct usb_configuration *c)
static int midi_bind_config(struct usb_configuration *c)
{
int status;

Expand All @@ -150,7 +150,7 @@ static int __init midi_bind_config(struct usb_configuration *c)
return 0;
}

static int __init midi_bind(struct usb_composite_dev *cdev)
static int midi_bind(struct usb_composite_dev *cdev)
{
struct f_midi_opts *midi_opts;
int status;
Expand Down Expand Up @@ -185,13 +185,13 @@ static int __init midi_bind(struct usb_composite_dev *cdev)
return status;
}

static __refdata struct usb_composite_driver midi_driver = {
static struct usb_composite_driver midi_driver = {
.name = (char *) longname,
.dev = &device_desc,
.strings = dev_strings,
.max_speed = USB_SPEED_HIGH,
.bind = midi_bind,
.unbind = __exit_p(midi_unbind),
.unbind = midi_unbind,
};

module_usb_composite_driver(midi_driver);
12 changes: 6 additions & 6 deletions drivers/usb/gadget/legacy/hid.c
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ static struct usb_gadget_strings *dev_strings[] = {

/****************************** Configurations ******************************/

static int __init do_config(struct usb_configuration *c)
static int do_config(struct usb_configuration *c)
{
struct hidg_func_node *e, *n;
int status = 0;
Expand Down Expand Up @@ -147,7 +147,7 @@ static struct usb_configuration config_driver = {

/****************************** Gadget Bind ******************************/

static int __init hid_bind(struct usb_composite_dev *cdev)
static int hid_bind(struct usb_composite_dev *cdev)
{
struct usb_gadget *gadget = cdev->gadget;
struct list_head *tmp;
Expand Down Expand Up @@ -205,7 +205,7 @@ static int __init hid_bind(struct usb_composite_dev *cdev)
return status;
}

static int __exit hid_unbind(struct usb_composite_dev *cdev)
static int hid_unbind(struct usb_composite_dev *cdev)
{
struct hidg_func_node *n;

Expand All @@ -216,7 +216,7 @@ static int __exit hid_unbind(struct usb_composite_dev *cdev)
return 0;
}

static int __init hidg_plat_driver_probe(struct platform_device *pdev)
static int hidg_plat_driver_probe(struct platform_device *pdev)
{
struct hidg_func_descriptor *func = dev_get_platdata(&pdev->dev);
struct hidg_func_node *entry;
Expand Down Expand Up @@ -252,13 +252,13 @@ static int hidg_plat_driver_remove(struct platform_device *pdev)
/****************************** Some noise ******************************/


static __refdata struct usb_composite_driver hidg_driver = {
static struct usb_composite_driver hidg_driver = {
.name = "g_hid",
.dev = &device_desc,
.strings = dev_strings,
.max_speed = USB_SPEED_HIGH,
.bind = hid_bind,
.unbind = __exit_p(hid_unbind),
.unbind = hid_unbind,
};

static struct platform_driver hidg_plat_driver = {
Expand Down
6 changes: 3 additions & 3 deletions drivers/usb/gadget/legacy/mass_storage.c
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ static int msg_thread_exits(struct fsg_common *common)
return 0;
}

static int __init msg_do_config(struct usb_configuration *c)
static int msg_do_config(struct usb_configuration *c)
{
struct fsg_opts *opts;
int ret;
Expand Down Expand Up @@ -170,7 +170,7 @@ static struct usb_configuration msg_config_driver = {

/****************************** Gadget Bind ******************************/

static int __init msg_bind(struct usb_composite_dev *cdev)
static int msg_bind(struct usb_composite_dev *cdev)
{
static const struct fsg_operations ops = {
.thread_exits = msg_thread_exits,
Expand Down Expand Up @@ -248,7 +248,7 @@ static int msg_unbind(struct usb_composite_dev *cdev)

/****************************** Some noise ******************************/

static __refdata struct usb_composite_driver msg_driver = {
static struct usb_composite_driver msg_driver = {
.name = "g_mass_storage",
.dev = &msg_device_desc,
.max_speed = USB_SPEED_SUPER,
Expand Down
10 changes: 5 additions & 5 deletions drivers/usb/gadget/legacy/multi.c
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ static struct usb_function *f_acm_rndis;
static struct usb_function *f_rndis;
static struct usb_function *f_msg_rndis;

static __init int rndis_do_config(struct usb_configuration *c)
static int rndis_do_config(struct usb_configuration *c)
{
struct fsg_opts *fsg_opts;
int ret;
Expand Down Expand Up @@ -237,7 +237,7 @@ static struct usb_function *f_acm_multi;
static struct usb_function *f_ecm;
static struct usb_function *f_msg_multi;

static __init int cdc_do_config(struct usb_configuration *c)
static int cdc_do_config(struct usb_configuration *c)
{
struct fsg_opts *fsg_opts;
int ret;
Expand Down Expand Up @@ -466,7 +466,7 @@ static int __ref multi_bind(struct usb_composite_dev *cdev)
return status;
}

static int __exit multi_unbind(struct usb_composite_dev *cdev)
static int multi_unbind(struct usb_composite_dev *cdev)
{
#ifdef CONFIG_USB_G_MULTI_CDC
usb_put_function(f_msg_multi);
Expand Down Expand Up @@ -497,13 +497,13 @@ static int __exit multi_unbind(struct usb_composite_dev *cdev)
/****************************** Some noise ******************************/


static __refdata struct usb_composite_driver multi_driver = {
static struct usb_composite_driver multi_driver = {
.name = "g_multi",
.dev = &device_desc,
.strings = dev_strings,
.max_speed = USB_SPEED_HIGH,
.bind = multi_bind,
.unbind = __exit_p(multi_unbind),
.unbind = multi_unbind,
.needs_serial = 1,
};

Expand Down
Loading

0 comments on commit c94e289

Please sign in to comment.