Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

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

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
Loading
Loading
Loading
Loading
+1 −2
Original line number Diff line number Diff line
@@ -105,7 +105,6 @@ static int __init audio_do_config(struct usb_configuration *c)

static struct usb_configuration audio_config_driver = {
	.label			= DRIVER_DESC,
	.bind			= audio_do_config,
	.bConfigurationValue	= 1,
	/* .iConfiguration = DYNAMIC */
	.bmAttributes		= USB_CONFIG_ATT_SELFPOWER,
@@ -145,7 +144,7 @@ static int __init audio_bind(struct usb_composite_dev *cdev)
	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;

+1 −2
Original line number Diff line number Diff line
@@ -151,7 +151,6 @@ static int __init cdc_do_config(struct usb_configuration *c)

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,
@@ -218,7 +217,7 @@ static int __init cdc_bind(struct usb_composite_dev *cdev)
	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;

+8 −6
Original line number Diff line number Diff line
@@ -474,18 +474,20 @@ static int set_config(struct usb_composite_dev *cdev,
 * 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;
@@ -494,7 +496,7 @@ int usb_add_config(struct usb_composite_dev *cdev,
			config->bConfigurationValue,
			config->label, config);

	if (!config->bConfigurationValue || !config->bind)
	if (!config->bConfigurationValue || !bind)
		goto done;

	/* Prevent duplicate configuration identifiers */
@@ -511,7 +513,7 @@ int usb_add_config(struct usb_composite_dev *cdev,
	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;
@@ -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.
	 */
	usb_ep_autoconfig_reset(cdev->gadget);
+3 −4
Original line number Diff line number Diff line
@@ -251,7 +251,6 @@ static int __init rndis_do_config(struct usb_configuration *c)

static struct usb_configuration rndis_config_driver = {
	.label			= "RNDIS",
	.bind			= rndis_do_config,
	.bConfigurationValue	= 2,
	/* .iConfiguration = DYNAMIC */
	.bmAttributes		= USB_CONFIG_ATT_SELFPOWER,
@@ -289,7 +288,6 @@ static int __init eth_do_config(struct usb_configuration *c)

static struct usb_configuration eth_config_driver = {
	/* .label = f(hardware) */
	.bind			= eth_do_config,
	.bConfigurationValue	= 1,
	/* .iConfiguration = DYNAMIC */
	.bmAttributes		= USB_CONFIG_ATT_SELFPOWER,
@@ -373,12 +371,13 @@ static int __init eth_bind(struct usb_composite_dev *cdev)

	/* 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, &eth_config_driver);
	status = usb_add_config(cdev, &eth_config_driver, eth_do_config);
	if (status < 0)
		goto fail;

+1 −2
Original line number Diff line number Diff line
@@ -349,7 +349,6 @@ static int __init loopback_bind_config(struct usb_configuration *c)
static struct usb_configuration loopback_driver = {
	.label		= "loopback",
	.strings	= loopback_strings,
	.bind		= loopback_bind_config,
	.bConfigurationValue = 2,
	.bmAttributes	= USB_CONFIG_ATT_SELFPOWER,
	/* .iConfiguration = DYNAMIC */
@@ -382,5 +381,5 @@ int __init loopback_add(struct usb_composite_dev *cdev, bool autoresume)
		loopback_driver.bmAttributes |= USB_CONFIG_ATT_WAKEUP;
	}

	return usb_add_config(cdev, &loopback_driver);
	return usb_add_config(cdev, &loopback_driver, loopback_bind_config);
}
Loading