aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDavid Brownell <david-b@pacbell.net>2006-02-18 15:31:05 -0500
committerGreg Kroah-Hartman <gregkh@suse.de>2006-03-20 17:49:58 -0500
commit329af28b141ab4ae847aff1362864c4cc332641f (patch)
treec4871a6065ed635998204efef0a63fda8c3dbfcc
parent43c5d5aaafef56618a6efbcab7f91615da1a8659 (diff)
[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: David Brownell <dbrownell@users.sourceforge.net> Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
-rw-r--r--drivers/usb/gadget/ether.c4
-rw-r--r--drivers/usb/gadget/file_storage.c4
-rw-r--r--drivers/usb/gadget/serial.c6
-rw-r--r--drivers/usb/gadget/zero.c6
-rw-r--r--include/linux/usb_gadget.h7
5 files changed, 15 insertions, 12 deletions
diff --git a/drivers/usb/gadget/ether.c b/drivers/usb/gadget/ether.c
index 3d2603e31808..0d9d9bbb73f0 100644
--- a/drivers/usb/gadget/ether.c
+++ b/drivers/usb/gadget/ether.c
@@ -2125,7 +2125,7 @@ eth_req_free (struct usb_ep *ep, struct usb_request *req)
2125} 2125}
2126 2126
2127 2127
2128static void 2128static void __exit
2129eth_unbind (struct usb_gadget *gadget) 2129eth_unbind (struct usb_gadget *gadget)
2130{ 2130{
2131 struct eth_dev *dev = get_gadget_data (gadget); 2131 struct eth_dev *dev = get_gadget_data (gadget);
@@ -2532,7 +2532,7 @@ static struct usb_gadget_driver eth_driver = {
2532 2532
2533 .function = (char *) driver_desc, 2533 .function = (char *) driver_desc,
2534 .bind = eth_bind, 2534 .bind = eth_bind,
2535 .unbind = eth_unbind, 2535 .unbind = __exit_p(eth_unbind),
2536 2536
2537 .setup = eth_setup, 2537 .setup = eth_setup,
2538 .disconnect = eth_disconnect, 2538 .disconnect = eth_disconnect,
diff --git a/drivers/usb/gadget/file_storage.c b/drivers/usb/gadget/file_storage.c
index de59c58896d6..cf3be299e353 100644
--- a/drivers/usb/gadget/file_storage.c
+++ b/drivers/usb/gadget/file_storage.c
@@ -3678,7 +3678,7 @@ static void lun_release(struct device *dev)
3678 kref_put(&fsg->ref, fsg_release); 3678 kref_put(&fsg->ref, fsg_release);
3679} 3679}
3680 3680
3681static void fsg_unbind(struct usb_gadget *gadget) 3681static void __exit fsg_unbind(struct usb_gadget *gadget)
3682{ 3682{
3683 struct fsg_dev *fsg = get_gadget_data(gadget); 3683 struct fsg_dev *fsg = get_gadget_data(gadget);
3684 int i; 3684 int i;
@@ -4064,7 +4064,7 @@ static struct usb_gadget_driver fsg_driver = {
4064#endif 4064#endif
4065 .function = (char *) longname, 4065 .function = (char *) longname,
4066 .bind = fsg_bind, 4066 .bind = fsg_bind,
4067 .unbind = fsg_unbind, 4067 .unbind = __exit_p(fsg_unbind),
4068 .disconnect = fsg_disconnect, 4068 .disconnect = fsg_disconnect,
4069 .setup = fsg_setup, 4069 .setup = fsg_setup,
4070 .suspend = fsg_suspend, 4070 .suspend = fsg_suspend,
diff --git a/drivers/usb/gadget/serial.c b/drivers/usb/gadget/serial.c
index ba9acd531024..548feaac4553 100644
--- a/drivers/usb/gadget/serial.c
+++ b/drivers/usb/gadget/serial.c
@@ -369,7 +369,7 @@ static struct usb_gadget_driver gs_gadget_driver = {
369#endif /* CONFIG_USB_GADGET_DUALSPEED */ 369#endif /* CONFIG_USB_GADGET_DUALSPEED */
370 .function = GS_LONG_NAME, 370 .function = GS_LONG_NAME,
371 .bind = gs_bind, 371 .bind = gs_bind,
372 .unbind = gs_unbind, 372 .unbind = __exit_p(gs_unbind),
373 .setup = gs_setup, 373 .setup = gs_setup,
374 .disconnect = gs_disconnect, 374 .disconnect = gs_disconnect,
375 .driver = { 375 .driver = {
@@ -1413,7 +1413,7 @@ requeue:
1413 * Called on module load. Allocates and initializes the device 1413 * Called on module load. Allocates and initializes the device
1414 * structure and a control request. 1414 * structure and a control request.
1415 */ 1415 */
1416static int gs_bind(struct usb_gadget *gadget) 1416static int __init gs_bind(struct usb_gadget *gadget)
1417{ 1417{
1418 int ret; 1418 int ret;
1419 struct usb_ep *ep; 1419 struct usb_ep *ep;
@@ -1538,7 +1538,7 @@ autoconf_fail:
1538 * Called on module unload. Frees the control request and device 1538 * Called on module unload. Frees the control request and device
1539 * structure. 1539 * structure.
1540 */ 1540 */
1541static void gs_unbind(struct usb_gadget *gadget) 1541static void __exit gs_unbind(struct usb_gadget *gadget)
1542{ 1542{
1543 struct gs_dev *dev = get_gadget_data(gadget); 1543 struct gs_dev *dev = get_gadget_data(gadget);
1544 1544
diff --git a/drivers/usb/gadget/zero.c b/drivers/usb/gadget/zero.c
index 5e9fe8a70543..44d8e5e77da7 100644
--- a/drivers/usb/gadget/zero.c
+++ b/drivers/usb/gadget/zero.c
@@ -1119,7 +1119,7 @@ zero_autoresume (unsigned long _dev)
1119 1119
1120/*-------------------------------------------------------------------------*/ 1120/*-------------------------------------------------------------------------*/
1121 1121
1122static void 1122static void __exit
1123zero_unbind (struct usb_gadget *gadget) 1123zero_unbind (struct usb_gadget *gadget)
1124{ 1124{
1125 struct zero_dev *dev = get_gadget_data (gadget); 1125 struct zero_dev *dev = get_gadget_data (gadget);
@@ -1136,7 +1136,7 @@ zero_unbind (struct usb_gadget *gadget)
1136 set_gadget_data (gadget, NULL); 1136 set_gadget_data (gadget, NULL);
1137} 1137}
1138 1138
1139static int 1139static int __init
1140zero_bind (struct usb_gadget *gadget) 1140zero_bind (struct usb_gadget *gadget)
1141{ 1141{
1142 struct zero_dev *dev; 1142 struct zero_dev *dev;
@@ -1288,7 +1288,7 @@ static struct usb_gadget_driver zero_driver = {
1288#endif 1288#endif
1289 .function = (char *) longname, 1289 .function = (char *) longname,
1290 .bind = zero_bind, 1290 .bind = zero_bind,
1291 .unbind = zero_unbind, 1291 .unbind = __exit_p(zero_unbind),
1292 1292
1293 .setup = zero_setup, 1293 .setup = zero_setup,
1294 .disconnect = zero_disconnect, 1294 .disconnect = zero_disconnect,
diff --git a/include/linux/usb_gadget.h b/include/linux/usb_gadget.h
index ff81117eb733..1d78870ed8af 100644
--- a/include/linux/usb_gadget.h
+++ b/include/linux/usb_gadget.h
@@ -801,7 +801,9 @@ struct usb_gadget_driver {
801 * Call this in your gadget driver's module initialization function, 801 * Call this in your gadget driver's module initialization function,
802 * to tell the underlying usb controller driver about your driver. 802 * to tell the underlying usb controller driver about your driver.
803 * The driver's bind() function will be called to bind it to a 803 * The driver's bind() function will be called to bind it to a
804 * gadget. This function must be called in a context that can sleep. 804 * gadget before this registration call returns. It's expected that
805 * the bind() functions will be in init sections.
806 * This function must be called in a context that can sleep.
805 */ 807 */
806int usb_gadget_register_driver (struct usb_gadget_driver *driver); 808int usb_gadget_register_driver (struct usb_gadget_driver *driver);
807 809
@@ -814,7 +816,8 @@ int usb_gadget_register_driver (struct usb_gadget_driver *driver);
814 * going away. If the controller is connected to a USB host, 816 * going away. If the controller is connected to a USB host,
815 * it will first disconnect(). The driver is also requested 817 * it will first disconnect(). The driver is also requested
816 * to unbind() and clean up any device state, before this procedure 818 * to unbind() and clean up any device state, before this procedure
817 * finally returns. 819 * finally returns. It's expected that the unbind() functions
820 * will in in exit sections, so may not be linked in some kernels.
818 * This function must be called in a context that can sleep. 821 * This function must be called in a context that can sleep.
819 */ 822 */
820int usb_gadget_unregister_driver (struct usb_gadget_driver *driver); 823int usb_gadget_unregister_driver (struct usb_gadget_driver *driver);