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

Commit 329af28b authored by David Brownell's avatar David Brownell Committed by Greg Kroah-Hartman
Browse files

[PATCH] USB: gadget driver section fixups



This adds __init section annotations to gadget driver bind() routines to
remove calls from .text into .init sections (for endpoint autoconfig).
Likewise it adds __exit section annotations to their unbind() routines.

The specification of the gadget driver register/unregister functions is
updated to explicitly allow use of those sections.

Signed-off-by: default avatarDavid Brownell <dbrownell@users.sourceforge.net>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@suse.de>
parent 43c5d5aa
Loading
Loading
Loading
Loading
+2 −2
Original line number Original line Diff line number Diff line
@@ -2125,7 +2125,7 @@ eth_req_free (struct usb_ep *ep, struct usb_request *req)
}
}




static void
static void __exit
eth_unbind (struct usb_gadget *gadget)
eth_unbind (struct usb_gadget *gadget)
{
{
	struct eth_dev		*dev = get_gadget_data (gadget);
	struct eth_dev		*dev = get_gadget_data (gadget);
@@ -2532,7 +2532,7 @@ static struct usb_gadget_driver eth_driver = {


	.function	= (char *) driver_desc,
	.function	= (char *) driver_desc,
	.bind		= eth_bind,
	.bind		= eth_bind,
	.unbind		= eth_unbind,
	.unbind		= __exit_p(eth_unbind),


	.setup		= eth_setup,
	.setup		= eth_setup,
	.disconnect	= eth_disconnect,
	.disconnect	= eth_disconnect,
+2 −2
Original line number Original line Diff line number Diff line
@@ -3678,7 +3678,7 @@ static void lun_release(struct device *dev)
	kref_put(&fsg->ref, fsg_release);
	kref_put(&fsg->ref, fsg_release);
}
}


static void fsg_unbind(struct usb_gadget *gadget)
static void __exit fsg_unbind(struct usb_gadget *gadget)
{
{
	struct fsg_dev		*fsg = get_gadget_data(gadget);
	struct fsg_dev		*fsg = get_gadget_data(gadget);
	int			i;
	int			i;
@@ -4064,7 +4064,7 @@ static struct usb_gadget_driver fsg_driver = {
#endif
#endif
	.function	= (char *) longname,
	.function	= (char *) longname,
	.bind		= fsg_bind,
	.bind		= fsg_bind,
	.unbind		= fsg_unbind,
	.unbind		= __exit_p(fsg_unbind),
	.disconnect	= fsg_disconnect,
	.disconnect	= fsg_disconnect,
	.setup		= fsg_setup,
	.setup		= fsg_setup,
	.suspend	= fsg_suspend,
	.suspend	= fsg_suspend,
+3 −3
Original line number Original line Diff line number Diff line
@@ -369,7 +369,7 @@ static struct usb_gadget_driver gs_gadget_driver = {
#endif /* CONFIG_USB_GADGET_DUALSPEED */
#endif /* CONFIG_USB_GADGET_DUALSPEED */
	.function =		GS_LONG_NAME,
	.function =		GS_LONG_NAME,
	.bind =			gs_bind,
	.bind =			gs_bind,
	.unbind =		gs_unbind,
	.unbind =		__exit_p(gs_unbind),
	.setup =		gs_setup,
	.setup =		gs_setup,
	.disconnect =		gs_disconnect,
	.disconnect =		gs_disconnect,
	.driver = {
	.driver = {
@@ -1413,7 +1413,7 @@ static void gs_write_complete(struct usb_ep *ep, struct usb_request *req)
 * Called on module load.  Allocates and initializes the device
 * Called on module load.  Allocates and initializes the device
 * structure and a control request.
 * structure and a control request.
 */
 */
static int gs_bind(struct usb_gadget *gadget)
static int __init gs_bind(struct usb_gadget *gadget)
{
{
	int ret;
	int ret;
	struct usb_ep *ep;
	struct usb_ep *ep;
@@ -1538,7 +1538,7 @@ static int gs_bind(struct usb_gadget *gadget)
 * Called on module unload.  Frees the control request and device
 * Called on module unload.  Frees the control request and device
 * structure.
 * structure.
 */
 */
static void gs_unbind(struct usb_gadget *gadget)
static void __exit gs_unbind(struct usb_gadget *gadget)
{
{
	struct gs_dev *dev = get_gadget_data(gadget);
	struct gs_dev *dev = get_gadget_data(gadget);


+3 −3
Original line number Original line Diff line number Diff line
@@ -1119,7 +1119,7 @@ zero_autoresume (unsigned long _dev)


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


static void
static void __exit
zero_unbind (struct usb_gadget *gadget)
zero_unbind (struct usb_gadget *gadget)
{
{
	struct zero_dev		*dev = get_gadget_data (gadget);
	struct zero_dev		*dev = get_gadget_data (gadget);
@@ -1136,7 +1136,7 @@ zero_unbind (struct usb_gadget *gadget)
	set_gadget_data (gadget, NULL);
	set_gadget_data (gadget, NULL);
}
}


static int
static int __init
zero_bind (struct usb_gadget *gadget)
zero_bind (struct usb_gadget *gadget)
{
{
	struct zero_dev		*dev;
	struct zero_dev		*dev;
@@ -1288,7 +1288,7 @@ static struct usb_gadget_driver zero_driver = {
#endif
#endif
	.function	= (char *) longname,
	.function	= (char *) longname,
	.bind		= zero_bind,
	.bind		= zero_bind,
	.unbind		= zero_unbind,
	.unbind		= __exit_p(zero_unbind),


	.setup		= zero_setup,
	.setup		= zero_setup,
	.disconnect	= zero_disconnect,
	.disconnect	= zero_disconnect,
+5 −2
Original line number Original line Diff line number Diff line
@@ -801,7 +801,9 @@ struct usb_gadget_driver {
 * Call this in your gadget driver's module initialization function,
 * Call this in your gadget driver's module initialization function,
 * to tell the underlying usb controller driver about your driver.
 * to tell the underlying usb controller driver about your driver.
 * The driver's bind() function will be called to bind it to a
 * The driver's bind() function will be called to bind it to a
 * gadget.  This function must be called in a context that can sleep.
 * gadget before this registration call returns.  It's expected that
 * the bind() functions will be in init sections.
 * This function must be called in a context that can sleep.
 */
 */
int usb_gadget_register_driver (struct usb_gadget_driver *driver);
int usb_gadget_register_driver (struct usb_gadget_driver *driver);


@@ -814,7 +816,8 @@ int usb_gadget_register_driver (struct usb_gadget_driver *driver);
 * going away.  If the controller is connected to a USB host,
 * going away.  If the controller is connected to a USB host,
 * it will first disconnect().  The driver is also requested
 * it will first disconnect().  The driver is also requested
 * to unbind() and clean up any device state, before this procedure
 * to unbind() and clean up any device state, before this procedure
 * finally returns.
 * finally returns.  It's expected that the unbind() functions
 * will in in exit sections, so may not be linked in some kernels.
 * This function must be called in a context that can sleep.
 * This function must be called in a context that can sleep.
 */
 */
int usb_gadget_unregister_driver (struct usb_gadget_driver *driver);
int usb_gadget_unregister_driver (struct usb_gadget_driver *driver);