usb: gadget: u_serial: convert into a module

Every user of u_serial has now to select the U_SERIAL symbol instead of
including the file.
There is one limition with this: ports and and gs_tty_driver are global
variables in u_serial. Since all users share them, there can be only one
user loaded at a time i.e. either g_serial or g_nokia.

Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
Signed-off-by: Felipe Balbi <balbi@ti.com>
diff --git a/drivers/usb/gadget/u_serial.c b/drivers/usb/gadget/u_serial.c
index d0f9548..1662d83 100644
--- a/drivers/usb/gadget/u_serial.c
+++ b/drivers/usb/gadget/u_serial.c
@@ -26,6 +26,7 @@
 #include <linux/tty_flip.h>
 #include <linux/slab.h>
 #include <linux/export.h>
+#include <linux/module.h>
 
 #include "u_serial.h"
 
@@ -309,6 +310,7 @@
 
 	return req;
 }
+EXPORT_SYMBOL_GPL(gs_alloc_req);
 
 /*
  * gs_free_req
@@ -320,6 +322,7 @@
 	kfree(req->buf);
 	usb_ep_free_request(ep, req);
 }
+EXPORT_SYMBOL_GPL(gs_free_req);
 
 /*
  * gs_send_packet
@@ -1081,6 +1084,9 @@
 	if (count == 0 || count > N_PORTS)
 		return -EINVAL;
 
+	if (gs_tty_driver)
+		return -EBUSY;
+
 	gs_tty_driver = alloc_tty_driver(count);
 	if (!gs_tty_driver)
 		return -ENOMEM;
@@ -1153,6 +1159,7 @@
 	gs_tty_driver = NULL;
 	return status;
 }
+EXPORT_SYMBOL_GPL(gserial_setup);
 
 static int gs_closed(struct gs_port *port)
 {
@@ -1213,6 +1220,7 @@
 
 	pr_debug("%s: cleaned up ttyGS* support\n", __func__);
 }
+EXPORT_SYMBOL_GPL(gserial_cleanup);
 
 /**
  * gserial_connect - notify TTY I/O glue that USB link is active
@@ -1292,7 +1300,7 @@
 	gser->in->driver_data = NULL;
 	return status;
 }
-
+EXPORT_SYMBOL_GPL(gserial_connect);
 /**
  * gserial_disconnect - notify TTY I/O glue that USB link is inactive
  * @gser: the function, on which gserial_connect() was called
@@ -1347,3 +1355,6 @@
 
 	spin_unlock_irqrestore(&port->port_lock, flags);
 }
+EXPORT_SYMBOL_GPL(gserial_disconnect);
+
+MODULE_LICENSE("GPL");