static struct usb_configuration audio_config_driver = {
.label = DRIVER_DESC,
- .bind = audio_do_config,
.bConfigurationValue = 1,
/* .iConfiguration = DYNAMIC */
.bmAttributes = USB_CONFIG_ATT_SELFPOWER,
strings_dev[STRING_PRODUCT_IDX].id = 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)
goto fail;
static struct usb_configuration cdc_config_driver = {
.label = "CDC Composite (ECM + ACM)",
- .bind = cdc_do_config,
.bConfigurationValue = 1,
/* .iConfiguration = DYNAMIC */
.bmAttributes = USB_CONFIG_ATT_SELFPOWER,
device_desc.iProduct = status;
/* 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)
goto fail1;
* usb_add_config() - add a configuration to a device.
* @cdev: wraps the USB gadget
* @config: the configuration, with bConfigurationValue assigned
+ * @bind: the configuration's bind function
* 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.
*
- * 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
* assigns global resources including string IDs, and per-configuration
* resources such as interface IDs and endpoints.
*/
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;
struct usb_configuration *c;
config->bConfigurationValue,
config->label, config);
- if (!config->bConfigurationValue || !config->bind)
+ if (!config->bConfigurationValue || !bind)
goto done;
/* Prevent duplicate configuration identifiers */
INIT_LIST_HEAD(&config->functions);
config->next_interface_id = 0;
- status = config->bind(config);
+ status = bind(config);
if (status < 0) {
list_del(&config->list);
config->cdev = NULL;
}
}
- /* set_alt(), or next config->bind(), sets up
+ /* set_alt(), or next bind(), sets up
* ep->driver_data as needed.
*/
usb_ep_autoconfig_reset(cdev->gadget);
static struct usb_configuration rndis_config_driver = {
.label = "RNDIS",
- .bind = rndis_do_config,
.bConfigurationValue = 2,
/* .iConfiguration = DYNAMIC */
.bmAttributes = USB_CONFIG_ATT_SELFPOWER,
static struct usb_configuration eth_config_driver = {
/* .label = f(hardware) */
- .bind = eth_do_config,
.bConfigurationValue = 1,
/* .iConfiguration = DYNAMIC */
.bmAttributes = USB_CONFIG_ATT_SELFPOWER,
/* register our configuration(s); RNDIS first, if it's used */
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)
goto fail;
}
- status = usb_add_config(cdev, ð_config_driver);
+ status = usb_add_config(cdev, ð_config_driver, eth_do_config);
if (status < 0)
goto fail;
static struct usb_configuration loopback_driver = {
.label = "loopback",
.strings = loopback_strings,
- .bind = loopback_bind_config,
.bConfigurationValue = 2,
.bmAttributes = USB_CONFIG_ATT_SELFPOWER,
/* .iConfiguration = DYNAMIC */
loopback_driver.bmAttributes |= USB_CONFIG_ATT_WAKEUP;
}
- return usb_add_config(cdev, &loopback_driver);
+ return usb_add_config(cdev, &loopback_driver, loopback_bind_config);
}
static struct usb_configuration sourcesink_driver = {
.label = "source/sink",
.strings = sourcesink_strings,
- .bind = sourcesink_bind_config,
.setup = sourcesink_setup,
.bConfigurationValue = 3,
.bmAttributes = USB_CONFIG_ATT_SELFPOWER,
sourcesink_driver.bmAttributes |= USB_CONFIG_ATT_WAKEUP;
}
- return usb_add_config(cdev, &sourcesink_driver);
+ return usb_add_config(cdev, &sourcesink_driver, sourcesink_bind_config);
}
c->c.label = gfs_strings[i].s;
c->c.iConfiguration = gfs_strings[i].id;
- c->c.bind = gfs_do_config;
c->c.bConfigurationValue = 1 + i;
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))
goto error_unbind;
}
static struct usb_configuration config_driver = {
.label = "HID Gadget",
- .bind = do_config,
.bConfigurationValue = 1,
/* .iConfiguration = DYNAMIC */
.bmAttributes = USB_CONFIG_ATT_SELFPOWER,
device_desc.iProduct = status;
/* register our configuration */
- status = usb_add_config(cdev, &config_driver);
+ status = usb_add_config(cdev, &config_driver, do_config);
if (status < 0)
return status;
static struct usb_configuration msg_config_driver = {
.label = "Linux File-Backed Storage",
- .bind = msg_do_config,
.bConfigurationValue = 1,
.bmAttributes = USB_CONFIG_ATT_SELFPOWER,
};
{
int status;
- status = usb_add_config(cdev, &msg_config_driver);
+ status = usb_add_config(cdev, &msg_config_driver, msg_do_config);
if (status < 0)
return status;
#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;
static int rndis_config_register(struct usb_composite_dev *cdev)
{
static struct usb_configuration config = {
- .bind = rndis_do_config,
.bConfigurationValue = MULTI_RNDIS_CONFIG_NUM,
.bmAttributes = USB_CONFIG_ATT_SELFPOWER,
};
config.label = strings_dev[MULTI_STRING_RNDIS_CONFIG_IDX].s;
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
#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;
static int cdc_config_register(struct usb_composite_dev *cdev)
{
static struct usb_configuration config = {
- .bind = cdc_do_config,
.bConfigurationValue = MULTI_CDC_CONFIG_NUM,
.bmAttributes = USB_CONFIG_ATT_SELFPOWER,
};
config.label = strings_dev[MULTI_STRING_CDC_CONFIG_IDX].s;
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
static struct usb_configuration nokia_config_500ma_driver = {
.label = "Bus Powered",
- .bind = nokia_bind_config,
.bConfigurationValue = 1,
/* .iConfiguration = DYNAMIC */
.bmAttributes = USB_CONFIG_ATT_ONE,
static struct usb_configuration nokia_config_100ma_driver = {
.label = "Self Powered",
- .bind = nokia_bind_config,
.bConfigurationValue = 2,
/* .iConfiguration = DYNAMIC */
.bmAttributes = USB_CONFIG_ATT_ONE | USB_CONFIG_ATT_SELFPOWER,
}
/* 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)
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)
goto err_usb;
static struct usb_configuration serial_config_driver = {
/* .label = f(use_acm) */
- .bind = serial_bind_config,
/* .bConfigurationValue = f(use_acm) */
/* .iConfiguration = DYNAMIC */
.bmAttributes = USB_CONFIG_ATT_SELFPOWER,
}
/* 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)
goto fail;
static struct usb_configuration webcam_config_driver = {
.label = webcam_config_label,
- .bind = webcam_config_bind,
.bConfigurationValue = 1,
.iConfiguration = 0, /* dynamic */
.bmAttributes = USB_CONFIG_ATT_SELFPOWER,
webcam_config_driver.iConfiguration = ret;
/* 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;
INFO(cdev, "Webcam Video Gadget\n");
* and by language IDs provided in control requests.
* @descriptors: Table of descriptors preceding all function 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
* driver which added this configuration.
* @setup: Used to delegate control requests that aren't handled by standard
* we can't restructure things to avoid mismatching...
*/
- /* configuration management: bind/unbind */
- int (*bind)(struct usb_configuration *);
+ /* configuration management: unbind/setup */
void (*unbind)(struct usb_configuration *);
int (*setup)(struct usb_configuration *,
const struct usb_ctrlrequest *);
};
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