static int acc_function_set_alt(struct usb_function *f, unsigned intf, unsigned alt) { struct acc_dev *dev = func_to_dev(f); struct usb_composite_dev *cdev = f->config->cdev; int ret; DBG(cdev, "acc_function_set_alt intf: %d alt: %d\n", intf, alt); ret = usb_ep_enable(dev->ep_in, ep_choose(cdev->gadget, &acc_highspeed_in_desc, &acc_fullspeed_in_desc)); if (ret) return ret; ret = usb_ep_enable(dev->ep_out, ep_choose(cdev->gadget, &acc_highspeed_out_desc, &acc_fullspeed_out_desc)); if (ret) { usb_ep_disable(dev->ep_in); return ret; } dev->online = 1; /* readers may be blocked waiting for us to go online */ wake_up(&dev->read_wq); #ifdef CONFIG_ANDROID_PANTECH_USB_MANAGER usb_interface_enum_cb(ACCESSORY_TYPE_FLAG); #endif return 0; }
static int acc_function_set_alt(struct usb_function *f, unsigned intf, unsigned alt) { struct acc_dev *dev = func_to_dev(f); struct usb_composite_dev *cdev = f->config->cdev; int ret; DBG(cdev, "acc_function_set_alt intf: %d alt: %d\n", intf, alt); ret = usb_ep_enable(dev->ep_in, ep_choose(cdev->gadget, &acc_highspeed_in_desc, &acc_fullspeed_in_desc)); if (ret) return ret; ret = usb_ep_enable(dev->ep_out, ep_choose(cdev->gadget, &acc_highspeed_out_desc, &acc_fullspeed_out_desc)); if (ret) { usb_ep_disable(dev->ep_in); return ret; } if (!dev->function.hidden) dev->online = 1; /* readers may be blocked waiting for us to go online */ wake_up(&dev->read_wq); return 0; }
static int dtf_function_set_alt(struct usb_function *f, unsigned intf, unsigned alt) { struct dtf_dev *dev = func_to_dtf(f); struct usb_composite_dev *cdev = f->config->cdev; int ret; int set_alt_end = 0; int speed_check = 0; _dbgmsg("dtf_function_set_alt(intf=%d,alt=%d)\n", intf, alt); /* MSEMSEMSE */ if( dev->pg.mCtrl_id == intf ) { _dbgmsg_gadget( "usb_ep_enable(%s)\n", dev->pg.ep_intr->name ); /* MSEMSEMSE */ ret = usb_ep_enable( dev->pg.ep_intr, ep_choose( cdev->gadget, &vPg1_epintr_desc_hs, &vPg1_epintr_desc ) ); if( ret ) { _dbgmsg( "usb_ep_enable error pg1 ep_intr ret = %d\n", ret );/* MSEMSEMSE */ return ret; } dev->mCtrl_ep_enbl = 1; } else if( dev->pg.mData_id == intf ) { _dbgmsg_gadget( "usb_ep_enable(%s)\n", dev->pg.ep_in->name ); /* MSEMSEMSE */ ret = usb_ep_enable( dev->pg.ep_in, ep_choose( cdev->gadget, &vPg1_epin_desc_hs, &vPg1_epin_desc ) ); if( ret ) { _dbgmsg( "usb_ep_enable error pg1 ep_in ret = %d\n", ret ); /* MSEMSEMSE */ return ret; } _dbgmsg_gadget( "usb_ep_enable(%s)\n", dev->pg.ep_out->name ); /* MSEMSEMSE */ ret = usb_ep_enable( dev->pg.ep_out, ep_choose( cdev->gadget, &vPg1_epout_desc_hs, &vPg1_epout_desc ) ); if( ret ) { _dbgmsg( "usb_ep_enable error pg1 ep_out ret = %d\n", ret );/* MSEMSEMSE */ usb_ep_disable(dev->pg.ep_in); return ret; } dev->pg.mReq_out->length = 512; usb_ep_queue( dev->pg.ep_out, dev->pg.mReq_out, GFP_ATOMIC ); dev->mData_ep_enbl = 1; } else { _dbgmsg( "unknown interface number\n" ); /* MSEMSEMSE */ } set_alt_end = ( (dev->mCtrl_ep_enbl) & (dev->mData_ep_enbl) ); speed_check = (dev->cdev->gadget->speed == USB_SPEED_HIGH)?(1):(0); if (set_alt_end == 1) { dtf_if_out_set_alt( speed_check ); } return 0; }
static int mtp_function_set_alt(struct usb_function *f, unsigned intf, unsigned alt) { int ret; printk(KERN_DEBUG "%s intf=%d alt=%d\n", __func__, intf, alt); ret = usb_ep_enable(g_usb_mtp_context.bulk_in, ep_choose(g_usb_mtp_context.cdev->gadget, &hs_bulk_in_desc, &fs_bulk_in_desc)); if (ret) return ret; ret = usb_ep_enable(g_usb_mtp_context.bulk_out, ep_choose(g_usb_mtp_context.cdev->gadget, &hs_bulk_out_desc, &fs_bulk_out_desc)); if (ret) { usb_ep_disable(g_usb_mtp_context.bulk_in); return ret; } ret = usb_ep_enable(g_usb_mtp_context.intr_in, ep_choose(g_usb_mtp_context.cdev->gadget, &hs_intr_in_desc, &fs_intr_in_desc)); if (ret) { usb_ep_disable(g_usb_mtp_context.bulk_in); usb_ep_disable(g_usb_mtp_context.bulk_out); return ret; } usb_interface_enum_cb(MTP_TYPE_FLAG); g_usb_mtp_context.cur_read_req = 0; g_usb_mtp_context.read_buf = 0; g_usb_mtp_context.data_len = 0; /* we're online -- get all rx requests queued */ start_out_receive(); g_usb_mtp_context.online = 1; g_usb_mtp_context.cancel = 0; g_usb_mtp_context.ctl_cancel = 0; g_usb_mtp_context.error = 0; /* readers may be blocked waiting for us to go online */ wake_up(&g_usb_mtp_context.rx_wq); return 0; }
static int gser_set_alt(struct usb_function *f, unsigned intf, unsigned alt) { struct f_gser *gser = func_to_gser(f); struct usb_composite_dev *cdev = f->config->cdev; int rc = 0; /* we know alt == 0, so this is an activation or a reset */ #ifdef CONFIG_MODEM_SUPPORT if (gser->notify->driver_data) { DBG(cdev, "reset generic ctl ttyGS%d\n", gser->port_num); usb_ep_disable(gser->notify); } gser->notify_desc = ep_choose(cdev->gadget, gser->hs.notify, gser->fs.notify); rc = usb_ep_enable(gser->notify, gser->notify_desc); if (rc) { ERROR(cdev, "can't enable %s, result %d\n", gser->notify->name, rc); return rc; } gser->notify->driver_data = gser; #endif if (gser->port.in->driver_data) { DBG(cdev, "reset generic data ttyGS%d\n", gser->port_num); gport_disconnect(gser); } else { DBG(cdev, "activate generic data ttyGS%d\n", gser->port_num); } gser->port.in_desc = ep_choose(cdev->gadget, gser->hs.in, gser->fs.in); gser->port.out_desc = ep_choose(cdev->gadget, gser->hs.out, gser->fs.out); #ifdef FEATURE_PANTECH_MODEM_REOPEN_DELAY schedule_delayed_work(&gser->connect_work, msecs_to_jiffies(50)); #else gport_connect(gser); #endif gser->online = 1; #ifdef CONFIG_ANDROID_PANTECH_USB_MANAGER usb_interface_enum_cb(ACM_TYPE_FLAG); #endif return rc; }
static int gser_set_alt(struct usb_function *f, unsigned intf, unsigned alt) { struct f_gser *gser = func_to_gser(f); struct usb_composite_dev *cdev = f->config->cdev; int rc = 0; /* we know alt == 0, so this is an activation or a reset */ #ifdef CONFIG_MODEM_SUPPORT if (gser->notify->driver_data) { DBG(cdev, "reset generic ctl ttyGS%d\n", gser->port_num); usb_ep_disable(gser->notify); } gser->notify_desc = ep_choose(cdev->gadget, gser->hs.notify, gser->fs.notify); rc = usb_ep_enable(gser->notify, gser->notify_desc); if (rc) { ERROR(cdev, "can't enable %s, result %d\n", gser->notify->name, rc); return rc; } gser->notify->driver_data = gser; #endif if (gser->port.in->driver_data) { DBG(cdev, "reset generic data ttyGS%d\n", gser->port_num); gport_disconnect(gser); } else { DBG(cdev, "activate generic data ttyGS%d\n", gser->port_num); } gser->port.in_desc = ep_choose(cdev->gadget, gser->hs.in, gser->fs.in); gser->port.out_desc = ep_choose(cdev->gadget, gser->hs.out, gser->fs.out); gport_connect(gser); gser->online = 1; gserial_ports[gser->port_num].enable = gser->online; return rc; }
static int set_fastboot_config(struct fastboot_dev *dev, gfp_t gfp_flags) { int result = 0; struct usb_gadget *gadget = dev->gadget; dev->in = ep_choose(gadget, &hs_source_desc, &fs_source_desc); dev->in_ep->driver_data = dev; dev->out = ep_choose(gadget, &hs_sink_desc, &fs_sink_desc); dev->out_ep->driver_data = dev; result = usb_ep_enable(dev->in_ep, dev->in); if (result != 0) { debug("enable %s --> %d\n", dev->in_ep->name, result); goto done; } result = usb_ep_enable(dev->out_ep, dev->out); if (result != 0) { debug("enable %s --> %d\n", dev->out_ep->name, result); goto done; } done: if (result == 0) result = alloc_requests(dev, 1, gfp_flags); /* on error, disable any endpoints */ if (result < 0) { (void)usb_ep_disable(dev->in_ep); (void)usb_ep_disable(dev->out_ep); dev->in = NULL; dev->out = NULL; } /* caller is responsible for cleanup on error */ return result; }
int f_cloner_set_alt(struct usb_function *f, unsigned interface, unsigned alt) { struct cloner *cloner = func_to_cloner(f); const struct usb_endpoint_descriptor *epin_desc,*epout_desc; int status = 0; debug_cond(BURNNER_DEBUG,"set interface %d alt %d\n",interface,alt); epin_desc = ep_choose(cloner->gadget,&hs_bulk_in_desc,&fs_bulk_in_desc); epout_desc = ep_choose(cloner->gadget,&hs_bulk_out_desc,&fs_bulk_out_desc); status += usb_ep_enable(cloner->ep_in,epin_desc); status += usb_ep_enable(cloner->ep_out,epout_desc); if (status < 0) { printf("usb enable ep failed\n"); goto failed; } cloner->ep_in->driver_data = cloner; cloner->ep_out->driver_data = cloner; failed: return status; }
static int ecm_set_alt(struct usb_function *f, unsigned intf, unsigned alt) { struct f_ecm *ecm = func_to_ecm(f); struct usb_composite_dev *cdev = f->config->cdev; /* Control interface has only altsetting 0 */ if (intf == ecm->ctrl_id) { if (alt != 0) goto fail; if (ecm->notify->driver_data) { VDBG(cdev, "reset ecm control %d\n", intf); usb_ep_disable(ecm->notify); } else { VDBG(cdev, "init ecm ctrl %d\n", intf); ecm->notify_desc = ep_choose(cdev->gadget, ecm->hs.notify, ecm->fs.notify); } usb_ep_enable(ecm->notify, ecm->notify_desc); ecm->notify->driver_data = ecm; /* Data interface has two altsettings, 0 and 1 */ } else if (intf == ecm->data_id) { if (alt > 1) goto fail; if (ecm->port.in_ep->driver_data) { DBG(cdev, "reset ecm\n"); gether_disconnect(&ecm->port); } if (!ecm->port.in) { DBG(cdev, "init ecm\n"); ecm->port.in = ep_choose(cdev->gadget, ecm->hs.in, ecm->fs.in); ecm->port.out = ep_choose(cdev->gadget, ecm->hs.out, ecm->fs.out); } /* CDC Ethernet only sends data in non-default altsettings. * Changing altsettings resets filters, statistics, etc. */ if (alt == 1) { struct net_device *net; #ifdef CONFIG_LGE_USB_GADGET_DRIVER ecm->port.is_zlp_ok = !( gadget_is_musbhdrc(cdev->gadget) || gadget_is_fsl_usb2(cdev->gadget) ); #else /* Enable zlps by default for ECM conformance; * override for musb_hdrc (avoids txdma ovhead). */ ecm->port.is_zlp_ok = !(gadget_is_musbhdrc(cdev->gadget)); #endif ecm->port.cdc_filter = DEFAULT_FILTER; DBG(cdev, "activate ecm\n"); net = gether_connect(&ecm->port); if (IS_ERR(net)) return PTR_ERR(net); } /* NOTE this can be a minor disagreement with the ECM spec, * which says speed notifications will "always" follow * connection notifications. But we allow one connect to * follow another (if the first is in flight), and instead * just guarantee that a speed notification is always sent. */ ecm_notify(ecm); } else goto fail; return 0; fail: return -EINVAL; }