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.c31
1 files changed, 10 insertions, 21 deletions
diff --git a/drivers/usb/gadget/cdc2.c b/drivers/usb/gadget/cdc2.c
index a7d6f7026757..2c5255182769 100644
--- a/drivers/usb/gadget/cdc2.c
+++ b/drivers/usb/gadget/cdc2.c
@@ -103,18 +103,16 @@ static struct usb_gadget_strings *dev_strings[] = {
103}; 103};
104 104
105static u8 hostaddr[ETH_ALEN]; 105static u8 hostaddr[ETH_ALEN];
106 106static struct eth_dev *the_dev;
107/*-------------------------------------------------------------------------*/ 107/*-------------------------------------------------------------------------*/
108static struct usb_function *f_acm; 108static struct usb_function *f_acm;
109static struct usb_function_instance *fi_serial; 109static struct usb_function_instance *fi_serial;
110 110
111static unsigned char tty_line;
112/* 111/*
113 * We _always_ have both CDC ECM and CDC ACM functions. 112 * We _always_ have both CDC ECM and CDC ACM functions.
114 */ 113 */
115static int __init cdc_do_config(struct usb_configuration *c) 114static int __init cdc_do_config(struct usb_configuration *c)
116{ 115{
117 struct f_serial_opts *opts;
118 int status; 116 int status;
119 117
120 if (gadget_is_otg(c->cdev->gadget)) { 118 if (gadget_is_otg(c->cdev->gadget)) {
@@ -122,7 +120,7 @@ static int __init cdc_do_config(struct usb_configuration *c)
122 c->bmAttributes |= USB_CONFIG_ATT_WAKEUP; 120 c->bmAttributes |= USB_CONFIG_ATT_WAKEUP;
123 } 121 }
124 122
125 status = ecm_bind_config(c, hostaddr); 123 status = ecm_bind_config(c, hostaddr, the_dev);
126 if (status < 0) 124 if (status < 0)
127 return status; 125 return status;
128 126
@@ -130,12 +128,11 @@ static int __init cdc_do_config(struct usb_configuration *c)
130 if (IS_ERR(fi_serial)) 128 if (IS_ERR(fi_serial))
131 return PTR_ERR(fi_serial); 129 return PTR_ERR(fi_serial);
132 130
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); 131 f_acm = usb_get_function(fi_serial);
137 if (IS_ERR(f_acm)) 132 if (IS_ERR(f_acm)) {
133 status = PTR_ERR(f_acm);
138 goto err_func_acm; 134 goto err_func_acm;
135 }
139 136
140 status = usb_add_function(c, f_acm); 137 status = usb_add_function(c, f_acm);
141 if (status) 138 if (status)
@@ -169,14 +166,9 @@ static int __init cdc_bind(struct usb_composite_dev *cdev)
169 } 166 }
170 167
171 /* set up network link layer */ 168 /* set up network link layer */
172 status = gether_setup(cdev->gadget, hostaddr); 169 the_dev = gether_setup(cdev->gadget, hostaddr);
173 if (status < 0) 170 if (IS_ERR(the_dev))
174 return status; 171 return PTR_ERR(the_dev);
175
176 /* set up serial link layer */
177 status = gserial_alloc_line(&tty_line);
178 if (status < 0)
179 goto fail0;
180 172
181 /* Allocate string descriptor numbers ... note that string 173 /* Allocate string descriptor numbers ... note that string
182 * contents can be overridden by the composite_dev glue. 174 * contents can be overridden by the composite_dev glue.
@@ -200,9 +192,7 @@ static int __init cdc_bind(struct usb_composite_dev *cdev)
200 return 0; 192 return 0;
201 193
202fail1: 194fail1:
203 gserial_free_line(tty_line); 195 gether_cleanup(the_dev);
204fail0:
205 gether_cleanup();
206 return status; 196 return status;
207} 197}
208 198
@@ -210,8 +200,7 @@ static int __exit cdc_unbind(struct usb_composite_dev *cdev)
210{ 200{
211 usb_put_function(f_acm); 201 usb_put_function(f_acm);
212 usb_put_function_instance(fi_serial); 202 usb_put_function_instance(fi_serial);
213 gserial_free_line(tty_line); 203 gether_cleanup(the_dev);
214 gether_cleanup();
215 return 0; 204 return 0;
216} 205}
217 206