aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/usb/gadget/cdc2.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/usb/gadget/cdc2.c')
-rw-r--r--drivers/usb/gadget/cdc2.c36
1 files changed, 27 insertions, 9 deletions
diff --git a/drivers/usb/gadget/cdc2.c b/drivers/usb/gadget/cdc2.c
index 1e4bb77f00bb..a7d6f7026757 100644
--- a/drivers/usb/gadget/cdc2.c
+++ b/drivers/usb/gadget/cdc2.c
@@ -42,9 +42,6 @@ USB_GADGET_COMPOSITE_OPTIONS();
42 * the runtime footprint, and giving us at least some parts of what 42 * the runtime footprint, and giving us at least some parts of what
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
46#include "u_serial.c"
47#include "f_acm.c"
48#include "f_ecm.c" 45#include "f_ecm.c"
49#include "u_ether.c" 46#include "u_ether.c"
50 47
@@ -108,12 +105,16 @@ static struct usb_gadget_strings *dev_strings[] = {
108static u8 hostaddr[ETH_ALEN]; 105static u8 hostaddr[ETH_ALEN];
109 106
110/*-------------------------------------------------------------------------*/ 107/*-------------------------------------------------------------------------*/
108static struct usb_function *f_acm;
109static struct usb_function_instance *fi_serial;
111 110
111static unsigned char tty_line;
112/* 112/*
113 * We _always_ have both CDC ECM and CDC ACM functions. 113 * We _always_ have both CDC ECM and CDC ACM functions.
114 */ 114 */
115static int __init cdc_do_config(struct usb_configuration *c) 115static int __init cdc_do_config(struct usb_configuration *c)
116{ 116{
117 struct f_serial_opts *opts;
117 int status; 118 int status;
118 119
119 if (gadget_is_otg(c->cdev->gadget)) { 120 if (gadget_is_otg(c->cdev->gadget)) {
@@ -125,11 +126,26 @@ static int __init cdc_do_config(struct usb_configuration *c)
125 if (status < 0) 126 if (status < 0)
126 return status; 127 return status;
127 128
128 status = acm_bind_config(c, 0); 129 fi_serial = usb_get_function_instance("acm");
129 if (status < 0) 130 if (IS_ERR(fi_serial))
130 return status; 131 return PTR_ERR(fi_serial);
131 132
133 opts = container_of(fi_serial, struct f_serial_opts, func_inst);
134 opts->port_num = tty_line;
135
136 f_acm = usb_get_function(fi_serial);
137 if (IS_ERR(f_acm))
138 goto err_func_acm;
139
140 status = usb_add_function(c, f_acm);
141 if (status)
142 goto err_conf;
132 return 0; 143 return 0;
144err_conf:
145 usb_put_function(f_acm);
146err_func_acm:
147 usb_put_function_instance(fi_serial);
148 return status;
133} 149}
134 150
135static struct usb_configuration cdc_config_driver = { 151static struct usb_configuration cdc_config_driver = {
@@ -158,7 +174,7 @@ static int __init cdc_bind(struct usb_composite_dev *cdev)
158 return status; 174 return status;
159 175
160 /* set up serial link layer */ 176 /* set up serial link layer */
161 status = gserial_setup(cdev->gadget, 1); 177 status = gserial_alloc_line(&tty_line);
162 if (status < 0) 178 if (status < 0)
163 goto fail0; 179 goto fail0;
164 180
@@ -184,7 +200,7 @@ static int __init cdc_bind(struct usb_composite_dev *cdev)
184 return 0; 200 return 0;
185 201
186fail1: 202fail1:
187 gserial_cleanup(); 203 gserial_free_line(tty_line);
188fail0: 204fail0:
189 gether_cleanup(); 205 gether_cleanup();
190 return status; 206 return status;
@@ -192,7 +208,9 @@ fail0:
192 208
193static int __exit cdc_unbind(struct usb_composite_dev *cdev) 209static int __exit cdc_unbind(struct usb_composite_dev *cdev)
194{ 210{
195 gserial_cleanup(); 211 usb_put_function(f_acm);
212 usb_put_function_instance(fi_serial);
213 gserial_free_line(tty_line);
196 gether_cleanup(); 214 gether_cleanup();
197 return 0; 215 return 0;
198} 216}