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

Commit 07a18bd7 authored by Michal Nazarewicz's avatar Michal Nazarewicz Committed by Greg Kroah-Hartman
Browse files

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



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 composite driver structure.

This fixes many section mismatches reported by modpost.

Signed-off-by: default avatarMichał Nazarewicz <m.nazarewicz@samsung.com>
Acked-by: default avatarUwe Kleine-König <u.kleine-koenig@pengutronix.de>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@suse.de>
parent b0fca50f
Loading
Loading
Loading
Loading
+1 −2
Original line number Diff line number Diff line
@@ -166,13 +166,12 @@ static struct usb_composite_driver audio_driver = {
	.name		= "g_audio",
	.dev		= &device_desc,
	.strings	= audio_strings,
	.bind		= audio_bind,
	.unbind		= __exit_p(audio_unbind),
};

static int __init init(void)
{
	return usb_composite_register(&audio_driver);
	return usb_composite_probe(&audio_driver, audio_bind);
}
module_init(init);

+1 −2
Original line number Diff line number Diff line
@@ -245,7 +245,6 @@ static struct usb_composite_driver cdc_driver = {
	.name		= "g_cdc",
	.dev		= &device_desc,
	.strings	= dev_strings,
	.bind		= cdc_bind,
	.unbind		= __exit_p(cdc_unbind),
};

@@ -255,7 +254,7 @@ MODULE_LICENSE("GPL");

static int __init init(void)
{
	return usb_composite_register(&cdc_driver);
	return usb_composite_probe(&cdc_driver, cdc_bind);
}
module_init(init);

+11 −4
Original line number Diff line number Diff line
@@ -40,6 +40,7 @@
#define USB_BUFSIZ	1024

static struct usb_composite_driver *composite;
static int (*composite_gadget_bind)(struct usb_composite_dev *cdev);

/* Some systems will need runtime overrides for the  product identifers
 * published in the device descriptor, either numbers or strings or both.
@@ -1115,7 +1116,7 @@ static int composite_bind(struct usb_gadget *gadget)
	 * serial number), register function drivers, potentially update
	 * power state and consumption, etc
	 */
	status = composite->bind(cdev);
	status = composite_gadget_bind(cdev);
	if (status < 0)
		goto fail;

@@ -1227,8 +1228,12 @@ static struct usb_gadget_driver composite_driver = {
};

/**
 * usb_composite_register() - register a composite driver
 * usb_composite_probe() - register a composite driver
 * @driver: the driver to register
 * @bind: the callback used to allocate resources that are shared across the
 *	whole device, such as string IDs, and add its configurations using
 *	@usb_add_config().  This may fail by returning a negative errno
 *	value; it should return zero on successful initialization.
 * Context: single threaded during gadget setup
 *
 * This function is used to register drivers using the composite driver
@@ -1241,9 +1246,10 @@ static struct usb_gadget_driver composite_driver = {
 * while it was binding.  That would usually be done in order to wait for
 * some userspace participation.
 */
int usb_composite_register(struct usb_composite_driver *driver)
extern int usb_composite_probe(struct usb_composite_driver *driver,
			       int (*bind)(struct usb_composite_dev *cdev))
{
	if (!driver || !driver->dev || !driver->bind || composite)
	if (!driver || !driver->dev || !bind || composite)
		return -EINVAL;

	if (!driver->iProduct)
@@ -1253,6 +1259,7 @@ int usb_composite_register(struct usb_composite_driver *driver)
	composite_driver.function =  (char *) driver->name;
	composite_driver.driver.name = driver->name;
	composite = driver;
	composite_gadget_bind = bind;

	return usb_gadget_probe_driver(&composite_driver, composite_bind);
}
+1 −2
Original line number Diff line number Diff line
@@ -402,7 +402,6 @@ static struct usb_composite_driver eth_driver = {
	.name		= "g_ether",
	.dev		= &device_desc,
	.strings	= dev_strings,
	.bind		= eth_bind,
	.unbind		= __exit_p(eth_unbind),
};

@@ -412,7 +411,7 @@ MODULE_LICENSE("GPL");

static int __init init(void)
{
	return usb_composite_register(&eth_driver);
	return usb_composite_probe(&eth_driver, eth_bind);
}
module_init(init);

+1 −2
Original line number Diff line number Diff line
@@ -147,7 +147,6 @@ static struct usb_composite_driver gfs_driver = {
	.name		= DRIVER_NAME,
	.dev		= &gfs_dev_desc,
	.strings	= gfs_dev_strings,
	.bind		= gfs_bind,
	.unbind		= gfs_unbind,
	.iProduct	= DRIVER_DESC,
};
@@ -187,7 +186,7 @@ static int functionfs_ready_callback(struct ffs_data *ffs)
		return -EBUSY;

	gfs_ffs_data = ffs;
	ret = usb_composite_register(&gfs_driver);
	ret = usb_composite_probe(&gfs_driver, gfs_bind);
	if (unlikely(ret < 0))
		clear_bit(0, &gfs_registered);
	return ret;
Loading