diff options
Diffstat (limited to 'drivers/usb/gadget/cdc2.c')
-rw-r--r-- | drivers/usb/gadget/cdc2.c | 36 |
1 files changed, 27 insertions, 9 deletions
diff --git a/drivers/usb/gadget/cdc2.c b/drivers/usb/gadget/cdc2.c index 1e4bb77f00b..a7d6f702675 100644 --- a/drivers/usb/gadget/cdc2.c +++ b/drivers/usb/gadget/cdc2.c @@ -42,9 +42,6 @@ USB_GADGET_COMPOSITE_OPTIONS(); * the runtime footprint, and giving us at least some parts of what * a "gcc --combine ... part1.c part2.c part3.c ... " build would. */ - -#include "u_serial.c" -#include "f_acm.c" #include "f_ecm.c" #include "u_ether.c" @@ -108,12 +105,16 @@ static struct usb_gadget_strings *dev_strings[] = { static u8 hostaddr[ETH_ALEN]; /*-------------------------------------------------------------------------*/ +static struct usb_function *f_acm; +static struct usb_function_instance *fi_serial; +static unsigned char tty_line; /* * We _always_ have both CDC ECM and CDC ACM functions. */ static int __init cdc_do_config(struct usb_configuration *c) { + struct f_serial_opts *opts; int status; if (gadget_is_otg(c->cdev->gadget)) { @@ -125,11 +126,26 @@ static int __init cdc_do_config(struct usb_configuration *c) if (status < 0) return status; - status = acm_bind_config(c, 0); - if (status < 0) - return status; + fi_serial = usb_get_function_instance("acm"); + if (IS_ERR(fi_serial)) + return PTR_ERR(fi_serial); + opts = container_of(fi_serial, struct f_serial_opts, func_inst); + opts->port_num = tty_line; + + f_acm = usb_get_function(fi_serial); + if (IS_ERR(f_acm)) + goto err_func_acm; + + status = usb_add_function(c, f_acm); + if (status) + goto err_conf; return 0; +err_conf: + usb_put_function(f_acm); +err_func_acm: + usb_put_function_instance(fi_serial); + return status; } static struct usb_configuration cdc_config_driver = { @@ -158,7 +174,7 @@ static int __init cdc_bind(struct usb_composite_dev *cdev) return status; /* set up serial link layer */ - status = gserial_setup(cdev->gadget, 1); + status = gserial_alloc_line(&tty_line); if (status < 0) goto fail0; @@ -184,7 +200,7 @@ static int __init cdc_bind(struct usb_composite_dev *cdev) return 0; fail1: - gserial_cleanup(); + gserial_free_line(tty_line); fail0: gether_cleanup(); return status; @@ -192,7 +208,9 @@ fail0: static int __exit cdc_unbind(struct usb_composite_dev *cdev) { - gserial_cleanup(); + usb_put_function(f_acm); + usb_put_function_instance(fi_serial); + gserial_free_line(tty_line); gether_cleanup(); return 0; } |