summaryrefslogtreecommitdiffstats
path: root/drivers/usb/gadget/serial.c
diff options
context:
space:
mode:
authorSebastian Andrzej Siewior <bigeasy@linutronix.de>2012-12-23 21:10:18 +0100
committerFelipe Balbi <balbi@ti.com>2013-04-03 13:43:31 +0200
commitc4ed4ac198495895fd1620cba15184c3b2d399dc (patch)
tree4b6d1601559aed0d29f8348c7460828d1ec27d85 /drivers/usb/gadget/serial.c
parentusb: gadget: move the global the_dev variable to their users (diff)
downloadlinux-c4ed4ac198495895fd1620cba15184c3b2d399dc.tar.xz
linux-c4ed4ac198495895fd1620cba15184c3b2d399dc.zip
usb: gadget: push tty port allocation from gadget into f_acm
It possible to allocate the tty port number within the "instance" structure of the function and there is no need to expose this information within the gadget and therefore it is removed here. This patch converts only f_acm and all its users. The other gadgets will follow once the function is converted to the function interface. Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de> Signed-off-by: Felipe Balbi <balbi@ti.com>
Diffstat (limited to 'drivers/usb/gadget/serial.c')
-rw-r--r--drivers/usb/gadget/serial.c20
1 files changed, 10 insertions, 10 deletions
diff --git a/drivers/usb/gadget/serial.c b/drivers/usb/gadget/serial.c
index 68d7bb06ebcb..c48ca1eb5442 100644
--- a/drivers/usb/gadget/serial.c
+++ b/drivers/usb/gadget/serial.c
@@ -169,15 +169,12 @@ static int serial_register_ports(struct usb_composite_dev *cdev,
goto out;
for (i = 0; i < n_ports; i++) {
- struct f_serial_opts *opts;
fi_serial[i] = usb_get_function_instance(f_name);
if (IS_ERR(fi_serial[i])) {
ret = PTR_ERR(fi_serial[i]);
goto fail;
}
- opts = container_of(fi_serial[i], struct f_serial_opts, func_inst);
- opts->port_num = tty_lines[i];
f_serial[i] = usb_get_function(fi_serial[i]);
if (IS_ERR(f_serial[i])) {
@@ -212,12 +209,14 @@ out:
static int __init gs_bind(struct usb_composite_dev *cdev)
{
int status;
- int cur_line;
+ int cur_line = 0;
- for (cur_line = 0; cur_line < n_ports; cur_line++) {
- status = gserial_alloc_line(&tty_lines[cur_line]);
- if (status)
- goto fail;
+ if (!use_acm) {
+ for (cur_line = 0; cur_line < n_ports; cur_line++) {
+ status = gserial_alloc_line(&tty_lines[cur_line]);
+ if (status)
+ goto fail;
+ }
}
/* Allocate string descriptor numbers ... note that string
@@ -258,7 +257,7 @@ static int __init gs_bind(struct usb_composite_dev *cdev)
fail:
cur_line--;
- while (cur_line >= 0)
+ while (cur_line >= 0 && !use_acm)
gserial_free_line(tty_lines[cur_line--]);
return status;
}
@@ -270,7 +269,8 @@ static int gs_unbind(struct usb_composite_dev *cdev)
for (i = 0; i < n_ports; i++) {
usb_put_function(f_serial[i]);
usb_put_function_instance(fi_serial[i]);
- gserial_free_line(tty_lines[i]);
+ if (!use_acm)
+ gserial_free_line(tty_lines[i]);
}
return 0;
}