diff options
author | Sebastian Andrzej Siewior <bigeasy@linutronix.de> | 2012-12-23 21:10:06 +0100 |
---|---|---|
committer | Felipe Balbi <balbi@ti.com> | 2013-01-21 20:52:43 +0200 |
commit | 19b10a8828a6cdd5a4e7e37babd5084d35641f87 (patch) | |
tree | 636a228ed32d975a8214639b17b4d7a595fdf7b4 /drivers/usb/gadget/acm_ms.c | |
parent | b473577854fea63055ff9ab84f0f52a3e8aed15e (diff) |
usb: gadget: allocate & giveback serial ports instead hard code them
This patch removes gserial_setup() and gserial_cleanup() and adds
gserial_alloc_line() and gserial_free_line() to replace them.
The initial setup of u_serial happens now on module load time. A
maximum of four TTY ports can be requested which is the current limit.
In theory we could extend this limit, the hard limit is the number of
available endpoints.
alloc_tty_driver() is now called at module init time with the max
available ports. The per-line footprint here is on 32bit is 3 * size of
pointer + 60 bytes (for cdevs).
The remaining memory (struct gs_port) is allocated once a port is
requested.
With this change it is possible to load g_multi and g_serial at the same
time. GS0 receives the module that is loaded first, GS1 is received by
the next module and so on. With the configfs interface the port number
can be exported and the device node is more predictable. Nothing changes
for g_serial and friends as long as one module is used.
Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
Signed-off-by: Felipe Balbi <balbi@ti.com>
Diffstat (limited to 'drivers/usb/gadget/acm_ms.c')
-rw-r--r-- | drivers/usb/gadget/acm_ms.c | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/drivers/usb/gadget/acm_ms.c b/drivers/usb/gadget/acm_ms.c index 35cbe728351..eb0fbdae5cc 100644 --- a/drivers/usb/gadget/acm_ms.c +++ b/drivers/usb/gadget/acm_ms.c @@ -111,6 +111,7 @@ FSG_MODULE_PARAMETERS(/* no prefix */, fsg_mod_data); static struct fsg_common fsg_common; /*-------------------------------------------------------------------------*/ +static unsigned char tty_line; /* * We _always_ have both ACM and mass storage functions. @@ -125,7 +126,7 @@ static int __init acm_ms_do_config(struct usb_configuration *c) } - status = acm_bind_config(c, 0); + status = acm_bind_config(c, tty_line); if (status < 0) return status; @@ -152,7 +153,7 @@ static int __init acm_ms_bind(struct usb_composite_dev *cdev) void *retp; /* set up serial link layer */ - status = gserial_setup(cdev->gadget, 1); + status = gserial_alloc_line(&tty_line); if (status < 0) return status; @@ -188,14 +189,13 @@ static int __init acm_ms_bind(struct usb_composite_dev *cdev) fail1: fsg_common_put(&fsg_common); fail0: - gserial_cleanup(); + gserial_free_line(tty_line); return status; } static int __exit acm_ms_unbind(struct usb_composite_dev *cdev) { - gserial_cleanup(); - + gserial_free_line(tty_line); return 0; } |