aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSebastian Andrzej Siewior <bigeasy@linutronix.de>2012-12-23 15:10:04 -0500
committerFelipe Balbi <balbi@ti.com>2013-01-21 13:52:42 -0500
commit3249ca22c088c286d6227d8fae9c85a43a8ce9f6 (patch)
treed6e0cdc2abb6d862af760af9ec7c80691182ec7a
parent48177cd83792d25a5bab7f887acc47c2c314810e (diff)
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>
-rw-r--r--drivers/usb/gadget/Kconfig9
-rw-r--r--drivers/usb/gadget/Makefile1
-rw-r--r--drivers/usb/gadget/acm_ms.c1
-rw-r--r--drivers/usb/gadget/cdc2.c1
-rw-r--r--drivers/usb/gadget/dbgp.c4
-rw-r--r--drivers/usb/gadget/multi.c1
-rw-r--r--drivers/usb/gadget/nokia.c1
-rw-r--r--drivers/usb/gadget/serial.c1
-rw-r--r--drivers/usb/gadget/u_serial.c13
9 files changed, 23 insertions, 9 deletions
diff --git a/drivers/usb/gadget/Kconfig b/drivers/usb/gadget/Kconfig
index 0ef5549b6544..8aefbbddf2a7 100644
--- a/drivers/usb/gadget/Kconfig
+++ b/drivers/usb/gadget/Kconfig
@@ -503,6 +503,9 @@ config USB_LIBCOMPOSITE
503config USB_F_SS_LB 503config USB_F_SS_LB
504 tristate 504 tristate
505 505
506config USB_U_SERIAL
507 tristate
508
506choice 509choice
507 tristate "USB Gadget Drivers" 510 tristate "USB Gadget Drivers"
508 default USB_ETH 511 default USB_ETH
@@ -754,6 +757,7 @@ config USB_GADGET_TARGET
754 757
755config USB_G_SERIAL 758config USB_G_SERIAL
756 tristate "Serial Gadget (with CDC ACM and CDC OBEX support)" 759 tristate "Serial Gadget (with CDC ACM and CDC OBEX support)"
760 select USB_U_SERIAL
757 select USB_LIBCOMPOSITE 761 select USB_LIBCOMPOSITE
758 help 762 help
759 The Serial Gadget talks to the Linux-USB generic serial driver. 763 The Serial Gadget talks to the Linux-USB generic serial driver.
@@ -807,6 +811,7 @@ config USB_CDC_COMPOSITE
807 tristate "CDC Composite Device (Ethernet and ACM)" 811 tristate "CDC Composite Device (Ethernet and ACM)"
808 depends on NET 812 depends on NET
809 select USB_LIBCOMPOSITE 813 select USB_LIBCOMPOSITE
814 select USB_U_SERIAL
810 help 815 help
811 This driver provides two functions in one configuration: 816 This driver provides two functions in one configuration:
812 a CDC Ethernet (ECM) link, and a CDC ACM (serial port) link. 817 a CDC Ethernet (ECM) link, and a CDC ACM (serial port) link.
@@ -822,6 +827,7 @@ config USB_G_NOKIA
822 tristate "Nokia composite gadget" 827 tristate "Nokia composite gadget"
823 depends on PHONET 828 depends on PHONET
824 select USB_LIBCOMPOSITE 829 select USB_LIBCOMPOSITE
830 select USB_U_SERIAL
825 help 831 help
826 The Nokia composite gadget provides support for acm, obex 832 The Nokia composite gadget provides support for acm, obex
827 and phonet in only one composite gadget driver. 833 and phonet in only one composite gadget driver.
@@ -833,6 +839,7 @@ config USB_G_ACM_MS
833 tristate "CDC Composite Device (ACM and mass storage)" 839 tristate "CDC Composite Device (ACM and mass storage)"
834 depends on BLOCK 840 depends on BLOCK
835 select USB_LIBCOMPOSITE 841 select USB_LIBCOMPOSITE
842 select USB_U_SERIAL
836 help 843 help
837 This driver provides two functions in one configuration: 844 This driver provides two functions in one configuration:
838 a mass storage, and a CDC ACM (serial port) link. 845 a mass storage, and a CDC ACM (serial port) link.
@@ -845,6 +852,7 @@ config USB_G_MULTI
845 depends on BLOCK && NET 852 depends on BLOCK && NET
846 select USB_G_MULTI_CDC if !USB_G_MULTI_RNDIS 853 select USB_G_MULTI_CDC if !USB_G_MULTI_RNDIS
847 select USB_LIBCOMPOSITE 854 select USB_LIBCOMPOSITE
855 select USB_U_SERIAL
848 help 856 help
849 The Multifunction Composite Gadget provides Ethernet (RNDIS 857 The Multifunction Composite Gadget provides Ethernet (RNDIS
850 and/or CDC Ethernet), mass storage and ACM serial link 858 and/or CDC Ethernet), mass storage and ACM serial link
@@ -920,6 +928,7 @@ config USB_G_DBGP_PRINTK
920 928
921config USB_G_DBGP_SERIAL 929config USB_G_DBGP_SERIAL
922 depends on USB_G_DBGP 930 depends on USB_G_DBGP
931 select USB_U_SERIAL
923 bool "serial" 932 bool "serial"
924 help 933 help
925 Userland can interact using /dev/ttyGSxxx. 934 Userland can interact using /dev/ttyGSxxx.
diff --git a/drivers/usb/gadget/Makefile b/drivers/usb/gadget/Makefile
index e412befa7a35..b88ee775de6b 100644
--- a/drivers/usb/gadget/Makefile
+++ b/drivers/usb/gadget/Makefile
@@ -78,3 +78,4 @@ obj-$(CONFIG_USB_GADGET_TARGET) += tcm_usb_gadget.o
78# USB Functions 78# USB Functions
79f_ss_lb-y := f_loopback.o f_sourcesink.o 79f_ss_lb-y := f_loopback.o f_sourcesink.o
80obj-$(CONFIG_USB_F_SS_LB) += f_ss_lb.o 80obj-$(CONFIG_USB_F_SS_LB) += f_ss_lb.o
81obj-$(CONFIG_USB_U_SERIAL) += u_serial.o
diff --git a/drivers/usb/gadget/acm_ms.c b/drivers/usb/gadget/acm_ms.c
index 5a7f289805ff..35cbe7283514 100644
--- a/drivers/usb/gadget/acm_ms.c
+++ b/drivers/usb/gadget/acm_ms.c
@@ -41,7 +41,6 @@
41 * a "gcc --combine ... part1.c part2.c part3.c ... " build would. 41 * a "gcc --combine ... part1.c part2.c part3.c ... " build would.
42 */ 42 */
43 43
44#include "u_serial.c"
45#include "f_acm.c" 44#include "f_acm.c"
46#include "f_mass_storage.c" 45#include "f_mass_storage.c"
47 46
diff --git a/drivers/usb/gadget/cdc2.c b/drivers/usb/gadget/cdc2.c
index 1e4bb77f00bb..379df679ef30 100644
--- a/drivers/usb/gadget/cdc2.c
+++ b/drivers/usb/gadget/cdc2.c
@@ -43,7 +43,6 @@ USB_GADGET_COMPOSITE_OPTIONS();
43 * a "gcc --combine ... part1.c part2.c part3.c ... " build would. 43 * a "gcc --combine ... part1.c part2.c part3.c ... " build would.
44 */ 44 */
45 45
46#include "u_serial.c"
47#include "f_acm.c" 46#include "f_acm.c"
48#include "f_ecm.c" 47#include "f_ecm.c"
49#include "u_ether.c" 48#include "u_ether.c"
diff --git a/drivers/usb/gadget/dbgp.c b/drivers/usb/gadget/dbgp.c
index 87d165028162..41eb98df5644 100644
--- a/drivers/usb/gadget/dbgp.c
+++ b/drivers/usb/gadget/dbgp.c
@@ -13,9 +13,7 @@
13#include <linux/usb/ch9.h> 13#include <linux/usb/ch9.h>
14#include <linux/usb/gadget.h> 14#include <linux/usb/gadget.h>
15 15
16#ifdef CONFIG_USB_G_DBGP_SERIAL 16#include "u_serial.h"
17#include "u_serial.c"
18#endif
19 17
20#define DRIVER_VENDOR_ID 0x0525 /* NetChip */ 18#define DRIVER_VENDOR_ID 0x0525 /* NetChip */
21#define DRIVER_PRODUCT_ID 0xc0de /* undefined */ 19#define DRIVER_PRODUCT_ID 0xc0de /* undefined */
diff --git a/drivers/usb/gadget/multi.c b/drivers/usb/gadget/multi.c
index 88472bf7dbb7..00667911100d 100644
--- a/drivers/usb/gadget/multi.c
+++ b/drivers/usb/gadget/multi.c
@@ -42,7 +42,6 @@ MODULE_LICENSE("GPL");
42 */ 42 */
43#include "f_mass_storage.c" 43#include "f_mass_storage.c"
44 44
45#include "u_serial.c"
46#include "f_acm.c" 45#include "f_acm.c"
47 46
48#include "f_ecm.c" 47#include "f_ecm.c"
diff --git a/drivers/usb/gadget/nokia.c b/drivers/usb/gadget/nokia.c
index 1475d663b527..48f0d5c372a8 100644
--- a/drivers/usb/gadget/nokia.c
+++ b/drivers/usb/gadget/nokia.c
@@ -37,7 +37,6 @@
37 * the runtime footprint, and giving us at least some parts of what 37 * the runtime footprint, and giving us at least some parts of what
38 * a "gcc --combine ... part1.c part2.c part3.c ... " build would. 38 * a "gcc --combine ... part1.c part2.c part3.c ... " build would.
39 */ 39 */
40#include "u_serial.c"
41#include "f_acm.c" 40#include "f_acm.c"
42#include "f_ecm.c" 41#include "f_ecm.c"
43#include "f_obex.c" 42#include "f_obex.c"
diff --git a/drivers/usb/gadget/serial.c b/drivers/usb/gadget/serial.c
index bc23905800d3..4816f494fc4d 100644
--- a/drivers/usb/gadget/serial.c
+++ b/drivers/usb/gadget/serial.c
@@ -39,7 +39,6 @@
39#include "f_acm.c" 39#include "f_acm.c"
40#include "f_obex.c" 40#include "f_obex.c"
41#include "f_serial.c" 41#include "f_serial.c"
42#include "u_serial.c"
43 42
44/*-------------------------------------------------------------------------*/ 43/*-------------------------------------------------------------------------*/
45USB_GADGET_COMPOSITE_OPTIONS(); 44USB_GADGET_COMPOSITE_OPTIONS();
diff --git a/drivers/usb/gadget/u_serial.c b/drivers/usb/gadget/u_serial.c
index d0f95482f40e..1662d839a1d6 100644
--- a/drivers/usb/gadget/u_serial.c
+++ b/drivers/usb/gadget/u_serial.c
@@ -26,6 +26,7 @@
26#include <linux/tty_flip.h> 26#include <linux/tty_flip.h>
27#include <linux/slab.h> 27#include <linux/slab.h>
28#include <linux/export.h> 28#include <linux/export.h>
29#include <linux/module.h>
29 30
30#include "u_serial.h" 31#include "u_serial.h"
31 32
@@ -309,6 +310,7 @@ gs_alloc_req(struct usb_ep *ep, unsigned len, gfp_t kmalloc_flags)
309 310
310 return req; 311 return req;
311} 312}
313EXPORT_SYMBOL_GPL(gs_alloc_req);
312 314
313/* 315/*
314 * gs_free_req 316 * gs_free_req
@@ -320,6 +322,7 @@ void gs_free_req(struct usb_ep *ep, struct usb_request *req)
320 kfree(req->buf); 322 kfree(req->buf);
321 usb_ep_free_request(ep, req); 323 usb_ep_free_request(ep, req);
322} 324}
325EXPORT_SYMBOL_GPL(gs_free_req);
323 326
324/* 327/*
325 * gs_send_packet 328 * gs_send_packet
@@ -1081,6 +1084,9 @@ int gserial_setup(struct usb_gadget *g, unsigned count)
1081 if (count == 0 || count > N_PORTS) 1084 if (count == 0 || count > N_PORTS)
1082 return -EINVAL; 1085 return -EINVAL;
1083 1086
1087 if (gs_tty_driver)
1088 return -EBUSY;
1089
1084 gs_tty_driver = alloc_tty_driver(count); 1090 gs_tty_driver = alloc_tty_driver(count);
1085 if (!gs_tty_driver) 1091 if (!gs_tty_driver)
1086 return -ENOMEM; 1092 return -ENOMEM;
@@ -1153,6 +1159,7 @@ fail:
1153 gs_tty_driver = NULL; 1159 gs_tty_driver = NULL;
1154 return status; 1160 return status;
1155} 1161}
1162EXPORT_SYMBOL_GPL(gserial_setup);
1156 1163
1157static int gs_closed(struct gs_port *port) 1164static int gs_closed(struct gs_port *port)
1158{ 1165{
@@ -1213,6 +1220,7 @@ void gserial_cleanup(void)
1213 1220
1214 pr_debug("%s: cleaned up ttyGS* support\n", __func__); 1221 pr_debug("%s: cleaned up ttyGS* support\n", __func__);
1215} 1222}
1223EXPORT_SYMBOL_GPL(gserial_cleanup);
1216 1224
1217/** 1225/**
1218 * gserial_connect - notify TTY I/O glue that USB link is active 1226 * gserial_connect - notify TTY I/O glue that USB link is active
@@ -1292,7 +1300,7 @@ fail_out:
1292 gser->in->driver_data = NULL; 1300 gser->in->driver_data = NULL;
1293 return status; 1301 return status;
1294} 1302}
1295 1303EXPORT_SYMBOL_GPL(gserial_connect);
1296/** 1304/**
1297 * gserial_disconnect - notify TTY I/O glue that USB link is inactive 1305 * gserial_disconnect - notify TTY I/O glue that USB link is inactive
1298 * @gser: the function, on which gserial_connect() was called 1306 * @gser: the function, on which gserial_connect() was called
@@ -1347,3 +1355,6 @@ void gserial_disconnect(struct gserial *gser)
1347 1355
1348 spin_unlock_irqrestore(&port->port_lock, flags); 1356 spin_unlock_irqrestore(&port->port_lock, flags);
1349} 1357}
1358EXPORT_SYMBOL_GPL(gserial_disconnect);
1359
1360MODULE_LICENSE("GPL");