aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/usb/gadget/f_obex.c
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2013-07-02 14:31:09 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2013-07-02 14:31:09 -0400
commita84270189e2afc7028b1123415a66d444f460977 (patch)
tree0f239afe73655167c02b411d1cf84bf3211818af /drivers/usb/gadget/f_obex.c
parentbcd7351e83728859833e3c5b8aae9a2816914e4b (diff)
parent3a0ddc714a1b8fcbff24c135a1332a28b4668d78 (diff)
Merge tag 'usb-3.11-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/usb
Pull USB updates from Greg KH: "Here's the big USB 3.11-rc1 merge request. Lots of gadget and finally, chipidea driver updates (they were much needed), along with a new host controller driver, lots of little serial driver fixes, the removal of the 255 usb-serial device limitation, and a variety of other minor things. All of these have been in the linux-next releases for a while" * tag 'usb-3.11-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/usb: (254 commits) usb: musb: omap2430: make it compile again usb: chipidea: ci_hdrc_imx: access phy via private data xhci: Add missing unlocks on error paths USB: option,qcserial: move Novatel Gobi1K IDs to qcserial ehci-atmel.c: prepare clk before calling enable USB: ohci-at91: prepare clk before calling enable USB: HWA: fix device probe failure wusbcore: add entries in Documentation/ABI for new wusbhc sysfs attributes wusbcore: add sysfs attribute for retry count wusbcore: add sysfs attribute for DNTS count and interval usb: chipidea: drop "13xxx" infix usb: phy: tegra: remove duplicated include from phy-tegra-usb.c usb: host: xhci-plat: release mem region while removing module usbmisc_imx: allow autoloading on according to dt ids usb: fix build error without CONFIG_USB_PHY usb: check usb_hub_to_struct_hub() return value xhci: check for failed dma pool allocation usb: gadget: f_subset: fix missing unlock on error in geth_alloc() usb: gadget: f_ncm: fix missing unlock on error in ncm_alloc() usb: gadget: f_ecm: fix missing unlock on error in ecm_alloc() ...
Diffstat (limited to 'drivers/usb/gadget/f_obex.c')
-rw-r--r--drivers/usb/gadget/f_obex.c75
1 files changed, 8 insertions, 67 deletions
diff --git a/drivers/usb/gadget/f_obex.c b/drivers/usb/gadget/f_obex.c
index 8aa2be5329bc..ad39f1dacba3 100644
--- a/drivers/usb/gadget/f_obex.c
+++ b/drivers/usb/gadget/f_obex.c
@@ -309,23 +309,20 @@ static int obex_bind(struct usb_configuration *c, struct usb_function *f)
309{ 309{
310 struct usb_composite_dev *cdev = c->cdev; 310 struct usb_composite_dev *cdev = c->cdev;
311 struct f_obex *obex = func_to_obex(f); 311 struct f_obex *obex = func_to_obex(f);
312 struct usb_string *us;
312 int status; 313 int status;
313 struct usb_ep *ep; 314 struct usb_ep *ep;
314 315
315 if (!can_support_obex(c)) 316 if (!can_support_obex(c))
316 return -EINVAL; 317 return -EINVAL;
317 318
318 if (obex_string_defs[OBEX_CTRL_IDX].id == 0) { 319 us = usb_gstrings_attach(cdev, obex_strings,
319 status = usb_string_ids_tab(c->cdev, obex_string_defs); 320 ARRAY_SIZE(obex_string_defs));
320 if (status < 0) 321 if (IS_ERR(us))
321 return status; 322 return PTR_ERR(us);
322 obex_control_intf.iInterface = 323 obex_control_intf.iInterface = us[OBEX_CTRL_IDX].id;
323 obex_string_defs[OBEX_CTRL_IDX].id; 324 obex_data_nop_intf.iInterface = us[OBEX_DATA_IDX].id;
324 325 obex_data_intf.iInterface = us[OBEX_DATA_IDX].id;
325 status = obex_string_defs[OBEX_DATA_IDX].id;
326 obex_data_nop_intf.iInterface = status;
327 obex_data_intf.iInterface = status;
328 }
329 326
330 /* allocate instance-specific interface IDs, and patch descriptors */ 327 /* allocate instance-specific interface IDs, and patch descriptors */
331 328
@@ -406,57 +403,6 @@ fail:
406 return status; 403 return status;
407} 404}
408 405
409#ifdef USBF_OBEX_INCLUDED
410
411static void
412obex_old_unbind(struct usb_configuration *c, struct usb_function *f)
413{
414 obex_string_defs[OBEX_CTRL_IDX].id = 0;
415 usb_free_all_descriptors(f);
416 kfree(func_to_obex(f));
417}
418
419/**
420 * obex_bind_config - add a CDC OBEX function to a configuration
421 * @c: the configuration to support the CDC OBEX instance
422 * @port_num: /dev/ttyGS* port this interface will use
423 * Context: single threaded during gadget setup
424 *
425 * Returns zero on success, else negative errno.
426 */
427int __init obex_bind_config(struct usb_configuration *c, u8 port_num)
428{
429 struct f_obex *obex;
430 int status;
431
432 /* allocate and initialize one new instance */
433 obex = kzalloc(sizeof *obex, GFP_KERNEL);
434 if (!obex)
435 return -ENOMEM;
436
437 obex->port_num = port_num;
438
439 obex->port.connect = obex_connect;
440 obex->port.disconnect = obex_disconnect;
441
442 obex->port.func.name = "obex";
443 obex->port.func.strings = obex_strings;
444 /* descriptors are per-instance copies */
445 obex->port.func.bind = obex_bind;
446 obex->port.func.unbind = obex_old_unbind;
447 obex->port.func.set_alt = obex_set_alt;
448 obex->port.func.get_alt = obex_get_alt;
449 obex->port.func.disable = obex_disable;
450
451 status = usb_add_function(c, &obex->port.func);
452 if (status)
453 kfree(obex);
454
455 return status;
456}
457
458#else
459
460static inline struct f_serial_opts *to_f_serial_opts(struct config_item *item) 406static inline struct f_serial_opts *to_f_serial_opts(struct config_item *item)
461{ 407{
462 return container_of(to_config_group(item), struct f_serial_opts, 408 return container_of(to_config_group(item), struct f_serial_opts,
@@ -550,7 +496,6 @@ static void obex_free(struct usb_function *f)
550 496
551static void obex_unbind(struct usb_configuration *c, struct usb_function *f) 497static void obex_unbind(struct usb_configuration *c, struct usb_function *f)
552{ 498{
553 obex_string_defs[OBEX_CTRL_IDX].id = 0;
554 usb_free_all_descriptors(f); 499 usb_free_all_descriptors(f);
555} 500}
556 501
@@ -572,7 +517,6 @@ struct usb_function *obex_alloc(struct usb_function_instance *fi)
572 obex->port.disconnect = obex_disconnect; 517 obex->port.disconnect = obex_disconnect;
573 518
574 obex->port.func.name = "obex"; 519 obex->port.func.name = "obex";
575 obex->port.func.strings = obex_strings;
576 /* descriptors are per-instance copies */ 520 /* descriptors are per-instance copies */
577 obex->port.func.bind = obex_bind; 521 obex->port.func.bind = obex_bind;
578 obex->port.func.unbind = obex_unbind; 522 obex->port.func.unbind = obex_unbind;
@@ -585,8 +529,5 @@ struct usb_function *obex_alloc(struct usb_function_instance *fi)
585} 529}
586 530
587DECLARE_USB_FUNCTION_INIT(obex, obex_alloc_inst, obex_alloc); 531DECLARE_USB_FUNCTION_INIT(obex, obex_alloc_inst, obex_alloc);
588
589#endif
590
591MODULE_AUTHOR("Felipe Balbi"); 532MODULE_AUTHOR("Felipe Balbi");
592MODULE_LICENSE("GPL"); 533MODULE_LICENSE("GPL");