aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/usb/gadget
diff options
context:
space:
mode:
authorKyösti Mälkki <kyosti.malkki@gmail.com>2014-11-03 10:18:04 -0500
committerFelipe Balbi <balbi@ti.com>2014-11-10 18:19:34 -0500
commit6876d58f2f0548ce130b388c323eed17dc5d8689 (patch)
tree6b2a670addb8cae0d1f31318db3e9fbd432ef630 /drivers/usb/gadget
parent8b9ca2767b2d1ea405287e530da3a7b234120b95 (diff)
usb: gadget: dbgp: Fix endpoint config after USB disconnect
SET_FEATURE request with DEBUG_MODE only worked the first time after module initialisation. Per the USB 2.0 debug device specification, said request is to be treated as if it were a SET_CONFIGURATION request, i.e. endpoint must be re-configured. As configure_endpoints() may now get called multiple times, move it outside __init and move serial_alloc_tty() call into __init. Code has assumption that endpoint mapping remains unchanged with consecutive calls of configure_endpoints(). Signed-off-by: Kyösti Mälkki <kyosti.malkki@gmail.com> Signed-off-by: Felipe Balbi <balbi@ti.com>
Diffstat (limited to 'drivers/usb/gadget')
-rw-r--r--drivers/usb/gadget/legacy/dbgp.c26
1 files changed, 14 insertions, 12 deletions
diff --git a/drivers/usb/gadget/legacy/dbgp.c b/drivers/usb/gadget/legacy/dbgp.c
index 1b075132f8f1..633683a72a11 100644
--- a/drivers/usb/gadget/legacy/dbgp.c
+++ b/drivers/usb/gadget/legacy/dbgp.c
@@ -237,7 +237,7 @@ static void dbgp_unbind(struct usb_gadget *gadget)
237static unsigned char tty_line; 237static unsigned char tty_line;
238#endif 238#endif
239 239
240static int __init dbgp_configure_endpoints(struct usb_gadget *gadget) 240static int dbgp_configure_endpoints(struct usb_gadget *gadget)
241{ 241{
242 int stp; 242 int stp;
243 243
@@ -273,19 +273,10 @@ static int __init dbgp_configure_endpoints(struct usb_gadget *gadget)
273 273
274 dbgp.serial->in->desc = &i_desc; 274 dbgp.serial->in->desc = &i_desc;
275 dbgp.serial->out->desc = &o_desc; 275 dbgp.serial->out->desc = &o_desc;
276 276#endif
277 if (gserial_alloc_line(&tty_line)) {
278 stp = 3;
279 goto fail_3;
280 }
281 277
282 return 0; 278 return 0;
283 279
284fail_3:
285 dbgp.o_ep->driver_data = NULL;
286#else
287 return 0;
288#endif
289fail_2: 280fail_2:
290 dbgp.i_ep->driver_data = NULL; 281 dbgp.i_ep->driver_data = NULL;
291fail_1: 282fail_1:
@@ -324,10 +315,17 @@ static int __init dbgp_bind(struct usb_gadget *gadget,
324 err = -ENOMEM; 315 err = -ENOMEM;
325 goto fail; 316 goto fail;
326 } 317 }
318
319 if (gserial_alloc_line(&tty_line)) {
320 stp = 4;
321 err = -ENODEV;
322 goto fail;
323 }
327#endif 324#endif
325
328 err = dbgp_configure_endpoints(gadget); 326 err = dbgp_configure_endpoints(gadget);
329 if (err < 0) { 327 if (err < 0) {
330 stp = 4; 328 stp = 5;
331 goto fail; 329 goto fail;
332 } 330 }
333 331
@@ -383,6 +381,10 @@ static int dbgp_setup(struct usb_gadget *gadget,
383#ifdef CONFIG_USB_G_DBGP_PRINTK 381#ifdef CONFIG_USB_G_DBGP_PRINTK
384 err = dbgp_enable_ep(); 382 err = dbgp_enable_ep();
385#else 383#else
384 err = dbgp_configure_endpoints(gadget);
385 if (err < 0) {
386 goto fail;
387 }
386 err = gserial_connect(dbgp.serial, tty_line); 388 err = gserial_connect(dbgp.serial, tty_line);
387#endif 389#endif
388 if (err < 0) 390 if (err < 0)