Commit c9bfff9c authored by Uwe Kleine-König's avatar Uwe Kleine-König Committed by Greg Kroah-Hartman

usb gadget: don't save bind callback in struct usb_configuration

The bind function is most of the time only called at init time so there
is no need to save a pointer to it in the configuration structure.

This fixes many section mismatches reported by modpost.
Signed-off-by: default avatarUwe Kleine-König <u.kleine-koenig@pengutronix.de>
[m.nazarewicz@samsung.com: updated for -next]
Signed-off-by: default avatarMichał Nazarewicz <m.nazarewicz@samsung.com>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@suse.de>
parent 07a18bd7
...@@ -105,7 +105,6 @@ static int __init audio_do_config(struct usb_configuration *c) ...@@ -105,7 +105,6 @@ static int __init audio_do_config(struct usb_configuration *c)
static struct usb_configuration audio_config_driver = { static struct usb_configuration audio_config_driver = {
.label = DRIVER_DESC, .label = DRIVER_DESC,
.bind = audio_do_config,
.bConfigurationValue = 1, .bConfigurationValue = 1,
/* .iConfiguration = DYNAMIC */ /* .iConfiguration = DYNAMIC */
.bmAttributes = USB_CONFIG_ATT_SELFPOWER, .bmAttributes = USB_CONFIG_ATT_SELFPOWER,
...@@ -145,7 +144,7 @@ static int __init audio_bind(struct usb_composite_dev *cdev) ...@@ -145,7 +144,7 @@ static int __init audio_bind(struct usb_composite_dev *cdev)
strings_dev[STRING_PRODUCT_IDX].id = status; strings_dev[STRING_PRODUCT_IDX].id = status;
device_desc.iProduct = status; device_desc.iProduct = status;
status = usb_add_config(cdev, &audio_config_driver); status = usb_add_config(cdev, &audio_config_driver, audio_do_config);
if (status < 0) if (status < 0)
goto fail; goto fail;
......
...@@ -151,7 +151,6 @@ static int __init cdc_do_config(struct usb_configuration *c) ...@@ -151,7 +151,6 @@ static int __init cdc_do_config(struct usb_configuration *c)
static struct usb_configuration cdc_config_driver = { static struct usb_configuration cdc_config_driver = {
.label = "CDC Composite (ECM + ACM)", .label = "CDC Composite (ECM + ACM)",
.bind = cdc_do_config,
.bConfigurationValue = 1, .bConfigurationValue = 1,
/* .iConfiguration = DYNAMIC */ /* .iConfiguration = DYNAMIC */
.bmAttributes = USB_CONFIG_ATT_SELFPOWER, .bmAttributes = USB_CONFIG_ATT_SELFPOWER,
...@@ -218,7 +217,7 @@ static int __init cdc_bind(struct usb_composite_dev *cdev) ...@@ -218,7 +217,7 @@ static int __init cdc_bind(struct usb_composite_dev *cdev)
device_desc.iProduct = status; device_desc.iProduct = status;
/* register our configuration */ /* register our configuration */
status = usb_add_config(cdev, &cdc_config_driver); status = usb_add_config(cdev, &cdc_config_driver, cdc_do_config);
if (status < 0) if (status < 0)
goto fail1; goto fail1;
......
...@@ -474,18 +474,20 @@ static int set_config(struct usb_composite_dev *cdev, ...@@ -474,18 +474,20 @@ static int set_config(struct usb_composite_dev *cdev,
* usb_add_config() - add a configuration to a device. * usb_add_config() - add a configuration to a device.
* @cdev: wraps the USB gadget * @cdev: wraps the USB gadget
* @config: the configuration, with bConfigurationValue assigned * @config: the configuration, with bConfigurationValue assigned
* @bind: the configuration's bind function
* Context: single threaded during gadget setup * Context: single threaded during gadget setup
* *
* One of the main tasks of a composite driver's bind() routine is to * One of the main tasks of a composite @bind() routine is to
* add each of the configurations it supports, using this routine. * add each of the configurations it supports, using this routine.
* *
* This function returns the value of the configuration's bind(), which * This function returns the value of the configuration's @bind(), which
* is zero for success else a negative errno value. Binding configurations * is zero for success else a negative errno value. Binding configurations
* assigns global resources including string IDs, and per-configuration * assigns global resources including string IDs, and per-configuration
* resources such as interface IDs and endpoints. * resources such as interface IDs and endpoints.
*/ */
int usb_add_config(struct usb_composite_dev *cdev, int usb_add_config(struct usb_composite_dev *cdev,
struct usb_configuration *config) struct usb_configuration *config,
int (*bind)(struct usb_configuration *))
{ {
int status = -EINVAL; int status = -EINVAL;
struct usb_configuration *c; struct usb_configuration *c;
...@@ -494,7 +496,7 @@ int usb_add_config(struct usb_composite_dev *cdev, ...@@ -494,7 +496,7 @@ int usb_add_config(struct usb_composite_dev *cdev,
config->bConfigurationValue, config->bConfigurationValue,
config->label, config); config->label, config);
if (!config->bConfigurationValue || !config->bind) if (!config->bConfigurationValue || !bind)
goto done; goto done;
/* Prevent duplicate configuration identifiers */ /* Prevent duplicate configuration identifiers */
...@@ -511,7 +513,7 @@ int usb_add_config(struct usb_composite_dev *cdev, ...@@ -511,7 +513,7 @@ int usb_add_config(struct usb_composite_dev *cdev,
INIT_LIST_HEAD(&config->functions); INIT_LIST_HEAD(&config->functions);
config->next_interface_id = 0; config->next_interface_id = 0;
status = config->bind(config); status = bind(config);
if (status < 0) { if (status < 0) {
list_del(&config->list); list_del(&config->list);
config->cdev = NULL; config->cdev = NULL;
...@@ -537,7 +539,7 @@ int usb_add_config(struct usb_composite_dev *cdev, ...@@ -537,7 +539,7 @@ int usb_add_config(struct usb_composite_dev *cdev,
} }
} }
/* set_alt(), or next config->bind(), sets up /* set_alt(), or next bind(), sets up
* ep->driver_data as needed. * ep->driver_data as needed.
*/ */
usb_ep_autoconfig_reset(cdev->gadget); usb_ep_autoconfig_reset(cdev->gadget);
......
...@@ -251,7 +251,6 @@ static int __init rndis_do_config(struct usb_configuration *c) ...@@ -251,7 +251,6 @@ static int __init rndis_do_config(struct usb_configuration *c)
static struct usb_configuration rndis_config_driver = { static struct usb_configuration rndis_config_driver = {
.label = "RNDIS", .label = "RNDIS",
.bind = rndis_do_config,
.bConfigurationValue = 2, .bConfigurationValue = 2,
/* .iConfiguration = DYNAMIC */ /* .iConfiguration = DYNAMIC */
.bmAttributes = USB_CONFIG_ATT_SELFPOWER, .bmAttributes = USB_CONFIG_ATT_SELFPOWER,
...@@ -289,7 +288,6 @@ static int __init eth_do_config(struct usb_configuration *c) ...@@ -289,7 +288,6 @@ static int __init eth_do_config(struct usb_configuration *c)
static struct usb_configuration eth_config_driver = { static struct usb_configuration eth_config_driver = {
/* .label = f(hardware) */ /* .label = f(hardware) */
.bind = eth_do_config,
.bConfigurationValue = 1, .bConfigurationValue = 1,
/* .iConfiguration = DYNAMIC */ /* .iConfiguration = DYNAMIC */
.bmAttributes = USB_CONFIG_ATT_SELFPOWER, .bmAttributes = USB_CONFIG_ATT_SELFPOWER,
...@@ -373,12 +371,13 @@ static int __init eth_bind(struct usb_composite_dev *cdev) ...@@ -373,12 +371,13 @@ static int __init eth_bind(struct usb_composite_dev *cdev)
/* register our configuration(s); RNDIS first, if it's used */ /* register our configuration(s); RNDIS first, if it's used */
if (has_rndis()) { if (has_rndis()) {
status = usb_add_config(cdev, &rndis_config_driver); status = usb_add_config(cdev, &rndis_config_driver,
rndis_do_config);
if (status < 0) if (status < 0)
goto fail; goto fail;
} }
status = usb_add_config(cdev, &eth_config_driver); status = usb_add_config(cdev, &eth_config_driver, eth_do_config);
if (status < 0) if (status < 0)
goto fail; goto fail;
......
...@@ -349,7 +349,6 @@ static int __init loopback_bind_config(struct usb_configuration *c) ...@@ -349,7 +349,6 @@ static int __init loopback_bind_config(struct usb_configuration *c)
static struct usb_configuration loopback_driver = { static struct usb_configuration loopback_driver = {
.label = "loopback", .label = "loopback",
.strings = loopback_strings, .strings = loopback_strings,
.bind = loopback_bind_config,
.bConfigurationValue = 2, .bConfigurationValue = 2,
.bmAttributes = USB_CONFIG_ATT_SELFPOWER, .bmAttributes = USB_CONFIG_ATT_SELFPOWER,
/* .iConfiguration = DYNAMIC */ /* .iConfiguration = DYNAMIC */
...@@ -382,5 +381,5 @@ int __init loopback_add(struct usb_composite_dev *cdev, bool autoresume) ...@@ -382,5 +381,5 @@ int __init loopback_add(struct usb_composite_dev *cdev, bool autoresume)
loopback_driver.bmAttributes |= USB_CONFIG_ATT_WAKEUP; loopback_driver.bmAttributes |= USB_CONFIG_ATT_WAKEUP;
} }
return usb_add_config(cdev, &loopback_driver); return usb_add_config(cdev, &loopback_driver, loopback_bind_config);
} }
...@@ -498,7 +498,6 @@ static int sourcesink_setup(struct usb_configuration *c, ...@@ -498,7 +498,6 @@ static int sourcesink_setup(struct usb_configuration *c,
static struct usb_configuration sourcesink_driver = { static struct usb_configuration sourcesink_driver = {
.label = "source/sink", .label = "source/sink",
.strings = sourcesink_strings, .strings = sourcesink_strings,
.bind = sourcesink_bind_config,
.setup = sourcesink_setup, .setup = sourcesink_setup,
.bConfigurationValue = 3, .bConfigurationValue = 3,
.bmAttributes = USB_CONFIG_ATT_SELFPOWER, .bmAttributes = USB_CONFIG_ATT_SELFPOWER,
...@@ -532,5 +531,5 @@ int __init sourcesink_add(struct usb_composite_dev *cdev, bool autoresume) ...@@ -532,5 +531,5 @@ int __init sourcesink_add(struct usb_composite_dev *cdev, bool autoresume)
sourcesink_driver.bmAttributes |= USB_CONFIG_ATT_WAKEUP; sourcesink_driver.bmAttributes |= USB_CONFIG_ATT_WAKEUP;
} }
return usb_add_config(cdev, &sourcesink_driver); return usb_add_config(cdev, &sourcesink_driver, sourcesink_bind_config);
} }
...@@ -234,11 +234,10 @@ static int gfs_bind(struct usb_composite_dev *cdev) ...@@ -234,11 +234,10 @@ static int gfs_bind(struct usb_composite_dev *cdev)
c->c.label = gfs_strings[i].s; c->c.label = gfs_strings[i].s;
c->c.iConfiguration = gfs_strings[i].id; c->c.iConfiguration = gfs_strings[i].id;
c->c.bind = gfs_do_config;
c->c.bConfigurationValue = 1 + i; c->c.bConfigurationValue = 1 + i;
c->c.bmAttributes = USB_CONFIG_ATT_SELFPOWER; c->c.bmAttributes = USB_CONFIG_ATT_SELFPOWER;
ret = usb_add_config(cdev, &c->c); ret = usb_add_config(cdev, &c->c, gfs_do_config);
if (unlikely(ret < 0)) if (unlikely(ret < 0))
goto error_unbind; goto error_unbind;
} }
......
...@@ -148,7 +148,6 @@ static int __init do_config(struct usb_configuration *c) ...@@ -148,7 +148,6 @@ static int __init do_config(struct usb_configuration *c)
static struct usb_configuration config_driver = { static struct usb_configuration config_driver = {
.label = "HID Gadget", .label = "HID Gadget",
.bind = do_config,
.bConfigurationValue = 1, .bConfigurationValue = 1,
/* .iConfiguration = DYNAMIC */ /* .iConfiguration = DYNAMIC */
.bmAttributes = USB_CONFIG_ATT_SELFPOWER, .bmAttributes = USB_CONFIG_ATT_SELFPOWER,
...@@ -201,7 +200,7 @@ static int __init hid_bind(struct usb_composite_dev *cdev) ...@@ -201,7 +200,7 @@ static int __init hid_bind(struct usb_composite_dev *cdev)
device_desc.iProduct = status; device_desc.iProduct = status;
/* register our configuration */ /* register our configuration */
status = usb_add_config(cdev, &config_driver); status = usb_add_config(cdev, &config_driver, do_config);
if (status < 0) if (status < 0)
return status; return status;
......
...@@ -141,7 +141,6 @@ static int __init msg_do_config(struct usb_configuration *c) ...@@ -141,7 +141,6 @@ static int __init msg_do_config(struct usb_configuration *c)
static struct usb_configuration msg_config_driver = { static struct usb_configuration msg_config_driver = {
.label = "Linux File-Backed Storage", .label = "Linux File-Backed Storage",
.bind = msg_do_config,
.bConfigurationValue = 1, .bConfigurationValue = 1,
.bmAttributes = USB_CONFIG_ATT_SELFPOWER, .bmAttributes = USB_CONFIG_ATT_SELFPOWER,
}; };
...@@ -153,7 +152,7 @@ static int __init msg_bind(struct usb_composite_dev *cdev) ...@@ -153,7 +152,7 @@ static int __init msg_bind(struct usb_composite_dev *cdev)
{ {
int status; int status;
status = usb_add_config(cdev, &msg_config_driver); status = usb_add_config(cdev, &msg_config_driver, msg_do_config);
if (status < 0) if (status < 0)
return status; return status;
......
...@@ -164,7 +164,7 @@ static u8 hostaddr[ETH_ALEN]; ...@@ -164,7 +164,7 @@ static u8 hostaddr[ETH_ALEN];
#ifdef USB_ETH_RNDIS #ifdef USB_ETH_RNDIS
static __ref int rndis_do_config(struct usb_configuration *c) static __init int rndis_do_config(struct usb_configuration *c)
{ {
int ret; int ret;
...@@ -191,7 +191,6 @@ static __ref int rndis_do_config(struct usb_configuration *c) ...@@ -191,7 +191,6 @@ static __ref int rndis_do_config(struct usb_configuration *c)
static int rndis_config_register(struct usb_composite_dev *cdev) static int rndis_config_register(struct usb_composite_dev *cdev)
{ {
static struct usb_configuration config = { static struct usb_configuration config = {
.bind = rndis_do_config,
.bConfigurationValue = MULTI_RNDIS_CONFIG_NUM, .bConfigurationValue = MULTI_RNDIS_CONFIG_NUM,
.bmAttributes = USB_CONFIG_ATT_SELFPOWER, .bmAttributes = USB_CONFIG_ATT_SELFPOWER,
}; };
...@@ -199,7 +198,7 @@ static int rndis_config_register(struct usb_composite_dev *cdev) ...@@ -199,7 +198,7 @@ static int rndis_config_register(struct usb_composite_dev *cdev)
config.label = strings_dev[MULTI_STRING_RNDIS_CONFIG_IDX].s; config.label = strings_dev[MULTI_STRING_RNDIS_CONFIG_IDX].s;
config.iConfiguration = strings_dev[MULTI_STRING_RNDIS_CONFIG_IDX].id; config.iConfiguration = strings_dev[MULTI_STRING_RNDIS_CONFIG_IDX].id;
return usb_add_config(cdev, &config); return usb_add_config(cdev, &config, rndis_do_config);
} }
#else #else
...@@ -216,7 +215,7 @@ static int rndis_config_register(struct usb_composite_dev *cdev) ...@@ -216,7 +215,7 @@ static int rndis_config_register(struct usb_composite_dev *cdev)
#ifdef CONFIG_USB_G_MULTI_CDC #ifdef CONFIG_USB_G_MULTI_CDC
static __ref int cdc_do_config(struct usb_configuration *c) static __init int cdc_do_config(struct usb_configuration *c)
{ {
int ret; int ret;
...@@ -243,7 +242,6 @@ static __ref int cdc_do_config(struct usb_configuration *c) ...@@ -243,7 +242,6 @@ static __ref int cdc_do_config(struct usb_configuration *c)
static int cdc_config_register(struct usb_composite_dev *cdev) static int cdc_config_register(struct usb_composite_dev *cdev)
{ {
static struct usb_configuration config = { static struct usb_configuration config = {
.bind = cdc_do_config,
.bConfigurationValue = MULTI_CDC_CONFIG_NUM, .bConfigurationValue = MULTI_CDC_CONFIG_NUM,
.bmAttributes = USB_CONFIG_ATT_SELFPOWER, .bmAttributes = USB_CONFIG_ATT_SELFPOWER,
}; };
...@@ -251,7 +249,7 @@ static int cdc_config_register(struct usb_composite_dev *cdev) ...@@ -251,7 +249,7 @@ static int cdc_config_register(struct usb_composite_dev *cdev)
config.label = strings_dev[MULTI_STRING_CDC_CONFIG_IDX].s; config.label = strings_dev[MULTI_STRING_CDC_CONFIG_IDX].s;
config.iConfiguration = strings_dev[MULTI_STRING_CDC_CONFIG_IDX].id; config.iConfiguration = strings_dev[MULTI_STRING_CDC_CONFIG_IDX].id;
return usb_add_config(cdev, &config); return usb_add_config(cdev, &config, cdc_do_config);
} }
#else #else
......
...@@ -135,7 +135,6 @@ static int __init nokia_bind_config(struct usb_configuration *c) ...@@ -135,7 +135,6 @@ static int __init nokia_bind_config(struct usb_configuration *c)
static struct usb_configuration nokia_config_500ma_driver = { static struct usb_configuration nokia_config_500ma_driver = {
.label = "Bus Powered", .label = "Bus Powered",
.bind = nokia_bind_config,
.bConfigurationValue = 1, .bConfigurationValue = 1,
/* .iConfiguration = DYNAMIC */ /* .iConfiguration = DYNAMIC */
.bmAttributes = USB_CONFIG_ATT_ONE, .bmAttributes = USB_CONFIG_ATT_ONE,
...@@ -144,7 +143,6 @@ static struct usb_configuration nokia_config_500ma_driver = { ...@@ -144,7 +143,6 @@ static struct usb_configuration nokia_config_500ma_driver = {
static struct usb_configuration nokia_config_100ma_driver = { static struct usb_configuration nokia_config_100ma_driver = {
.label = "Self Powered", .label = "Self Powered",
.bind = nokia_bind_config,
.bConfigurationValue = 2, .bConfigurationValue = 2,
/* .iConfiguration = DYNAMIC */ /* .iConfiguration = DYNAMIC */
.bmAttributes = USB_CONFIG_ATT_ONE | USB_CONFIG_ATT_SELFPOWER, .bmAttributes = USB_CONFIG_ATT_ONE | USB_CONFIG_ATT_SELFPOWER,
...@@ -206,11 +204,13 @@ static int __init nokia_bind(struct usb_composite_dev *cdev) ...@@ -206,11 +204,13 @@ static int __init nokia_bind(struct usb_composite_dev *cdev)
} }
/* finaly register the configuration */ /* finaly register the configuration */
status = usb_add_config(cdev, &nokia_config_500ma_driver); status = usb_add_config(cdev, &nokia_config_500ma_driver,
nokia_bind_config);
if (status < 0) if (status < 0)
goto err_usb; goto err_usb;
status = usb_add_config(cdev, &nokia_config_100ma_driver); status = usb_add_config(cdev, &nokia_config_100ma_driver,
nokia_bind_config);
if (status < 0) if (status < 0)
goto err_usb; goto err_usb;
......
...@@ -155,7 +155,6 @@ static int __init serial_bind_config(struct usb_configuration *c) ...@@ -155,7 +155,6 @@ static int __init serial_bind_config(struct usb_configuration *c)
static struct usb_configuration serial_config_driver = { static struct usb_configuration serial_config_driver = {
/* .label = f(use_acm) */ /* .label = f(use_acm) */
.bind = serial_bind_config,
/* .bConfigurationValue = f(use_acm) */ /* .bConfigurationValue = f(use_acm) */
/* .iConfiguration = DYNAMIC */ /* .iConfiguration = DYNAMIC */
.bmAttributes = USB_CONFIG_ATT_SELFPOWER, .bmAttributes = USB_CONFIG_ATT_SELFPOWER,
...@@ -225,7 +224,8 @@ static int __init gs_bind(struct usb_composite_dev *cdev) ...@@ -225,7 +224,8 @@ static int __init gs_bind(struct usb_composite_dev *cdev)
} }
/* register our configuration */ /* register our configuration */
status = usb_add_config(cdev, &serial_config_driver); status = usb_add_config(cdev, &serial_config_driver,
serial_bind_config);
if (status < 0) if (status < 0)
goto fail; goto fail;
......
...@@ -317,7 +317,6 @@ webcam_config_bind(struct usb_configuration *c) ...@@ -317,7 +317,6 @@ webcam_config_bind(struct usb_configuration *c)
static struct usb_configuration webcam_config_driver = { static struct usb_configuration webcam_config_driver = {
.label = webcam_config_label, .label = webcam_config_label,
.bind = webcam_config_bind,
.bConfigurationValue = 1, .bConfigurationValue = 1,
.iConfiguration = 0, /* dynamic */ .iConfiguration = 0, /* dynamic */
.bmAttributes = USB_CONFIG_ATT_SELFPOWER, .bmAttributes = USB_CONFIG_ATT_SELFPOWER,
...@@ -354,7 +353,8 @@ webcam_bind(struct usb_composite_dev *cdev) ...@@ -354,7 +353,8 @@ webcam_bind(struct usb_composite_dev *cdev)
webcam_config_driver.iConfiguration = ret; webcam_config_driver.iConfiguration = ret;
/* Register our configuration. */ /* Register our configuration. */
if ((ret = usb_add_config(cdev, &webcam_config_driver)) < 0) if ((ret = usb_add_config(cdev, &webcam_config_driver,
webcam_config_bind)) < 0)
goto error; goto error;
INFO(cdev, "Webcam Video Gadget\n"); INFO(cdev, "Webcam Video Gadget\n");
......
...@@ -161,8 +161,6 @@ ep_choose(struct usb_gadget *g, struct usb_endpoint_descriptor *hs, ...@@ -161,8 +161,6 @@ ep_choose(struct usb_gadget *g, struct usb_endpoint_descriptor *hs,
* and by language IDs provided in control requests. * and by language IDs provided in control requests.
* @descriptors: Table of descriptors preceding all function descriptors. * @descriptors: Table of descriptors preceding all function descriptors.
* Examples include OTG and vendor-specific descriptors. * Examples include OTG and vendor-specific descriptors.
* @bind: Called from @usb_add_config() to allocate resources unique to this
* configuration and to call @usb_add_function() for each function used.
* @unbind: Reverses @bind; called as a side effect of unregistering the * @unbind: Reverses @bind; called as a side effect of unregistering the
* driver which added this configuration. * driver which added this configuration.
* @setup: Used to delegate control requests that aren't handled by standard * @setup: Used to delegate control requests that aren't handled by standard
...@@ -207,8 +205,7 @@ struct usb_configuration { ...@@ -207,8 +205,7 @@ struct usb_configuration {
* we can't restructure things to avoid mismatching... * we can't restructure things to avoid mismatching...
*/ */
/* configuration management: bind/unbind */ /* configuration management: unbind/setup */
int (*bind)(struct usb_configuration *);
void (*unbind)(struct usb_configuration *); void (*unbind)(struct usb_configuration *);
int (*setup)(struct usb_configuration *, int (*setup)(struct usb_configuration *,
const struct usb_ctrlrequest *); const struct usb_ctrlrequest *);
...@@ -232,7 +229,8 @@ struct usb_configuration { ...@@ -232,7 +229,8 @@ struct usb_configuration {
}; };
int usb_add_config(struct usb_composite_dev *, int usb_add_config(struct usb_composite_dev *,
struct usb_configuration *); struct usb_configuration *,
int (*)(struct usb_configuration *));
/** /**
* struct usb_composite_driver - groups configurations into a gadget * struct usb_composite_driver - groups configurations into a gadget
......
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