这篇教程C++ usb_endpoint_is_bulk_out函数代码示例写得很实用,希望能帮到您。
本文整理汇总了C++中usb_endpoint_is_bulk_out函数的典型用法代码示例。如果您正苦于以下问题:C++ usb_endpoint_is_bulk_out函数的具体用法?C++ usb_endpoint_is_bulk_out怎么用?C++ usb_endpoint_is_bulk_out使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。 在下文中一共展示了usb_endpoint_is_bulk_out函数的25个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。 示例1: qcprobestatic int qcprobe(struct usb_serial *serial, const struct usb_device_id *id){ struct usb_host_interface *intf = serial->interface->cur_altsetting; struct device *dev = &serial->dev->dev; int retval = -ENODEV; __u8 nintf; __u8 ifnum; int altsetting = -1; bool sendsetup = false; /* we only support vendor specific functions */ if (intf->desc.bInterfaceClass != USB_CLASS_VENDOR_SPEC) goto done; nintf = serial->dev->actconfig->desc.bNumInterfaces; dev_dbg(dev, "Num Interfaces = %d/n", nintf); ifnum = intf->desc.bInterfaceNumber; dev_dbg(dev, "This Interface = %d/n", ifnum); if (nintf == 1) { /* QDL mode */ /* Gobi 2000 has a single altsetting, older ones have two */ if (serial->interface->num_altsetting == 2) intf = &serial->interface->altsetting[1]; else if (serial->interface->num_altsetting > 2) goto done; if (intf->desc.bNumEndpoints == 2 && usb_endpoint_is_bulk_in(&intf->endpoint[0].desc) && usb_endpoint_is_bulk_out(&intf->endpoint[1].desc)) { dev_dbg(dev, "QDL port found/n"); if (serial->interface->num_altsetting == 1) retval = 0; /* Success */ else altsetting = 1; } goto done; } /* default to enabling interface */ altsetting = 0; /* * Composite mode; don't bind to the QMI/net interface as that * gets handled by other drivers. */ switch (id->driver_info) { case QCSERIAL_G1K: /* * Gobi 1K USB layout: * 0: DM/DIAG (use libqcdm from ModemManager for communication) * 1: serial port (doesn't respond) * 2: AT-capable modem port * 3: QMI/net */ if (nintf < 3 || nintf > 4) { dev_err(dev, "unknown number of interfaces: %d/n", nintf); altsetting = -1; goto done; } if (ifnum == 0) { dev_dbg(dev, "Gobi 1K DM/DIAG interface found/n"); altsetting = 1; } else if (ifnum == 2) dev_dbg(dev, "Modem port found/n"); else altsetting = -1; break; case QCSERIAL_G2K: /* handle non-standard layouts */ if (nintf == 5 && id->idProduct == QUECTEL_EC20_PID) { altsetting = handle_quectel_ec20(dev, ifnum); goto done; } /* * Gobi 2K+ USB layout: * 0: QMI/net * 1: DM/DIAG (use libqcdm from ModemManager for communication) * 2: AT-capable modem port * 3: NMEA */ if (nintf < 3 || nintf > 4) { dev_err(dev, "unknown number of interfaces: %d/n", nintf); altsetting = -1; goto done; } switch (ifnum) { case 0: /* Don't claim the QMI/net interface */ altsetting = -1; break; case 1: dev_dbg(dev, "Gobi 2K+ DM/DIAG interface found/n"); break;//.........这里部分代码省略.........
开发者ID:Codefollows,项目名称:ps4-linux,代码行数:101,
示例2: xpad_probe//.........这里部分代码省略......... goto fail4; error = xpad_led_probe(xpad); if (error) goto fail5; /* Xbox One controller has in/out endpoints swapped. */ ep_irq_in_idx = xpad->xtype == XTYPE_XBOXONE ? 1 : 0; ep_irq_in = &intf->cur_altsetting->endpoint[ep_irq_in_idx].desc; usb_fill_int_urb(xpad->irq_in, udev, usb_rcvintpipe(udev, ep_irq_in->bEndpointAddress), xpad->idata, XPAD_PKT_LEN, xpad_irq_in, xpad, ep_irq_in->bInterval); xpad->irq_in->transfer_dma = xpad->idata_dma; xpad->irq_in->transfer_flags |= URB_NO_TRANSFER_DMA_MAP; error = input_register_device(xpad->dev); if (error) goto fail6; usb_set_intfdata(intf, xpad); if (xpad->xtype == XTYPE_XBOX360W) { /* * Setup the message to set the LEDs on the * controller when it shows up */ xpad->bulk_out = usb_alloc_urb(0, GFP_KERNEL); if (!xpad->bulk_out) { error = -ENOMEM; goto fail7; } xpad->bdata = kzalloc(XPAD_PKT_LEN, GFP_KERNEL); if (!xpad->bdata) { error = -ENOMEM; goto fail8; } xpad->bdata[2] = 0x08; switch (intf->cur_altsetting->desc.bInterfaceNumber) { case 0: xpad->bdata[3] = 0x42; break; case 2: xpad->bdata[3] = 0x43; break; case 4: xpad->bdata[3] = 0x44; break; case 6: xpad->bdata[3] = 0x45; } ep_irq_in = &intf->cur_altsetting->endpoint[1].desc; if (usb_endpoint_is_bulk_out(ep_irq_in)) { usb_fill_bulk_urb(xpad->bulk_out, udev, usb_sndbulkpipe(udev, ep_irq_in->bEndpointAddress), xpad->bdata, XPAD_PKT_LEN, xpad_bulk_out, xpad); } else { usb_fill_int_urb(xpad->bulk_out, udev, usb_sndintpipe(udev, ep_irq_in->bEndpointAddress), xpad->bdata, XPAD_PKT_LEN, xpad_bulk_out, xpad, 0); } /* * Submit the int URB immediately rather than waiting for open * because we get status messages from the device whether * or not any controllers are attached. In fact, it's * exactly the message that a controller has arrived that * we're waiting for. */ xpad->irq_in->dev = xpad->udev; error = usb_submit_urb(xpad->irq_in, GFP_KERNEL); if (error) goto fail9; } return 0; fail9: kfree(xpad->bdata); fail8: usb_free_urb(xpad->bulk_out); fail7: input_unregister_device(input_dev); input_dev = NULL; fail6: xpad_led_disconnect(xpad); fail5: if (input_dev) input_ff_destroy(input_dev); fail4: xpad_deinit_output(xpad); fail3: usb_free_urb(xpad->irq_in); fail2: usb_free_coherent(udev, XPAD_PKT_LEN, xpad->idata, xpad->idata_dma); fail1: input_free_device(input_dev); kfree(xpad); return error;}
开发者ID:19Dan01,项目名称:linux,代码行数:101,
示例3: btusb_probestatic int btusb_probe(struct usb_interface *intf, const struct usb_device_id *id){ struct usb_endpoint_descriptor *ep_desc; struct btusb_data *data; struct hci_dev *hdev; int i, err; BT_DBG("intf %p id %p", intf, id); /* interface numbers are hardcoded in the spec */ if (intf->cur_altsetting->desc.bInterfaceNumber != 0) return -ENODEV; if (!id->driver_info) { const struct usb_device_id *match; match = usb_match_id(intf, blacklist_table); if (match) id = match; } if (id->driver_info == BTUSB_IGNORE) return -ENODEV; if (ignore_dga && id->driver_info & BTUSB_DIGIANSWER) return -ENODEV; if (ignore_csr && id->driver_info & BTUSB_CSR) return -ENODEV; if (ignore_sniffer && id->driver_info & BTUSB_SNIFFER) return -ENODEV; if (id->driver_info & BTUSB_ATH3012) { struct usb_device *udev = interface_to_usbdev(intf); /* Old firmware would otherwise let ath3k driver load * patch and sysconfig files */ if (le16_to_cpu(udev->descriptor.bcdDevice) <= 0x0001) return -ENODEV; } data = kzalloc(sizeof(*data), GFP_KERNEL); if (!data) return -ENOMEM; for (i = 0; i < intf->cur_altsetting->desc.bNumEndpoints; i++) { ep_desc = &intf->cur_altsetting->endpoint[i].desc; if (!data->intr_ep && usb_endpoint_is_int_in(ep_desc)) { data->intr_ep = ep_desc; continue; } if (!data->bulk_tx_ep && usb_endpoint_is_bulk_out(ep_desc)) { data->bulk_tx_ep = ep_desc; continue; } if (!data->bulk_rx_ep && usb_endpoint_is_bulk_in(ep_desc)) { data->bulk_rx_ep = ep_desc; continue; } } if (!data->intr_ep || !data->bulk_tx_ep || !data->bulk_rx_ep) { kfree(data); return -ENODEV; } data->cmdreq_type = USB_TYPE_CLASS; data->udev = interface_to_usbdev(intf); data->intf = intf; spin_lock_init(&data->lock); INIT_WORK(&data->work, btusb_work); INIT_WORK(&data->waker, btusb_waker); spin_lock_init(&data->txlock); init_usb_anchor(&data->tx_anchor); init_usb_anchor(&data->intr_anchor); init_usb_anchor(&data->bulk_anchor); init_usb_anchor(&data->isoc_anchor); init_usb_anchor(&data->deferred); hdev = hci_alloc_dev(); if (!hdev) { kfree(data); return -ENOMEM; } hdev->bus = HCI_USB; hdev->driver_data = data; data->hdev = hdev; SET_HCIDEV_DEV(hdev, &intf->dev);//.........这里部分代码省略.........
开发者ID:corvusmod,项目名称:wetab-ICS-device-tree,代码行数:101,
示例4: btusb_probestatic int btusb_probe(struct usb_interface *intf, const struct usb_device_id *id){ struct usb_endpoint_descriptor *ep_desc; struct btusb_data *data; struct hci_dev *hdev; int i, version, err; BT_DBG("intf %p id %p", intf, id); /* interface numbers are hardcoded in the spec */ if (intf->cur_altsetting->desc.bInterfaceNumber != 0) return -ENODEV; if (!id->driver_info) { const struct usb_device_id *match; match = usb_match_id(intf, blacklist_table); if (match) id = match; } if (id->driver_info == BTUSB_IGNORE) return -ENODEV; if (ignore_dga && id->driver_info & BTUSB_DIGIANSWER) return -ENODEV; if (ignore_csr && id->driver_info & BTUSB_CSR) return -ENODEV; if (ignore_sniffer && id->driver_info & BTUSB_SNIFFER) return -ENODEV; if (id->driver_info & BTUSB_ATH3012) { struct usb_device *udev = interface_to_usbdev(intf); version = get_rome_version(udev); BT_INFO("Rome Version: 0x%x", version); /* Old firmware would otherwise let ath3k driver load * patch and sysconfig files */ if (version) rome_download(udev); else if (le16_to_cpu(udev->descriptor.bcdDevice) <= 0x0001) { BT_INFO("FW for ar3k is yet to be downloaded"); return -ENODEV; } } data = devm_kzalloc(&intf->dev, sizeof(*data), GFP_KERNEL); if (!data) return -ENOMEM; for (i = 0; i < intf->cur_altsetting->desc.bNumEndpoints; i++) { ep_desc = &intf->cur_altsetting->endpoint[i].desc; if (!data->intr_ep && usb_endpoint_is_int_in(ep_desc)) { data->intr_ep = ep_desc; continue; } if (!data->bulk_tx_ep && usb_endpoint_is_bulk_out(ep_desc)) { data->bulk_tx_ep = ep_desc; continue; } if (!data->bulk_rx_ep && usb_endpoint_is_bulk_in(ep_desc)) { data->bulk_rx_ep = ep_desc; continue; } } if (!data->intr_ep || !data->bulk_tx_ep || !data->bulk_rx_ep) return -ENODEV; data->cmdreq_type = USB_TYPE_CLASS; data->udev = interface_to_usbdev(intf); data->intf = intf; spin_lock_init(&data->lock); INIT_WORK(&data->work, btusb_work); INIT_WORK(&data->waker, btusb_waker); spin_lock_init(&data->txlock); init_usb_anchor(&data->tx_anchor); init_usb_anchor(&data->intr_anchor); init_usb_anchor(&data->bulk_anchor); init_usb_anchor(&data->isoc_anchor); init_usb_anchor(&data->deferred); hdev = hci_alloc_dev(); if (!hdev) return -ENOMEM; hdev->bus = HCI_USB; hci_set_drvdata(hdev, data); data->hdev = hdev; SET_HCIDEV_DEV(hdev, &intf->dev);//.........这里部分代码省略.........
开发者ID:Skin1980,项目名称:bass-MM,代码行数:101,
示例5: if_usb_probe/** * @brief sets the configuration values * @param ifnum interface number * @param id pointer to usb_device_id * @return 0 on success, error code on failure */static int if_usb_probe(struct usb_interface *intf, const struct usb_device_id *id){ struct usb_device *udev; struct usb_host_interface *iface_desc; struct usb_endpoint_descriptor *endpoint; struct lbs_private *priv; struct if_usb_card *cardp; int i; udev = interface_to_usbdev(intf); cardp = kzalloc(sizeof(struct if_usb_card), GFP_KERNEL); if (!cardp) { lbs_pr_err("Out of memory allocating private data./n"); goto error; } setup_timer(&cardp->fw_timeout, if_usb_fw_timeo, (unsigned long)cardp); init_waitqueue_head(&cardp->fw_wq); cardp->udev = udev; iface_desc = intf->cur_altsetting; lbs_deb_usbd(&udev->dev, "bcdUSB = 0x%X bDeviceClass = 0x%X" " bDeviceSubClass = 0x%X, bDeviceProtocol = 0x%X/n", le16_to_cpu(udev->descriptor.bcdUSB), udev->descriptor.bDeviceClass, udev->descriptor.bDeviceSubClass, udev->descriptor.bDeviceProtocol); for (i = 0; i < iface_desc->desc.bNumEndpoints; ++i) { endpoint = &iface_desc->endpoint[i].desc; if (usb_endpoint_is_bulk_in(endpoint)) { cardp->ep_in_size = le16_to_cpu(endpoint->wMaxPacketSize); cardp->ep_in = usb_endpoint_num(endpoint); lbs_deb_usbd(&udev->dev, "in_endpoint = %d/n", cardp->ep_in); lbs_deb_usbd(&udev->dev, "Bulk in size is %d/n", cardp->ep_in_size); } else if (usb_endpoint_is_bulk_out(endpoint)) { cardp->ep_out_size = le16_to_cpu(endpoint->wMaxPacketSize); cardp->ep_out = usb_endpoint_num(endpoint); lbs_deb_usbd(&udev->dev, "out_endpoint = %d/n", cardp->ep_out); lbs_deb_usbd(&udev->dev, "Bulk out size is %d/n", cardp->ep_out_size); } } if (!cardp->ep_out_size || !cardp->ep_in_size) { lbs_deb_usbd(&udev->dev, "Endpoints not found/n"); goto dealloc; } if (!(cardp->rx_urb = usb_alloc_urb(0, GFP_KERNEL))) { lbs_deb_usbd(&udev->dev, "Rx URB allocation failed/n"); goto dealloc; } if (!(cardp->tx_urb = usb_alloc_urb(0, GFP_KERNEL))) { lbs_deb_usbd(&udev->dev, "Tx URB allocation failed/n"); goto dealloc; } cardp->ep_out_buf = kmalloc(MRVDRV_ETH_TX_PACKET_BUFFER_SIZE, GFP_KERNEL); if (!cardp->ep_out_buf) { lbs_deb_usbd(&udev->dev, "Could not allocate buffer/n"); goto dealloc; } /* Upload firmware */ if (if_usb_prog_firmware(cardp)) { lbs_deb_usbd(&udev->dev, "FW upload failed/n"); goto err_prog_firmware; } if (!(priv = lbs_add_card(cardp, &udev->dev))) goto err_prog_firmware; cardp->priv = priv; cardp->priv->fw_ready = 1; priv->hw_host_to_card = if_usb_host_to_card;#ifdef CONFIG_OLPC if (machine_is_olpc()) priv->reset_card = if_usb_reset_olpc_card;#endif cardp->boot2_version = udev->descriptor.bcdDevice; if_usb_submit_rx_urb(cardp); if (lbs_start_card(priv)) goto err_start_card; if_usb_setup_firmware(priv); usb_get_dev(udev);//.........这里部分代码省略.........
开发者ID:LouZiffer,项目名称:m900_kernel_cupcake-SDX,代码行数:101,
示例6: kzallocstatic struct dvobj_priv *usb_dvobj_init(struct usb_interface *usb_intf){ int i; int status = _FAIL; struct dvobj_priv *pdvobjpriv; struct usb_host_config *phost_conf; struct usb_config_descriptor *pconf_desc; struct usb_host_interface *phost_iface; struct usb_interface_descriptor *piface_desc; struct usb_host_endpoint *phost_endp; struct usb_endpoint_descriptor *pendp_desc; struct usb_device *pusbd; pdvobjpriv = kzalloc(sizeof(*pdvobjpriv), GFP_KERNEL); if (pdvobjpriv == NULL) goto exit; pdvobjpriv->pusbintf = usb_intf; pusbd = interface_to_usbdev(usb_intf); pdvobjpriv->pusbdev = pusbd; usb_set_intfdata(usb_intf, pdvobjpriv); pdvobjpriv->RtNumInPipes = 0; pdvobjpriv->RtNumOutPipes = 0; phost_conf = pusbd->actconfig; pconf_desc = &phost_conf->desc; phost_iface = &usb_intf->altsetting[0]; piface_desc = &phost_iface->desc; pdvobjpriv->NumInterfaces = pconf_desc->bNumInterfaces; pdvobjpriv->InterfaceNumber = piface_desc->bInterfaceNumber; pdvobjpriv->nr_endpoint = piface_desc->bNumEndpoints; for (i = 0; i < pdvobjpriv->nr_endpoint; i++) { int ep_num; phost_endp = phost_iface->endpoint + i; if (phost_endp) { pendp_desc = &phost_endp->desc; ep_num = usb_endpoint_num(pendp_desc); if (usb_endpoint_is_bulk_in(pendp_desc)) { pdvobjpriv->RtInPipe[pdvobjpriv->RtNumInPipes] = ep_num; pdvobjpriv->RtNumInPipes++; } else if (usb_endpoint_is_int_in(pendp_desc)) { pdvobjpriv->RtInPipe[pdvobjpriv->RtNumInPipes] = ep_num; pdvobjpriv->RtNumInPipes++; } else if (usb_endpoint_is_bulk_out(pendp_desc)) { pdvobjpriv->RtOutPipe[pdvobjpriv->RtNumOutPipes] = ep_num; pdvobjpriv->RtNumOutPipes++; } pdvobjpriv->ep_num[i] = ep_num; } } if (pusbd->speed == USB_SPEED_HIGH) pdvobjpriv->ishighspeed = true; else pdvobjpriv->ishighspeed = false; mutex_init(&pdvobjpriv->usb_vendor_req_mutex); pdvobjpriv->usb_vendor_req_buf = kzalloc(MAX_USB_IO_CTL_SIZE, GFP_KERNEL); if (!pdvobjpriv->usb_vendor_req_buf) goto free_dvobj; usb_get_dev(pusbd); status = _SUCCESS;free_dvobj: if (status != _SUCCESS && pdvobjpriv) { usb_set_intfdata(usb_intf, NULL); kfree(pdvobjpriv); pdvobjpriv = NULL; }exit: return pdvobjpriv;}
开发者ID:mikemvk,项目名称:linux-at91,代码行数:82,
示例7: kzallocstatic struct dvobj_priv *usb_dvobj_init(struct usb_interface *usb_intf){ struct dvobj_priv *pdvobjpriv; struct usb_host_config *phost_conf; struct usb_config_descriptor *pconf_desc; struct usb_host_interface *phost_iface; struct usb_interface_descriptor *piface_desc; struct usb_endpoint_descriptor *pendp_desc; struct usb_device *pusbd; int i, status = _FAIL; pdvobjpriv = kzalloc(sizeof(*pdvobjpriv), GFP_KERNEL); if (!pdvobjpriv) goto exit; mutex_init(&pdvobjpriv->hw_init_mutex); mutex_init(&pdvobjpriv->h2c_fwcmd_mutex); mutex_init(&pdvobjpriv->setch_mutex); mutex_init(&pdvobjpriv->setbw_mutex); pdvobjpriv->pusbintf = usb_intf; pusbd = interface_to_usbdev(usb_intf); pdvobjpriv->pusbdev = pusbd; usb_set_intfdata(usb_intf, pdvobjpriv); pdvobjpriv->RtNumInPipes = 0; pdvobjpriv->RtNumOutPipes = 0; phost_conf = pusbd->actconfig; pconf_desc = &phost_conf->desc; phost_iface = &usb_intf->altsetting[0]; piface_desc = &phost_iface->desc; pdvobjpriv->NumInterfaces = pconf_desc->bNumInterfaces; pdvobjpriv->InterfaceNumber = piface_desc->bInterfaceNumber; pdvobjpriv->nr_endpoint = piface_desc->bNumEndpoints; for (i = 0; i < pdvobjpriv->nr_endpoint; i++) { pendp_desc = &phost_iface->endpoint[i].desc; DBG_8723A("/nusb_endpoint_descriptor(%d):/n", i); DBG_8723A("bLength =%x/n", pendp_desc->bLength); DBG_8723A("bDescriptorType =%x/n", pendp_desc->bDescriptorType); DBG_8723A("bEndpointAddress =%x/n", pendp_desc->bEndpointAddress); DBG_8723A("wMaxPacketSize =%d/n", le16_to_cpu(pendp_desc->wMaxPacketSize)); DBG_8723A("bInterval =%x/n", pendp_desc->bInterval); if (usb_endpoint_is_bulk_in(pendp_desc)) { DBG_8723A("usb_endpoint_is_bulk_in = %x/n", usb_endpoint_num(pendp_desc)); pdvobjpriv->RtInPipe[pdvobjpriv->RtNumInPipes] = usb_endpoint_num(pendp_desc); pdvobjpriv->RtNumInPipes++; } else if (usb_endpoint_is_int_in(pendp_desc)) { DBG_8723A("usb_endpoint_is_int_in = %x, Interval = " "%x/n", usb_endpoint_num(pendp_desc), pendp_desc->bInterval); pdvobjpriv->RtInPipe[pdvobjpriv->RtNumInPipes] = usb_endpoint_num(pendp_desc); pdvobjpriv->RtNumInPipes++; } else if (usb_endpoint_is_bulk_out(pendp_desc)) { DBG_8723A("usb_endpoint_is_bulk_out = %x/n", usb_endpoint_num(pendp_desc)); pdvobjpriv->RtOutPipe[pdvobjpriv->RtNumOutPipes] = usb_endpoint_num(pendp_desc); pdvobjpriv->RtNumOutPipes++; } pdvobjpriv->ep_num[i] = usb_endpoint_num(pendp_desc); } DBG_8723A("nr_endpoint =%d, in_num =%d, out_num =%d/n/n", pdvobjpriv->nr_endpoint, pdvobjpriv->RtNumInPipes, pdvobjpriv->RtNumOutPipes); if (pusbd->speed == USB_SPEED_HIGH) { pdvobjpriv->ishighspeed = true; DBG_8723A("USB_SPEED_HIGH/n"); } else { pdvobjpriv->ishighspeed = false; DBG_8723A("NON USB_SPEED_HIGH/n"); } if (rtw_init_intf_priv(pdvobjpriv) == _FAIL) { RT_TRACE(_module_os_intfs_c_, _drv_err_, ("/n Can't INIT rtw_init_intf_priv/n")); goto free_dvobj; } /* 3 misc */ rtw_reset_continual_urb_error(pdvobjpriv); usb_get_dev(pusbd); status = _SUCCESS;free_dvobj: if (status != _SUCCESS && pdvobjpriv) { usb_set_intfdata(usb_intf, NULL); mutex_destroy(&pdvobjpriv->hw_init_mutex); mutex_destroy(&pdvobjpriv->h2c_fwcmd_mutex); mutex_destroy(&pdvobjpriv->setch_mutex); mutex_destroy(&pdvobjpriv->setbw_mutex);//.........这里部分代码省略.........
开发者ID:Abioy,项目名称:kasan,代码行数:101,
示例8: diag_bridge_probestatic intdiag_bridge_probe(struct usb_interface *ifc, const struct usb_device_id *id){ struct diag_bridge *dev; struct usb_host_interface *ifc_desc; struct usb_endpoint_descriptor *ep_desc; int i; int ret = -ENOMEM; __u8 ifc_num; pr_debug("id:%lu", id->driver_info); ifc_num = ifc->cur_altsetting->desc.bInterfaceNumber; /* is this interface supported ? */ if (ifc_num != id->driver_info) return -ENODEV; dev = kzalloc(sizeof(*dev), GFP_KERNEL); if (!dev) { pr_err("unable to allocate dev"); return -ENOMEM; } dev->pdev = platform_device_alloc("diag_bridge", -1); if (!dev->pdev) { pr_err("unable to allocate platform device"); kfree(dev); return -ENOMEM; } __dev = dev; dev->udev = usb_get_dev(interface_to_usbdev(ifc)); dev->ifc = ifc; kref_init(&dev->kref); init_usb_anchor(&dev->submitted); ifc_desc = ifc->cur_altsetting; for (i = 0; i < ifc_desc->desc.bNumEndpoints; i++) { ep_desc = &ifc_desc->endpoint[i].desc;#ifdef LG_FW_HSIC_EMS_DEBUG /* secheol.pyo - endpoint logging */ printk("[%s]for ++, i= %d, ifc_desc->desc.bNumEndpoints = %d/n", __func__,i, ifc_desc->desc.bNumEndpoints);#endif /* secheol.pyo - endpoint logging */ if (!dev->in_epAddr && usb_endpoint_is_bulk_in(ep_desc)) dev->in_epAddr = ep_desc->bEndpointAddress; if (!dev->out_epAddr && usb_endpoint_is_bulk_out(ep_desc)) dev->out_epAddr = ep_desc->bEndpointAddress;#ifdef LG_FW_HSIC_EMS_DEBUG /* secheol.pyo - endpoint logging */ printk("[%s]for --, i= %d, dev->in_epAddr = %d, dev->out_epAddr = %d /n", __func__,i, dev->in_epAddr, dev->out_epAddr);#endif/* secheol.pyo - endpoint logging */ } if (!(dev->in_epAddr && dev->out_epAddr)) { pr_err("could not find bulk in and bulk out endpoints"); ret = -ENODEV; goto error; } usb_set_intfdata(ifc, dev); diag_bridge_debugfs_init(); platform_device_add(dev->pdev); dev_dbg(&dev->ifc->dev, "%s: complete/n", __func__); return 0;error: if (dev) kref_put(&dev->kref, diag_bridge_delete); return ret;}
开发者ID:regit66,项目名称:android_kernel_lge_geehrc,代码行数:73,
示例9: zfLnxAllocAllUrbsint zfLnxAllocAllUrbs(struct usbdrv_private *macp){ struct usb_interface *interface = macp->interface; struct usb_host_interface *iface_desc = &interface->altsetting[0]; struct usb_endpoint_descriptor *endpoint; int i; /* descriptor matches, let's find the endpoints needed */ /* check out the endpoints */ for (i = 0; i < iface_desc->desc.bNumEndpoints; ++i) { endpoint = &iface_desc->endpoint[i].desc; if (usb_endpoint_is_bulk_in(endpoint)) { /* we found a bulk in endpoint */ printk(KERN_ERR "bulk in: wMaxPacketSize = %x/n", le16_to_cpu(endpoint->wMaxPacketSize)); } if (usb_endpoint_is_bulk_out(endpoint)) { /* we found a bulk out endpoint */ printk(KERN_ERR "bulk out: wMaxPacketSize = %x/n", le16_to_cpu(endpoint->wMaxPacketSize)); } if (usb_endpoint_is_int_in(endpoint)) { /* we found a interrupt in endpoint */ printk(KERN_ERR "interrupt in: wMaxPacketSize = %x/n", le16_to_cpu(endpoint->wMaxPacketSize)); printk(KERN_ERR "interrupt in: int_interval = %d/n", endpoint->bInterval); } if (usb_endpoint_is_int_out(endpoint)) { /* we found a interrupt out endpoint */ printk(KERN_ERR "interrupt out: wMaxPacketSize = %x/n", le16_to_cpu(endpoint->wMaxPacketSize)); printk(KERN_ERR "interrupt out: int_interval = %d/n", endpoint->bInterval); } } /* Allocate all Tx URBs */ for (i = 0; i < ZM_MAX_TX_URB_NUM; i++) { macp->WlanTxDataUrb[i] = USB_ALLOC_URB(0, GFP_KERNEL); if (macp->WlanTxDataUrb[i] == 0) { int j; /* Free all urbs */ for (j = 0; j < i; j++) { usb_free_urb(macp->WlanTxDataUrb[j]); } return 0; } } /* Allocate all Rx URBs */ for (i = 0; i < ZM_MAX_RX_URB_NUM; i++) { macp->WlanRxDataUrb[i] = USB_ALLOC_URB(0, GFP_KERNEL); if (macp->WlanRxDataUrb[i] == 0) { int j; /* Free all urbs */ for (j = 0; j < i; j++) { usb_free_urb(macp->WlanRxDataUrb[j]); } for (j = 0; j < ZM_MAX_TX_URB_NUM; j++) { usb_free_urb(macp->WlanTxDataUrb[j]); } return 0; } } /* Allocate Register Read/Write USB */ macp->RegOutUrb = USB_ALLOC_URB(0, GFP_KERNEL); macp->RegInUrb = USB_ALLOC_URB(0, GFP_KERNEL); return 1;}
开发者ID:mecke,项目名称:linux-2.6,代码行数:89,
示例10: ipheth_probestatic int ipheth_probe (struct usb_interface *intf, const struct usb_device_id *id){ struct usb_device *udev = interface_to_usbdev(intf); struct usb_host_interface *hintf; struct usb_endpoint_descriptor *endp; struct ipheth_device *dev; struct net_device *netdev; int i; int retval; /* Ensure we are probing the right interface */ if (intf->cur_altsetting->desc.bInterfaceClass != IPHETH_USBINTF_CLASS || intf->cur_altsetting->desc.bInterfaceSubClass != IPHETH_USBINTF_SUBCLASS) return -ENODEV; netdev = alloc_etherdev(sizeof(struct ipheth_device)); if (!netdev) return -ENOMEM;#ifdef HAVE_NET_DEVICE_OPS netdev->netdev_ops = &ipheth_netdev_ops;#else /* CONFIG_COMPAT_NET_DEV_OPS */ netdev->open = &ipheth_open; netdev->stop = &ipheth_close; netdev->hard_start_xmit = &ipheth_tx; netdev->tx_timeout = &ipheth_tx_timeout; netdev->get_stats = &ipheth_stats;#endif netdev->watchdog_timeo = IPHETH_TX_TIMEOUT; dev = netdev_priv(netdev); dev->udev = udev; dev->net = netdev; dev->intf = intf; /* Set up endpoints */ hintf = usb_altnum_to_altsetting (intf, IPHETH_ALT_INTFNUM); if (hintf == NULL) { retval = -ENODEV; err("Unable to find alternate settings interface"); goto err_endpoints; } for (i = 0; i < hintf->desc.bNumEndpoints; i++) { endp = &hintf->endpoint[i].desc; if (usb_endpoint_is_bulk_in(endp)) dev->bulk_in = endp->bEndpointAddress; else if (usb_endpoint_is_bulk_out(endp)) dev->bulk_out = endp->bEndpointAddress; } if (!(dev->bulk_in && dev->bulk_out)) { retval = -ENODEV; err("Unable to find endpoints"); goto err_endpoints; } dev->ctrl_buf = kmalloc(IPHETH_CTRL_BUF_SIZE, GFP_KERNEL); if (dev->ctrl_buf == NULL) { retval = -ENOMEM; goto err_alloc_ctrl_buf; } if ((retval = ipheth_get_macaddr(dev))) goto err_get_macaddr; INIT_DELAYED_WORK(&dev->carrier_work, ipheth_carrier_check_work); if ((retval = ipheth_alloc_urbs(dev))) { err("error allocating urbs: %d", retval); goto err_alloc_urbs; } usb_set_intfdata(intf, dev); SET_NETDEV_DEV(netdev, &intf->dev); SET_ETHTOOL_OPS(netdev, &ops); if ((retval = register_netdev(netdev))) { err("error registering netdev: %d", retval); retval = -EIO; goto err_register_netdev; } dev_info(&intf->dev, "Apple iPhone USB Ethernet device attached/n"); return 0;err_register_netdev: ipheth_free_urbs(dev);err_alloc_urbs:err_get_macaddr:err_alloc_ctrl_buf: kfree(dev->ctrl_buf);err_endpoints: free_netdev(netdev); return retval;}
开发者ID:aircross,项目名称:ray,代码行数:97,
示例11: if_usb_probe/** * if_usb_probe - sets the configuration values * * @ifnum interface number * @id pointer to usb_device_id * * Returns: 0 on success, error code on failure */static int if_usb_probe(struct usb_interface *intf, const struct usb_device_id *id){ struct usb_device *udev; struct usb_host_interface *iface_desc; struct usb_endpoint_descriptor *endpoint; struct lbtf_private *priv; struct if_usb_card *cardp; int i; lbtf_deb_enter(LBTF_DEB_USB); udev = interface_to_usbdev(intf); cardp = kzalloc(sizeof(struct if_usb_card), GFP_KERNEL); if (!cardp) goto error; setup_timer(&cardp->fw_timeout, if_usb_fw_timeo, (unsigned long)cardp); init_waitqueue_head(&cardp->fw_wq); cardp->udev = udev; iface_desc = intf->cur_altsetting; lbtf_deb_usbd(&udev->dev, "bcdUSB = 0x%X bDeviceClass = 0x%X" " bDeviceSubClass = 0x%X, bDeviceProtocol = 0x%X/n", le16_to_cpu(udev->descriptor.bcdUSB), udev->descriptor.bDeviceClass, udev->descriptor.bDeviceSubClass, udev->descriptor.bDeviceProtocol); for (i = 0; i < iface_desc->desc.bNumEndpoints; ++i) { endpoint = &iface_desc->endpoint[i].desc; if (usb_endpoint_is_bulk_in(endpoint)) { cardp->ep_in_size = le16_to_cpu(endpoint->wMaxPacketSize); cardp->ep_in = usb_endpoint_num(endpoint); lbtf_deb_usbd(&udev->dev, "in_endpoint = %d/n", cardp->ep_in); lbtf_deb_usbd(&udev->dev, "Bulk in size is %d/n", cardp->ep_in_size); } else if (usb_endpoint_is_bulk_out(endpoint)) { cardp->ep_out_size = le16_to_cpu(endpoint->wMaxPacketSize); cardp->ep_out = usb_endpoint_num(endpoint); lbtf_deb_usbd(&udev->dev, "out_endpoint = %d/n", cardp->ep_out); lbtf_deb_usbd(&udev->dev, "Bulk out size is %d/n", cardp->ep_out_size); } } if (!cardp->ep_out_size || !cardp->ep_in_size) { lbtf_deb_usbd(&udev->dev, "Endpoints not found/n"); /* Endpoints not found */ goto dealloc; } cardp->rx_urb = usb_alloc_urb(0, GFP_KERNEL); if (!cardp->rx_urb) { lbtf_deb_usbd(&udev->dev, "Rx URB allocation failed/n"); goto dealloc; } cardp->tx_urb = usb_alloc_urb(0, GFP_KERNEL); if (!cardp->tx_urb) { lbtf_deb_usbd(&udev->dev, "Tx URB allocation failed/n"); goto dealloc; } cardp->cmd_urb = usb_alloc_urb(0, GFP_KERNEL); if (!cardp->cmd_urb) { lbtf_deb_usbd(&udev->dev, "Cmd URB allocation failed/n"); goto dealloc; } cardp->ep_out_buf = kmalloc(MRVDRV_ETH_TX_PACKET_BUFFER_SIZE, GFP_KERNEL); if (!cardp->ep_out_buf) { lbtf_deb_usbd(&udev->dev, "Could not allocate buffer/n"); goto dealloc; } priv = lbtf_add_card(cardp, &udev->dev); if (!priv) goto dealloc; cardp->priv = priv; priv->hw_host_to_card = if_usb_host_to_card; priv->hw_prog_firmware = if_usb_prog_firmware; priv->hw_reset_device = if_usb_reset_device;//.........这里部分代码省略.........
开发者ID:nocl,项目名称:linux-libre,代码行数:101,
示例12: skel_probestatic int skel_probe(struct usb_interface *interface, const struct usb_device_id *id){ struct usb_skel *dev; struct usb_host_interface *iface_desc; struct usb_endpoint_descriptor *endpoint; int buffer_size; int i; int retval = -ENOMEM; /* allocate memory for our device state and initialize it */ dev = kzalloc(sizeof(*dev), GFP_KERNEL); if (!dev) { dev_err(&interface->dev, "Out of memory/n"); goto error; } kref_init(&dev->kref); sema_init(&dev->limit_sem, WRITES_IN_FLIGHT); mutex_init(&dev->io_mutex); spin_lock_init(&dev->err_lock); init_usb_anchor(&dev->submitted); init_waitqueue_head(&dev->bulk_in_wait); dev->udev = usb_get_dev(interface_to_usbdev(interface)); dev->interface = interface; /* set up the endpoint information */ /* use only the first bulk-in and bulk-out endpoints */ iface_desc = interface->cur_altsetting; for (i = 0; i < iface_desc->desc.bNumEndpoints; ++i) { endpoint = &iface_desc->endpoint[i].desc; if (!dev->bulk_in_endpointAddr && usb_endpoint_is_bulk_in(endpoint)) { /* we found a bulk in endpoint */ buffer_size = usb_endpoint_maxp(endpoint); dev->bulk_in_size = buffer_size; dev->bulk_in_endpointAddr = endpoint->bEndpointAddress; dev->bulk_in_buffer = kmalloc(buffer_size, GFP_KERNEL); if (!dev->bulk_in_buffer) { dev_err(&interface->dev, "Could not allocate bulk_in_buffer/n"); goto error; } dev->bulk_in_urb = usb_alloc_urb(0, GFP_KERNEL); if (!dev->bulk_in_urb) { dev_err(&interface->dev, "Could not allocate bulk_in_urb/n"); goto error; } } if (!dev->bulk_out_endpointAddr && usb_endpoint_is_bulk_out(endpoint)) { /* we found a bulk out endpoint */ dev->bulk_out_endpointAddr = endpoint->bEndpointAddress; } } if (!(dev->bulk_in_endpointAddr && dev->bulk_out_endpointAddr)) { dev_err(&interface->dev, "Could not find both bulk-in and bulk-out endpoints/n"); goto error; } /* save our data pointer in this interface device */ usb_set_intfdata(interface, dev); /* we can register the device now, as it is ready */ retval = usb_register_dev(interface, &skel_class); if (retval) { /* something prevented us from registering this driver */ dev_err(&interface->dev, "Not able to get a minor for this device./n"); usb_set_intfdata(interface, NULL); goto error; } /* let the user know what node this device is now attached to */ dev_info(&interface->dev, "USB Skeleton device now attached to USBSkel-%d", interface->minor); return 0;error: if (dev) /* this frees allocated memory */ kref_put(&dev->kref, skel_delete); return retval;}
开发者ID:MercyMM,项目名称:os,代码行数:89,
示例13: usbtmc_probestatic int usbtmc_probe(struct usb_interface *intf, const struct usb_device_id *id){ struct usbtmc_device_data *data; struct usb_host_interface *iface_desc; struct usb_endpoint_descriptor *endpoint; int n; int retcode; dev_dbg(&intf->dev, "%s called/n", __func__); data = kmalloc(sizeof(*data), GFP_KERNEL); if (!data) return -ENOMEM; data->intf = intf; data->id = id; data->usb_dev = usb_get_dev(interface_to_usbdev(intf)); usb_set_intfdata(intf, data); kref_init(&data->kref); mutex_init(&data->io_mutex); init_waitqueue_head(&data->waitq); atomic_set(&data->iin_data_valid, 0); atomic_set(&data->srq_asserted, 0); data->zombie = 0; /* Determine if it is a Rigol or not */ data->rigol_quirk = 0; dev_dbg(&intf->dev, "Trying to find if device Vendor 0x%04X Product 0x%04X has the RIGOL quirk/n", le16_to_cpu(data->usb_dev->descriptor.idVendor), le16_to_cpu(data->usb_dev->descriptor.idProduct)); for(n = 0; usbtmc_id_quirk[n].idVendor > 0; n++) { if ((usbtmc_id_quirk[n].idVendor == le16_to_cpu(data->usb_dev->descriptor.idVendor)) && (usbtmc_id_quirk[n].idProduct == le16_to_cpu(data->usb_dev->descriptor.idProduct))) { dev_dbg(&intf->dev, "Setting this device as having the RIGOL quirk/n"); data->rigol_quirk = 1; break; } } /* Initialize USBTMC bTag and other fields */ data->bTag = 1; data->TermCharEnabled = 0; data->TermChar = '/n'; /* 2 <= bTag <= 127 USBTMC-USB488 subclass specification 4.3.1 */ data->iin_bTag = 2; /* USBTMC devices have only one setting, so use that */ iface_desc = data->intf->cur_altsetting; data->ifnum = iface_desc->desc.bInterfaceNumber; /* Find bulk in endpoint */ for (n = 0; n < iface_desc->desc.bNumEndpoints; n++) { endpoint = &iface_desc->endpoint[n].desc; if (usb_endpoint_is_bulk_in(endpoint)) { data->bulk_in = endpoint->bEndpointAddress; dev_dbg(&intf->dev, "Found bulk in endpoint at %u/n", data->bulk_in); break; } } /* Find bulk out endpoint */ for (n = 0; n < iface_desc->desc.bNumEndpoints; n++) { endpoint = &iface_desc->endpoint[n].desc; if (usb_endpoint_is_bulk_out(endpoint)) { data->bulk_out = endpoint->bEndpointAddress; dev_dbg(&intf->dev, "Found Bulk out endpoint at %u/n", data->bulk_out); break; } } /* Find int endpoint */ for (n = 0; n < iface_desc->desc.bNumEndpoints; n++) { endpoint = &iface_desc->endpoint[n].desc; if (usb_endpoint_is_int_in(endpoint)) { data->iin_ep_present = 1; data->iin_ep = endpoint->bEndpointAddress; data->iin_wMaxPacketSize = usb_endpoint_maxp(endpoint); data->iin_interval = endpoint->bInterval; dev_dbg(&intf->dev, "Found Int in endpoint at %u/n", data->iin_ep); break; } } retcode = get_capabilities(data); if (retcode) dev_err(&intf->dev, "can't read capabilities/n"); else retcode = sysfs_create_group(&intf->dev.kobj, &capability_attr_grp); if (data->iin_ep_present) { /* allocate int urb */ data->iin_urb = usb_alloc_urb(0, GFP_KERNEL); if (!data->iin_urb)//.........这里部分代码省略.........
开发者ID:acton393,项目名称:linux,代码行数:101,
示例14: bridge_probestatic int __devinitbridge_probe(struct usb_interface *iface, const struct usb_device_id *id){ struct usb_host_endpoint *endpoint = NULL; struct usb_host_endpoint *bulk_in = NULL; struct usb_host_endpoint *bulk_out = NULL; struct usb_host_endpoint *int_in = NULL; struct usb_device *udev; int i; int status = 0; int numends; int ch_id; char **bname = (char **)id->driver_info; if (iface->num_altsetting != 1) { err("%s invalid num_altsetting %u/n", __func__, iface->num_altsetting); return -EINVAL; } udev = interface_to_usbdev(iface); usb_get_dev(udev); numends = iface->cur_altsetting->desc.bNumEndpoints; for (i = 0; i < numends; i++) { endpoint = iface->cur_altsetting->endpoint + i; if (!endpoint) { dev_err(&iface->dev, "%s: invalid endpoint %u/n", __func__, i); status = -EINVAL; goto out; } if (usb_endpoint_is_bulk_in(&endpoint->desc)) bulk_in = endpoint; else if (usb_endpoint_is_bulk_out(&endpoint->desc)) bulk_out = endpoint; else if (usb_endpoint_is_int_in(&endpoint->desc)) int_in = endpoint; } if (!bulk_in || !bulk_out || !int_in) { dev_err(&iface->dev, "%s: invalid endpoints/n", __func__); status = -EINVAL; goto out; } ch_id = get_bridge_dev_idx(); if (ch_id < 0) { err("%s all bridge channels claimed. Probe failed/n", __func__); return -ENODEV; } status = data_bridge_probe(iface, bulk_in, bulk_out, bname[BRIDGE_DATA_IDX], ch_id); if (status < 0) { dev_err(&iface->dev, "data_bridge_probe failed %d/n", status); goto out; } status = ctrl_bridge_probe(iface, int_in, bname[BRIDGE_CTRL_IDX], ch_id); if (status < 0) { dev_err(&iface->dev, "ctrl_bridge_probe failed %d/n", status); goto error; }// ASUS_BSP+++ Wenli "tty device for AT command"#ifndef DISABLE_ASUS_DUN pr_info("%s: bridge probe success/n", __func__); if (ch_id == DUN_DATA_ID) { is_open_asus = false; is_open_usb = false; gdun_tty = NULL; ctrl_bridge_init_asus(); s_is_bridge_init = true; pr_info("%s: gdun connect/n", __func__); }#endif// ASUS_BSP--- Wenli "tty device for AT command" return 0;error: platform_device_unregister(__dev[ch_id]->pdev); free_rx_urbs(__dev[ch_id]); usb_set_intfdata(iface, NULL);out: usb_put_dev(udev); return status;}
开发者ID:msva,项目名称:android_kernel_asus_A80,代码行数:91,
示例15: lcd_probestatic int lcd_probe(struct usb_interface *interface, const struct usb_device_id *id){ struct usb_lcd *dev = NULL; struct usb_host_interface *iface_desc; struct usb_endpoint_descriptor *endpoint; size_t buffer_size; int i; int retval = -ENOMEM; /* allocate memory for our device state and initialize it */ dev = kzalloc(sizeof(*dev), GFP_KERNEL); if (dev == NULL) { err("Out of memory"); goto error; } kref_init(&dev->kref); dev->udev = usb_get_dev(interface_to_usbdev(interface)); dev->interface = interface; if (le16_to_cpu(dev->udev->descriptor.idProduct) != 0x0001) { warn(KERN_INFO "USBLCD model not supported."); return -ENODEV; } /* set up the endpoint information */ /* use only the first bulk-in and bulk-out endpoints */ iface_desc = interface->cur_altsetting; for (i = 0; i < iface_desc->desc.bNumEndpoints; ++i) { endpoint = &iface_desc->endpoint[i].desc; if (!dev->bulk_in_endpointAddr && usb_endpoint_is_bulk_in(endpoint)) { /* we found a bulk in endpoint */ buffer_size = le16_to_cpu(endpoint->wMaxPacketSize); dev->bulk_in_size = buffer_size; dev->bulk_in_endpointAddr = endpoint->bEndpointAddress; dev->bulk_in_buffer = kmalloc(buffer_size, GFP_KERNEL); if (!dev->bulk_in_buffer) { err("Could not allocate bulk_in_buffer"); goto error; } } if (!dev->bulk_out_endpointAddr && usb_endpoint_is_bulk_out(endpoint)) { /* we found a bulk out endpoint */ dev->bulk_out_endpointAddr = endpoint->bEndpointAddress; } } if (!(dev->bulk_in_endpointAddr && dev->bulk_out_endpointAddr)) { err("Could not find both bulk-in and bulk-out endpoints"); goto error; } /* save our data pointer in this interface device */ usb_set_intfdata(interface, dev); /* we can register the device now, as it is ready */ retval = usb_register_dev(interface, &lcd_class); if (retval) { /* something prevented us from registering this driver */ err("Not able to get a minor for this device."); usb_set_intfdata(interface, NULL); goto error; } i = le16_to_cpu(dev->udev->descriptor.bcdDevice); info("USBLCD Version %1d%1d.%1d%1d found at address %d", (i & 0xF000)>>12,(i & 0xF00)>>8,(i & 0xF0)>>4,(i & 0xF), dev->udev->devnum); /* let the user know what node this device is now attached to */ info("USB LCD device now attached to USBLCD-%d", interface->minor); return 0;error: if (dev) kref_put(&dev->kref, lcd_delete); return retval;}
开发者ID:StephenMacras,项目名称:dsl-n55u-bender,代码行数:82,
示例16: usblp_select_alts/* * We are a "new" style driver with usb_device_id table, * but our requirements are too intricate for simple match to handle. * * The "proto_bias" option may be used to specify the preferred protocol * for all USB printers (1=7/1/1, 2=7/1/2, 3=7/1/3). If the device * supports the preferred protocol, then we bind to it. * * The best interface for us is 7/1/2, because it is compatible * with a stream of characters. If we find it, we bind to it. * * Note that the people from hpoj.sourceforge.net need to be able to * bind to 7/1/3 (MLC/1284.4), so we provide them ioctls for this purpose. * * Failing 7/1/2, we look for 7/1/3, even though it's probably not * stream-compatible, because this matches the behaviour of the old code. * * If nothing else, we bind to 7/1/1 - the unidirectional interface. */static int usblp_select_alts(struct usblp *usblp){ struct usb_interface *if_alt; struct usb_host_interface *ifd; struct usb_endpoint_descriptor *epd, *epwrite, *epread; int p, i, e; if_alt = usblp->intf; for (p = 0; p < USBLP_MAX_PROTOCOLS; p++) usblp->protocol[p].alt_setting = -1; /* Find out what we have. */ for (i = 0; i < if_alt->num_altsetting; i++) { ifd = &if_alt->altsetting[i]; if (ifd->desc.bInterfaceClass != 7 || ifd->desc.bInterfaceSubClass != 1) if (!(usblp->quirks & USBLP_QUIRK_BAD_CLASS)) continue; if (ifd->desc.bInterfaceProtocol < USBLP_FIRST_PROTOCOL || ifd->desc.bInterfaceProtocol > USBLP_LAST_PROTOCOL) continue; /* Look for bulk OUT and IN endpoints. */ epwrite = epread = NULL; for (e = 0; e < ifd->desc.bNumEndpoints; e++) { epd = &ifd->endpoint[e].desc; if (usb_endpoint_is_bulk_out(epd)) if (!epwrite) epwrite = epd; if (usb_endpoint_is_bulk_in(epd)) if (!epread) epread = epd; } /* Ignore buggy hardware without the right endpoints. */ if (!epwrite || (ifd->desc.bInterfaceProtocol > 1 && !epread)) continue; /* Turn off reads for 7/1/1 (unidirectional) interfaces * and buggy bidirectional printers. */ if (ifd->desc.bInterfaceProtocol == 1) { epread = NULL; } else if (usblp->quirks & USBLP_QUIRK_BIDIR) { printk(KERN_INFO "usblp%d: Disabling reads from " "problematic bidirectional printer/n", usblp->minor); epread = NULL; } usblp->protocol[ifd->desc.bInterfaceProtocol].alt_setting = ifd->desc.bAlternateSetting; usblp->protocol[ifd->desc.bInterfaceProtocol].epwrite = epwrite; usblp->protocol[ifd->desc.bInterfaceProtocol].epread = epread; } /* If our requested protocol is supported, then use it. */ if (proto_bias >= USBLP_FIRST_PROTOCOL && proto_bias <= USBLP_LAST_PROTOCOL && usblp->protocol[proto_bias].alt_setting != -1) return proto_bias; /* Ordering is important here. */ if (usblp->protocol[2].alt_setting != -1) return 2; if (usblp->protocol[1].alt_setting != -1) return 1; if (usblp->protocol[3].alt_setting != -1) return 3; /* If nothing is available, then don't bind to this device. */ return -1;}
开发者ID:3sOx,项目名称:asuswrt-merlin,代码行数:95,
示例17: kzallocstatic struct dvobj_priv *usb_dvobj_init(struct usb_interface *usb_intf){ int i; struct dvobj_priv *pdvobjpriv; struct usb_host_config *phost_conf; struct usb_config_descriptor *pconf_desc; struct usb_host_interface *phost_iface; struct usb_interface_descriptor *piface_desc; struct usb_endpoint_descriptor *pendp_desc; struct usb_device *pusbd; pdvobjpriv = kzalloc(sizeof(*pdvobjpriv), GFP_KERNEL); if (!pdvobjpriv) return NULL; pdvobjpriv->pusbintf = usb_intf; pusbd = interface_to_usbdev(usb_intf); pdvobjpriv->pusbdev = pusbd; usb_set_intfdata(usb_intf, pdvobjpriv); pdvobjpriv->RtNumInPipes = 0; pdvobjpriv->RtNumOutPipes = 0; phost_conf = pusbd->actconfig; pconf_desc = &phost_conf->desc; phost_iface = &usb_intf->altsetting[0]; piface_desc = &phost_iface->desc; pdvobjpriv->NumInterfaces = pconf_desc->bNumInterfaces; pdvobjpriv->InterfaceNumber = piface_desc->bInterfaceNumber; for (i = 0; i < piface_desc->bNumEndpoints; i++) { int ep_num; pendp_desc = &phost_iface->endpoint[i].desc; ep_num = usb_endpoint_num(pendp_desc); if (usb_endpoint_is_bulk_in(pendp_desc)) { pdvobjpriv->RtInPipe[pdvobjpriv->RtNumInPipes] = ep_num; pdvobjpriv->RtNumInPipes++; } else if (usb_endpoint_is_int_in(pendp_desc)) { pdvobjpriv->RtInPipe[pdvobjpriv->RtNumInPipes] = ep_num; pdvobjpriv->RtNumInPipes++; } else if (usb_endpoint_is_bulk_out(pendp_desc)) { pdvobjpriv->RtOutPipe[pdvobjpriv->RtNumOutPipes] = ep_num; pdvobjpriv->RtNumOutPipes++; } } if (pusbd->speed == USB_SPEED_HIGH) pdvobjpriv->ishighspeed = true; else pdvobjpriv->ishighspeed = false; mutex_init(&pdvobjpriv->usb_vendor_req_mutex); usb_get_dev(pusbd); return pdvobjpriv;}
开发者ID:AlexShiLucky,项目名称:linux,代码行数:62,
示例18: qcprobestatic int qcprobe(struct usb_serial *serial, const struct usb_device_id *id){ struct usb_wwan_intf_private *data; struct usb_host_interface *intf = serial->interface->cur_altsetting; int retval = -ENODEV; __u8 nintf; __u8 ifnum; bool is_gobi1k = id->driver_info ? true : false; dbg("%s", __func__); dbg("Is Gobi 1000 = %d", is_gobi1k); nintf = serial->dev->actconfig->desc.bNumInterfaces; dbg("Num Interfaces = %d", nintf); ifnum = intf->desc.bInterfaceNumber; dbg("This Interface = %d", ifnum); data = kzalloc(sizeof(struct usb_wwan_intf_private), GFP_KERNEL); if (!data) return -ENOMEM; spin_lock_init(&data->susp_lock); if (!(board_mfg_mode() == 8 || board_mfg_mode() == 6 || board_mfg_mode() == 2)) usb_enable_autosuspend(serial->dev); switch (nintf) { case 1: if (serial->interface->num_altsetting == 2) intf = &serial->interface->altsetting[1]; else if (serial->interface->num_altsetting > 2) break; if (intf->desc.bNumEndpoints == 2 && usb_endpoint_is_bulk_in(&intf->endpoint[0].desc) && usb_endpoint_is_bulk_out(&intf->endpoint[1].desc)) { dbg("QDL port found"); if (serial->interface->num_altsetting == 1) { retval = 0; break; } retval = usb_set_interface(serial->dev, ifnum, 1); if (retval < 0) { dev_err(&serial->dev->dev, "Could not set interface, error %d/n", retval); retval = -ENODEV; kfree(data); } } break; case 3: case 4: if (ifnum == 1 && !is_gobi1k) { dbg("Gobi 2K+ DM/DIAG interface found"); retval = usb_set_interface(serial->dev, ifnum, 0); if (retval < 0) { dev_err(&serial->dev->dev, "Could not set interface, error %d/n", retval); retval = -ENODEV; kfree(data); } } else if (ifnum == 2) { dbg("Modem port found"); retval = usb_set_interface(serial->dev, ifnum, 0); if (retval < 0) { dev_err(&serial->dev->dev, "Could not set interface, error %d/n", retval); retval = -ENODEV; kfree(data); } } else if (ifnum==3 && !is_gobi1k) { dbg("Gobi 2K+ NMEA GPS interface found"); retval = usb_set_interface(serial->dev, ifnum, 0); if (retval < 0) { dev_err(&serial->dev->dev, "Could not set interface, error %d/n", retval); retval = -ENODEV; kfree(data); } } break; case 9: if (get_radio_flag() & 0x20000) usb_diag_enable = true;//.........这里部分代码省略.........
开发者ID:boa19861105,项目名称:Killx-Kernel,代码行数:101,
示例19: diag_bridge_probestatic intdiag_bridge_probe(struct usb_interface *ifc, const struct usb_device_id *id){ struct diag_bridge *dev; struct usb_host_interface *ifc_desc; struct usb_endpoint_descriptor *ep_desc; int i; int ret = -ENOMEM; __u8 ifc_num; dbg("%s: id:%lu", __func__, id->driver_info); ifc_num = ifc->cur_altsetting->desc.bInterfaceNumber; /* is this interface supported ? */ if (ifc_num != id->driver_info) return -ENODEV; dev = kzalloc(sizeof(*dev), GFP_KERNEL); if (!dev) { pr_err("%s: unable to allocate dev/n", __func__); return -ENOMEM; } dev->pdev = platform_device_alloc("diag_bridge", -1); if (!dev->pdev) { pr_err("%s: unable to allocate platform device/n", __func__); kfree(dev); return -ENOMEM; } /* zero_pky.patch */ dev->buf_in = kzalloc(IN_BUF_SIZE, GFP_KERNEL); if (!dev->buf_in) { pr_err("%s: unable to allocate dev->buf_in/n", __func__); return -ENOMEM; } __dev = dev; dev->udev = usb_get_dev(interface_to_usbdev(ifc)); dev->ifc = ifc; kref_init(&dev->kref); init_usb_anchor(&dev->submitted); ifc_desc = ifc->cur_altsetting; for (i = 0; i < ifc_desc->desc.bNumEndpoints; i++) { ep_desc = &ifc_desc->endpoint[i].desc; if (!dev->in_epAddr && usb_endpoint_is_bulk_in(ep_desc)) dev->in_epAddr = ep_desc->bEndpointAddress; if (!dev->out_epAddr && usb_endpoint_is_bulk_out(ep_desc)) dev->out_epAddr = ep_desc->bEndpointAddress; } if (!(dev->in_epAddr && dev->out_epAddr)) { err("could not find bulk in and bulk out endpoints"); ret = -ENODEV; goto error; } usb_set_intfdata(ifc, dev); diag_bridge_debugfs_init(); platform_device_add(dev->pdev); dev_dbg(&dev->udev->dev, "%s: complete/n", __func__); return 0;error: if (dev) kref_put(&dev->kref, diag_bridge_delete); return ret;}
开发者ID:ARMP,项目名称:ARMP-i9300,代码行数:73,
示例20: ksb_usb_probestatic intksb_usb_probe(struct usb_interface *ifc, const struct usb_device_id *id){ __u8 ifc_num; struct usb_host_interface *ifc_desc; struct usb_endpoint_descriptor *ep_desc; int i; struct ks_bridge *ksb; unsigned long flags; struct data_pkt *pkt; ifc_num = ifc->cur_altsetting->desc.bInterfaceNumber; switch (id->idProduct) { case 0x9008: if (ifc_num != 0) return -ENODEV; ksb = __ksb[BOOT_BRIDGE_INDEX]; break; case 0x9048: case 0x904C: case 0x9075: if (ifc_num != 2) return -ENODEV; ksb = __ksb[EFS_BRIDGE_INDEX]; break; default: return -ENODEV; } if (!ksb) { pr_err("ksb is not initialized"); return -ENODEV; } ksb->udev = usb_get_dev(interface_to_usbdev(ifc)); ksb->ifc = ifc; ifc_desc = ifc->cur_altsetting; for (i = 0; i < ifc_desc->desc.bNumEndpoints; i++) { ep_desc = &ifc_desc->endpoint[i].desc; if (!ksb->in_epAddr && usb_endpoint_is_bulk_in(ep_desc)) ksb->in_epAddr = ep_desc->bEndpointAddress; if (!ksb->out_epAddr && usb_endpoint_is_bulk_out(ep_desc)) ksb->out_epAddr = ep_desc->bEndpointAddress; } if (!(ksb->in_epAddr && ksb->out_epAddr)) { pr_err("could not find bulk in and bulk out endpoints"); usb_put_dev(ksb->udev); ksb->ifc = NULL; return -ENODEV; } ksb->in_pipe = usb_rcvbulkpipe(ksb->udev, ksb->in_epAddr); ksb->out_pipe = usb_sndbulkpipe(ksb->udev, ksb->out_epAddr); usb_set_intfdata(ifc, ksb); set_bit(USB_DEV_CONNECTED, &ksb->flags); atomic_set(&ksb->tx_pending_cnt, 0); atomic_set(&ksb->rx_pending_cnt, 0); dbg_log_event(ksb, "PID-ATT", id->idProduct, 0); /*free up stale buffers if any from previous disconnect*/ spin_lock_irqsave(&ksb->lock, flags); while (!list_empty(&ksb->to_ks_list)) { pkt = list_first_entry(&ksb->to_ks_list, struct data_pkt, list); list_del_init(&pkt->list); ksb_free_data_pkt(pkt); } while (!list_empty(&ksb->to_mdm_list)) { pkt = list_first_entry(&ksb->to_mdm_list, struct data_pkt, list); list_del_init(&pkt->list); ksb_free_data_pkt(pkt); } spin_unlock_irqrestore(&ksb->lock, flags); ksb->fs_dev = (struct miscdevice *)id->driver_info; misc_register(ksb->fs_dev); if (device_can_wakeup(&ksb->udev->dev)) { ifc->needs_remote_wakeup = 1; usb_enable_autosuspend(ksb->udev); } atomic_set(&ksb->pmlock_cnt, 0); pr_info("usb dev connected"); return 0;}
开发者ID:QweJay,项目名称:GT-I9505,代码行数:95,
示例21: modem_startupstatic int modem_startup(struct usb_serial *serial){ struct usb_serial_port *port = serial->port[0]; struct modem_port *modem_port_ptr = NULL; struct usb_interface *interface; struct usb_endpoint_descriptor *endpoint; struct usb_endpoint_descriptor *epread = NULL; struct usb_endpoint_descriptor *epwrite = NULL; struct usb_host_interface *iface_desc; unsigned long flags; int readsize; int num_rx_buf; int i; int retval = 0; interface = serial->interface; iface_desc = interface->cur_altsetting; for (i = 0; i < iface_desc->desc.bNumEndpoints; ++i) { endpoint = &iface_desc->endpoint[i].desc; if (usb_endpoint_is_bulk_in(endpoint)) epread = endpoint; if (usb_endpoint_is_bulk_out(endpoint)) epwrite = endpoint; } if (epread == NULL) { dev_err(&serial->dev->dev, "%s: No Bulk In Endpoint for this Interface/n", __func__); return -EPERM; } if (epwrite == NULL) { dev_err(&serial->dev->dev, "%s: No Bulk Out Endpoint for this Interface/n", __func__); return -EPERM; } num_rx_buf = AP_NR; readsize = le16_to_cpu(epread->wMaxPacketSize) * 2; /* setup a buffer to store interface data */ modem_port_ptr = kzalloc(sizeof(struct modem_port), GFP_KERNEL); if (modem_port_ptr == NULL) { dev_err(&serial->dev->dev, "%s: error -- no memory on start up./n", __func__); return -ENOMEM; } /* init tasklet for rx processing */ tasklet_init(&modem_port_ptr->urb_task, modem_rx_tasklet, (unsigned long)modem_port_ptr); modem_port_ptr->rx_buflimit = num_rx_buf; modem_port_ptr->rx_endpoint = usb_rcvbulkpipe(serial->dev, port->bulk_in_endpointAddress); spin_lock_init(&modem_port_ptr->read_lock); spin_lock_init(&modem_port_ptr->write_lock); spin_lock_init(&modem_port_ptr->last_traffic_lock); atomic_set(&modem_port_ptr->wakeup_flag, 0); modem_port_ptr->serial = serial; modem_port_ptr->susp_count = 0; modem_port_ptr->resuming = 0; modem_port_ptr->port = 0; modem_port_ptr->last_traffic = 0; modem_port_ptr->readsize = readsize; modem_port_ptr->writesize = le16_to_cpu(epwrite->wMaxPacketSize) * 20; modem_port_ptr->number = modem_attached_ports++; INIT_WORK(&modem_port_ptr->wake_and_write, modem_wake_and_write); INIT_WORK(&modem_port_ptr->usb_wkup_work, modem_usb_wkup_work); if (modem_write_buffers_alloc(modem_port_ptr, serial) < 0) { dev_err(&serial->dev->dev, "%s: out of memory/n", __func__); goto alloc_write_buf_fail; } /* allocate multiple receive urb pool */ for (i = 0; i < num_rx_buf; i++) { struct ap_ru *rcv = &(modem_port_ptr->ru[i]); rcv->urb = usb_alloc_urb(0, GFP_KERNEL); if (rcv->urb == NULL) { dev_err(&serial->dev->dev, "%s: out of memory/n", __func__); goto alloc_rb_urb_fail; } rcv->urb->transfer_flags |= URB_NO_TRANSFER_DMA_MAP; rcv->instance = modem_port_ptr; } /* allocate multiple receive buffer */ for (i = 0; i < num_rx_buf; i++) { struct ap_rb *rb = &(modem_port_ptr->rb[i]);//.........这里部分代码省略.........
开发者ID:Atrix-Dev-Team,项目名称:kernel-MB860,代码行数:101,
示例22: ipheth_probestatic int ipheth_probe(struct usb_interface *intf, const struct usb_device_id *id){ struct usb_device *udev = interface_to_usbdev(intf); struct usb_host_interface *hintf; struct usb_endpoint_descriptor *endp; struct ipheth_device *dev; struct net_device *netdev; int i; int retval; netdev = alloc_etherdev(sizeof(struct ipheth_device)); if (!netdev) return -ENOMEM; netdev->netdev_ops = &ipheth_netdev_ops; netdev->watchdog_timeo = IPHETH_TX_TIMEOUT; strcpy(netdev->name, "eth%d"); dev = netdev_priv(netdev); dev->udev = udev; dev->net = netdev; dev->intf = intf; dev->confirmed_pairing = false; /* Set up endpoints */ hintf = usb_altnum_to_altsetting(intf, IPHETH_ALT_INTFNUM); if (hintf == NULL) { retval = -ENODEV; dev_err(&intf->dev, "Unable to find alternate settings interface/n"); goto err_endpoints; } for (i = 0; i < hintf->desc.bNumEndpoints; i++) { endp = &hintf->endpoint[i].desc; if (usb_endpoint_is_bulk_in(endp)) dev->bulk_in = endp->bEndpointAddress; else if (usb_endpoint_is_bulk_out(endp)) dev->bulk_out = endp->bEndpointAddress; } if (!(dev->bulk_in && dev->bulk_out)) { retval = -ENODEV; dev_err(&intf->dev, "Unable to find endpoints/n"); goto err_endpoints; } dev->ctrl_buf = kmalloc(IPHETH_CTRL_BUF_SIZE, GFP_KERNEL); if (dev->ctrl_buf == NULL) { retval = -ENOMEM; goto err_alloc_ctrl_buf; } retval = ipheth_get_macaddr(dev); if (retval) goto err_get_macaddr; INIT_DELAYED_WORK(&dev->carrier_work, ipheth_carrier_check_work); retval = ipheth_alloc_urbs(dev); if (retval) { dev_err(&intf->dev, "error allocating urbs: %d/n", retval); goto err_alloc_urbs; } usb_set_intfdata(intf, dev); SET_NETDEV_DEV(netdev, &intf->dev); netdev->ethtool_ops = &ops; retval = register_netdev(netdev); if (retval) { dev_err(&intf->dev, "error registering netdev: %d/n", retval); retval = -EIO; goto err_register_netdev; } // carrier down and transmit queues stopped until packet from device netif_carrier_off(netdev); netif_tx_stop_all_queues(netdev); dev_info(&intf->dev, "Apple iPhone USB Ethernet device attached/n"); return 0;err_register_netdev: ipheth_free_urbs(dev);err_alloc_urbs:err_get_macaddr:err_alloc_ctrl_buf: kfree(dev->ctrl_buf);err_endpoints: free_netdev(netdev); return retval;}
开发者ID:Lyude,项目名称:linux,代码行数:90,
示例23: hsic_sysmon_probestatic inthsic_sysmon_probe(struct usb_interface *ifc, const struct usb_device_id *id){ struct hsic_sysmon *hs; struct usb_host_interface *ifc_desc; struct usb_endpoint_descriptor *ep_desc; int i; int ret = -ENOMEM; __u8 ifc_num; pr_debug("id:%lu", id->driver_info); ifc_num = ifc->cur_altsetting->desc.bInterfaceNumber; /* is this the interface we're looking for? */ if (ifc_num != id->driver_info) return -ENODEV; hs = kzalloc(sizeof(*hs), GFP_KERNEL); if (!hs) { pr_err("unable to allocate hsic_sysmon"); return -ENOMEM; } hs->udev = usb_get_dev(interface_to_usbdev(ifc)); hs->ifc = ifc; kref_init(&hs->kref); ifc_desc = ifc->cur_altsetting; for (i = 0; i < ifc_desc->desc.bNumEndpoints; i++) { ep_desc = &ifc_desc->endpoint[i].desc; if (!hs->in_epaddr && usb_endpoint_is_bulk_in(ep_desc)) { hs->in_epaddr = ep_desc->bEndpointAddress; hs->pipe[HSIC_SYSMON_OP_READ] = usb_rcvbulkpipe(hs->udev, hs->in_epaddr); } if (!hs->out_epaddr && usb_endpoint_is_bulk_out(ep_desc)) { hs->out_epaddr = ep_desc->bEndpointAddress; hs->pipe[HSIC_SYSMON_OP_WRITE] = usb_sndbulkpipe(hs->udev, hs->out_epaddr); } } if (!(hs->in_epaddr && hs->out_epaddr)) { pr_err("could not find bulk in and bulk out endpoints"); ret = -ENODEV; goto error; } hs->id = HSIC_SYSMON_DEV_EXT_MODEM; hsic_sysmon_devices[HSIC_SYSMON_DEV_EXT_MODEM] = hs; usb_set_intfdata(ifc, hs); hs->pdev.name = "sys_mon"; hs->pdev.id = SYSMON_SS_EXT_MODEM; hs->pdev.dev.release = hsic_sysmon_pdev_release;#ifdef CONFIG_LGE_EMS_CH sysmon_hsic_debug_init(hs->udev,hs->ifc,hs->in_epaddr);#endif platform_device_register(&hs->pdev); pr_debug("complete"); return 0;error: if (hs) kref_put(&hs->kref, hsic_sysmon_delete); return ret;}
开发者ID:AttiJeong98,项目名称:Solid_Kernel-Stock,代码行数:73,
示例24: wagusb_probestatic int wagusb_probe(struct usb_interface *interface, const struct usb_device_id *id){ struct usb_device *udev = interface_to_usbdev(interface); struct usb_wagusb *dev = NULL; struct usb_host_interface *iface_desc; struct usb_endpoint_descriptor *endpoint; int result = -ENOMEM, i; dev = kzalloc(sizeof(struct usb_wagusb), GFP_KERNEL); if (NULL == dev) { printk (KERN_ALERT "wagusb: wagusb_probe() - Out of memory/n"); goto error_mem; } mutex_init(&dev->lock); dev->udev = usb_get_dev(udev); /* set up endpoint info */ iface_desc = interface->cur_altsetting; for (i = 0; i < iface_desc->desc.bNumEndpoints; i++) { endpoint = &iface_desc->endpoint[i].desc; if (usb_endpoint_is_bulk_in(endpoint)) { dev->bulk_in_endpointAddr = endpoint->bEndpointAddress; dev->bulk_in_buffer = kzalloc(EPBUFF_SIZE, GFP_KERNEL); if (NULL == dev->bulk_in_buffer) { printk (KERN_ALERT "wagusb: wagusb_probe() - Out of memory/n"); goto error_mem; } } if (usb_endpoint_is_bulk_out(endpoint)) { dev->bulk_out_endpointAddr = endpoint->bEndpointAddress; dev->bulk_out_buffer = kzalloc(EPBUFF_SIZE, GFP_KERNEL); if (NULL == dev->bulk_out_buffer) { printk (KERN_ALERT "wagusb: wagusb_probe() - Out of memory/n"); goto error_mem; } } } if (!dev->bulk_in_endpointAddr && !dev->bulk_out_endpointAddr) { printk (KERN_ALERT "wagusb: wagusb_probe() ERROR: BULK IN and OUT not found/n"); result = -1; goto error_noendpoints; } dev->read_pos = 0; dev->bytes_read = 0; usb_set_intfdata(interface, dev); result = usb_register_dev(interface, &wagusb_class); if (result) { printk (KERN_ALERT "wagusb: wagusb_probe() ERROR: Cant register device/n"); usb_set_intfdata(interface, NULL); goto error_cant_register_dev; } return 0;error_cant_register_dev:error_noendpoints:error_mem: if (dev && dev->bulk_in_buffer) kfree(dev->bulk_in_buffer); if (dev && dev->bulk_out_buffer) kfree(dev->bulk_out_buffer); if (dev) kfree(dev); return result;}
开发者ID:autifkhan,项目名称:disorg,代码行数:73,
示例25: bridge_probestatic int bridge_probe(struct usb_interface *iface, const struct usb_device_id *id){ struct usb_host_endpoint *endpoint = NULL; struct usb_host_endpoint *bulk_in = NULL; struct usb_host_endpoint *bulk_out = NULL; struct usb_host_endpoint *int_in = NULL; struct usb_host_endpoint *data_int_in = NULL; struct usb_device *udev; int i; int status = 0; int numends; int ch_id; char **bname = (char **)id->driver_info; if (iface->num_altsetting != 1) { pr_err("%s invalid num_altsetting %u/n", __func__, iface->num_altsetting); return -EINVAL; } udev = interface_to_usbdev(iface); usb_get_dev(udev); numends = iface->cur_altsetting->desc.bNumEndpoints; for (i = 0; i < numends; i++) { endpoint = iface->cur_altsetting->endpoint + i; if (!endpoint) { dev_err(&iface->dev, "%s: invalid endpoint %u/n", __func__, i); status = -EINVAL; goto out; } if (usb_endpoint_is_bulk_in(&endpoint->desc)) bulk_in = endpoint; else if (usb_endpoint_is_bulk_out(&endpoint->desc)) bulk_out = endpoint; else if (usb_endpoint_is_int_in(&endpoint->desc)) { if (int_in != 0) data_int_in = endpoint; else int_in = endpoint; } } if (((numends == 3) && ((!bulk_in && !data_int_in) || !bulk_out || !int_in)) || ((numends == 1) && !bulk_in)) { dev_err(&iface->dev, "%s: invalid endpoints/n", __func__); status = -EINVAL; goto out; } ch_id = get_bridge_dev_idx(); if (ch_id < 0) { pr_err("%s all bridge channels claimed. Probe failed/n", __func__); return -ENODEV; } if (data_int_in) { __dev[ch_id]->use_int_in_pipe = true; __dev[ch_id]->period = data_int_in->desc.bInterval; status = data_bridge_probe(iface, data_int_in, bulk_out, bname[BRIDGE_DATA_IDX], ch_id); } else { status = data_bridge_probe(iface, bulk_in, bulk_out, bname[BRIDGE_DATA_IDX], ch_id); } if (status < 0) { dev_err(&iface->dev, "data_bridge_probe failed %d/n", status); goto out; } status = ctrl_bridge_probe(iface, int_in, bname[BRIDGE_CTRL_IDX], ch_id); if (status < 0) { dev_err(&iface->dev, "ctrl_bridge_probe failed %d/n", status); goto error; } return 0;error: platform_device_unregister(__dev[ch_id]->pdev); free_rx_urbs(__dev[ch_id]); usb_set_intfdata(iface, NULL);out: usb_put_dev(udev); return status;}
开发者ID:AD5GB,项目名称:kernel_n5_3.10-experimental,代码行数:93,
注:本文中的usb_endpoint_is_bulk_out函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 C++ usb_endpoint_is_int_in函数代码示例 C++ usb_endpoint_dir_in函数代码示例 |