The composite framework has been written using __init and __exit tags
to mark init and exit functions as such. This works with most of the
composite gadgets however some may need to call init/exit functions
during normal operations. One example is mass storage gadget which
needs to call exit functions.
This patch allows gadgets to define USB_NO_INIT_SEGMENT or
USB_NO_EXIT_SEGMENT to remove the __init and __exit declarations
from composite framework.
For example see mass_storage.c.
Signed-off-by: Michal Nazarewicz <m.nazarewicz@samsung.com>
Cc: Kyungmin Park <kyungmin.park@samsung.com>
Cc: Marek Szyprowski <m.szyprowski@samsung.com>
---
drivers/usb/gadget/composite.c | 25 +++++++++++++------------
drivers/usb/gadget/config.c | 6 ++++--
drivers/usb/gadget/epautoconf.c | 13 +++++++------
drivers/usb/gadget/mass_storage.c | 4 ++++
drivers/usb/gadget/usb-init-exit.h | 23 +++++++++++++++++++++++
5 files changed, 51 insertions(+), 20 deletions(-)
create mode 100644 drivers/usb/gadget/usb-init-exit.h
diff --git a/drivers/usb/gadget/composite.c b/drivers/usb/gadget/composite.c
index 09289bb..0039aba 100644
--- a/drivers/usb/gadget/composite.c
+++ b/drivers/usb/gadget/composite.c
@@ -27,6 +27,8 @@
#include <linux/usb/composite.h>
+#include "usb-init-exit.h"
+
/*
* The code in this file is utility code, used to build a gadget driver
@@ -85,7 +87,7 @@ MODULE_PARM_DESC(iSerialNumber, "SerialNumber string");
* This function returns the value of the function's bind(), which is
* zero for success else a negative errno value.
*/
-int __init usb_add_function(struct usb_configuration *config,
+int __usb_init usb_add_function(struct usb_configuration *config,
struct usb_function *function)
{
int value = -EINVAL;
@@ -215,7 +217,7 @@ int usb_function_activate(struct usb_function *function)
* Returns the interface ID which was allocated; or -ENODEV if no
* more interface IDs can be allocated.
*/
-int __init ...