static int msg_do_config(struct usb_configuration *c) { struct fsg_opts *opts; int ret; if (gadget_is_otg(c->cdev->gadget)) { c->descriptors = otg_desc; c->bmAttributes |= USB_CONFIG_ATT_WAKEUP; } opts = fsg_opts_from_func_inst(fi_msg); f_msg = usb_get_function(fi_msg); if (IS_ERR(f_msg)) return PTR_ERR(f_msg); ret = fsg_common_run_thread(opts->common); if (ret) goto put_func; ret = usb_add_function(c, f_msg); if (ret) goto put_func; return 0; put_func: usb_put_function(f_msg); return ret; }
static __init int cdc_do_config(struct usb_configuration *c) { struct fsg_opts *fsg_opts; int ret; if (gadget_is_otg(c->cdev->gadget)) { c->descriptors = otg_desc; c->bmAttributes |= USB_CONFIG_ATT_WAKEUP; } f_ecm = usb_get_function(fi_ecm); if (IS_ERR(f_ecm)) return PTR_ERR(f_ecm); ret = usb_add_function(c, f_ecm); if (ret < 0) goto err_func_ecm; /* implicit port_num is zero */ f_acm_multi = usb_get_function(fi_acm); if (IS_ERR(f_acm_multi)) { ret = PTR_ERR(f_acm_multi); goto err_func_acm; } ret = usb_add_function(c, f_acm_multi); if (ret) goto err_conf; f_msg_multi = usb_get_function(fi_msg); if (IS_ERR(f_msg_multi)) { ret = PTR_ERR(f_msg_multi); goto err_fsg; } fsg_opts = fsg_opts_from_func_inst(fi_msg); ret = fsg_common_run_thread(fsg_opts->common); if (ret) goto err_run; ret = usb_add_function(c, f_msg_multi); if (ret) goto err_run; return 0; err_run: usb_put_function(f_msg_multi); err_fsg: usb_remove_function(c, f_acm_multi); err_conf: usb_put_function(f_acm_multi); err_func_acm: usb_remove_function(c, f_ecm); err_func_ecm: usb_put_function(f_ecm); return ret; }
/* * We _always_ have both ACM and mass storage functions. */ static int acm_ms_do_config(struct usb_configuration *c) { struct fsg_opts *opts; int status; if (gadget_is_otg(c->cdev->gadget)) { c->descriptors = otg_desc; c->bmAttributes |= USB_CONFIG_ATT_WAKEUP; } opts = fsg_opts_from_func_inst(fi_msg); f_acm = usb_get_function(f_acm_inst); if (IS_ERR(f_acm)) return PTR_ERR(f_acm); f_msg = usb_get_function(fi_msg); if (IS_ERR(f_msg)) { status = PTR_ERR(f_msg); goto put_acm; } status = usb_add_function(c, f_acm); if (status < 0) goto put_msg; status = fsg_common_run_thread(opts->common); if (status) goto remove_acm; status = usb_add_function(c, f_msg); if (status) goto remove_acm; return 0; remove_acm: usb_remove_function(c, f_acm); put_msg: usb_put_function(f_msg); put_acm: usb_put_function(f_acm); return status; }
static int nokia_bind_config(struct usb_configuration *c) { struct usb_function *f_acm; struct usb_function *f_phonet = NULL; struct usb_function *f_obex1 = NULL; struct usb_function *f_ecm; struct usb_function *f_obex2 = NULL; struct usb_function *f_msg; struct fsg_opts *fsg_opts; int status = 0; int obex1_stat = -1; int obex2_stat = -1; int phonet_stat = -1; if (!IS_ERR(fi_phonet)) { f_phonet = usb_get_function(fi_phonet); if (IS_ERR(f_phonet)) pr_debug("could not get phonet function\n"); } if (!IS_ERR(fi_obex1)) { f_obex1 = usb_get_function(fi_obex1); if (IS_ERR(f_obex1)) pr_debug("could not get obex function 0\n"); } if (!IS_ERR(fi_obex2)) { f_obex2 = usb_get_function(fi_obex2); if (IS_ERR(f_obex2)) pr_debug("could not get obex function 1\n"); } f_acm = usb_get_function(fi_acm); if (IS_ERR(f_acm)) { status = PTR_ERR(f_acm); goto err_get_acm; } f_ecm = usb_get_function(fi_ecm); if (IS_ERR(f_ecm)) { status = PTR_ERR(f_ecm); goto err_get_ecm; } f_msg = usb_get_function(fi_msg); if (IS_ERR(f_msg)) { status = PTR_ERR(f_msg); goto err_get_msg; } if (!IS_ERR_OR_NULL(f_phonet)) { phonet_stat = usb_add_function(c, f_phonet); if (phonet_stat) pr_debug("could not add phonet function\n"); } if (!IS_ERR_OR_NULL(f_obex1)) { obex1_stat = usb_add_function(c, f_obex1); if (obex1_stat) pr_debug("could not add obex function 0\n"); } if (!IS_ERR_OR_NULL(f_obex2)) { obex2_stat = usb_add_function(c, f_obex2); if (obex2_stat) pr_debug("could not add obex function 1\n"); } status = usb_add_function(c, f_acm); if (status) goto err_conf; status = usb_add_function(c, f_ecm); if (status) { pr_debug("could not bind ecm config %d\n", status); goto err_ecm; } fsg_opts = fsg_opts_from_func_inst(fi_msg); status = fsg_common_run_thread(fsg_opts->common); if (status) goto err_msg; status = usb_add_function(c, f_msg); if (status) goto err_msg; if (c == &nokia_config_500ma_driver) { f_acm_cfg1 = f_acm; f_ecm_cfg1 = f_ecm; f_phonet_cfg1 = f_phonet; f_obex1_cfg1 = f_obex1; f_obex2_cfg1 = f_obex2; f_msg_cfg1 = f_msg; } else { f_acm_cfg2 = f_acm; f_ecm_cfg2 = f_ecm; f_phonet_cfg2 = f_phonet; f_obex1_cfg2 = f_obex1; f_obex2_cfg2 = f_obex2; f_msg_cfg2 = f_msg; } return status; err_msg: usb_remove_function(c, f_ecm); err_ecm: usb_remove_function(c, f_acm); err_conf: if (!obex2_stat) usb_remove_function(c, f_obex2); if (!obex1_stat) usb_remove_function(c, f_obex1); if (!phonet_stat) usb_remove_function(c, f_phonet); usb_put_function(f_msg); err_get_msg: usb_put_function(f_ecm); err_get_ecm: usb_put_function(f_acm); err_get_acm: if (!IS_ERR_OR_NULL(f_obex2)) usb_put_function(f_obex2); if (!IS_ERR_OR_NULL(f_obex1)) usb_put_function(f_obex1); if (!IS_ERR_OR_NULL(f_phonet)) usb_put_function(f_phonet); return status; }