这篇教程C++ usb_endpoint_is_int_in函数代码示例写得很实用,希望能帮到您。
本文整理汇总了C++中usb_endpoint_is_int_in函数的典型用法代码示例。如果您正苦于以下问题:C++ usb_endpoint_is_int_in函数的具体用法?C++ usb_endpoint_is_int_in怎么用?C++ usb_endpoint_is_int_in使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。 在下文中一共展示了usb_endpoint_is_int_in函数的22个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。 示例1: usb_mouse_probestatic int usb_mouse_probe(struct usb_interface *intf, const struct usb_device_id *id) //@: vf_usb_operation_probe_t/*@ requires usb_interface(usb_mouse_probe, ?disconnect_cb, intf, _, ?originalData, false, ?fracsize) &*& permission_to_submit_urb(?urbs_submitted, false) &*& not_in_interrupt_context(currentThread) &*& [fracsize]probe_disconnect_userdata(usb_mouse_probe, disconnect_cb)() &*& [?callback_link_f]usb_probe_callback_link(usb_mouse_probe)(disconnect_cb); @*/ /*@ ensures not_in_interrupt_context(currentThread) &*& [callback_link_f]usb_probe_callback_link(usb_mouse_probe)(disconnect_cb) &*& result == 0 ? // success // probe_disconnect_userdata is not returned, so the user "has to put it somewhere", // and give it back with _disconnect. // you can put it in usb_interface: it includes userdata which // can eat whatever probe_disconnect_userdata contains. usb_interface(usb_mouse_probe, disconnect_cb, intf, _, ?data, true, fracsize) //&*& permission_to_submit_urb(_, false) : // failure usb_interface(usb_mouse_probe, disconnect_cb, intf, _, ?data, false, fracsize) // XXX meh, the permission count thing is annoying and I don't think it actually // solves much at all, so made it "_" for now. &*& permission_to_submit_urb(_, false) &*& data == originalData || data == 0 &*& [fracsize]probe_disconnect_userdata(usb_mouse_probe, _)() ; @*/{ struct usb_host_endpoint* ep; //@ open [callback_link_f]usb_probe_callback_link(usb_mouse_probe)(disconnect_cb); //@ close [callback_link_f]usb_probe_callback_link(usb_mouse_probe)(disconnect_cb); struct usb_device *dev = interface_to_usbdev(intf); struct usb_host_interface *interface; struct usb_endpoint_descriptor *endpoint; struct usb_mouse *mouse; struct input_dev *input_dev; int pipe, maxp; int error = -ENOMEM; //@ open usb_interface(usb_mouse_probe, _, _, _, _, _, _); interface = intf->cur_altsetting; //@ open [?f2]usb_host_interface(interface); //@ open [?f3]usb_interface_descriptor(&interface->desc, ?bNumEndpoints, ?bInterfaceNumber); if (interface->desc.bNumEndpoints != 1) { //@ close [f3]usb_interface_descriptor(&interface->desc, bNumEndpoints, bInterfaceNumber); //@ close [f2]usb_host_interface(interface); //@ close usb_interface(usb_mouse_probe, disconnect_cb, intf, _, originalData, false, fracsize); return -ENODEV; } ep = interface->endpoint; endpoint = &(ep->desc); //@ open usb_host_endpoint(interface->endpoint); //int usb_endpoint_is_int_in_res = ; if (! usb_endpoint_is_int_in(endpoint)) { //@ close usb_host_endpoint(interface->endpoint); //@ close [f3]usb_interface_descriptor(&interface->desc, bNumEndpoints, bInterfaceNumber); //@ close [f2]usb_host_interface(interface); //@ close usb_interface(usb_mouse_probe, disconnect_cb, intf, _, originalData, false, fracsize); return -ENODEV; } pipe = usb_rcvintpipe(dev, endpoint->bEndpointAddress); // original: maxp = usb_maxpacket(dev, pipe, usb_pipeout(pipe)); __u16 usb_maxpacket_ret = usb_maxpacket(dev, pipe, usb_pipeout(pipe)); maxp = usb_maxpacket_ret; mouse = kzalloc(sizeof(struct usb_mouse), GFP_KERNEL); input_dev = input_allocate_device(); if (! mouse || ! input_dev) goto fail1; //@ uchars_to_chars(mouse); //@ close_struct(mouse); //@ assert chars((void*) &mouse->name, 128, ?zeros); //@ assume(mem(0, zeros)); // follows because kzalloc is used //@ assert chars((void*) &mouse->phys, 64, ?zeros2); //@ assume(mem(0, zeros2)); // follows because kzalloc is used mouse->usbdev = 0; mouse->dev = 0; mouse->irq = 0; mouse->data = 0; mouse->data_dma = 0; mouse->data = usb_alloc_coherent(dev, 8, GFP_ATOMIC, &mouse->data_dma); //@ signed char* data_tmp = mouse->data; if (! mouse->data) { //@ open_struct(mouse); //@ chars_to_uchars(mouse); goto fail1;//.........这里部分代码省略.........
开发者ID:amintimany,项目名称:verifast,代码行数:101,
示例2: usbnet_generic_cdc_bind//.........这里部分代码省略......... "ACM capabilities %02x, not really RNDIS?/n", header.usb_cdc_acm_descriptor->bmCapabilities); goto bad_desc; } if (header.usb_cdc_ether_desc && info->ether->wMaxSegmentSize) { dev->hard_mtu = le16_to_cpu(info->ether->wMaxSegmentSize); /* because of Zaurus, we may be ignoring the host * side link address we were given. */ } if (header.usb_cdc_mdlm_desc && memcmp(header.usb_cdc_mdlm_desc->bGUID, mbm_guid, 16)) { dev_dbg(&intf->dev, "GUID doesn't match/n"); goto bad_desc; } if (header.usb_cdc_mdlm_detail_desc && header.usb_cdc_mdlm_detail_desc->bLength < (sizeof(struct usb_cdc_mdlm_detail_desc) + 1)) { dev_dbg(&intf->dev, "Descriptor too short/n"); goto bad_desc; } /* Microsoft ActiveSync based and some regular RNDIS devices lack the * CDC descriptors, so we'll hard-wire the interfaces and not check * for descriptors. * * Some Android RNDIS devices have a CDC Union descriptor pointing * to non-existing interfaces. Ignore that and attempt the same * hard-wired 0 and 1 interfaces. */ if (rndis && (!info->u || android_rndis_quirk)) { info->control = usb_ifnum_to_if(dev->udev, 0); info->data = usb_ifnum_to_if(dev->udev, 1); if (!info->control || !info->data || info->control != intf) { dev_dbg(&intf->dev, "rndis: master #0/%p slave #1/%p/n", info->control, info->data); goto bad_desc; } } else if (!info->header || (!rndis && !info->ether)) { dev_dbg(&intf->dev, "missing cdc %s%s%sdescriptor/n", info->header ? "" : "header ", info->u ? "" : "union ", info->ether ? "" : "ether "); goto bad_desc; } /* claim data interface and set it up ... with side effects. * network traffic can't flow until an altsetting is enabled. */ if (info->data != info->control) { status = usb_driver_claim_interface(driver, info->data, dev); if (status < 0) return status; } status = usbnet_get_endpoints(dev, info->data); if (status < 0) { /* ensure immediate exit from usbnet_disconnect */ usb_set_intfdata(info->data, NULL); if (info->data != info->control) usb_driver_release_interface(driver, info->data); return status; } /* status endpoint: optional for CDC Ethernet, not RNDIS (or ACM) */ if (info->data != info->control) dev->status = NULL; if (info->control->cur_altsetting->desc.bNumEndpoints == 1) { struct usb_endpoint_descriptor *desc; dev->status = &info->control->cur_altsetting->endpoint[0]; desc = &dev->status->desc; if (!usb_endpoint_is_int_in(desc) || (le16_to_cpu(desc->wMaxPacketSize) < sizeof(struct usb_cdc_notification)) || !desc->bInterval) { dev_dbg(&intf->dev, "bad notification endpoint/n"); dev->status = NULL; } } if (rndis && !dev->status) { dev_dbg(&intf->dev, "missing RNDIS status endpoint/n"); usb_set_intfdata(info->data, NULL); usb_driver_release_interface(driver, info->data); return -ENODEV; } return 0;bad_desc: dev_info(&dev->udev->dev, "bad CDC descriptors/n"); return -ENODEV;}
开发者ID:avagin,项目名称:linux,代码行数:101,
示例3: si470x_usb_driver_probe/* * si470x_usb_driver_probe - probe for the device */static int si470x_usb_driver_probe(struct usb_interface *intf, const struct usb_device_id *id){ struct si470x_device *radio; struct usb_host_interface *iface_desc; struct usb_endpoint_descriptor *endpoint; int i, int_end_size, retval = 0; unsigned char version_warning = 0; /* private data allocation and initialization */ radio = kzalloc(sizeof(struct si470x_device), GFP_KERNEL); if (!radio) { retval = -ENOMEM; goto err_initial; } radio->usb_buf = kmalloc(MAX_REPORT_SIZE, GFP_KERNEL); if (radio->usb_buf == NULL) { retval = -ENOMEM; goto err_radio; } radio->usbdev = interface_to_usbdev(intf); radio->intf = intf; radio->band = 1; /* Default to 76 - 108 MHz */ mutex_init(&radio->lock); init_completion(&radio->completion); iface_desc = intf->cur_altsetting; /* Set up interrupt endpoint information. */ for (i = 0; i < iface_desc->desc.bNumEndpoints; ++i) { endpoint = &iface_desc->endpoint[i].desc; if (usb_endpoint_is_int_in(endpoint)) radio->int_in_endpoint = endpoint; } if (!radio->int_in_endpoint) { dev_info(&intf->dev, "could not find interrupt in endpoint/n"); retval = -EIO; goto err_usbbuf; } int_end_size = le16_to_cpu(radio->int_in_endpoint->wMaxPacketSize); radio->int_in_buffer = kmalloc(int_end_size, GFP_KERNEL); if (!radio->int_in_buffer) { dev_info(&intf->dev, "could not allocate int_in_buffer"); retval = -ENOMEM; goto err_usbbuf; } radio->int_in_urb = usb_alloc_urb(0, GFP_KERNEL); if (!radio->int_in_urb) { retval = -ENOMEM; goto err_intbuffer; } radio->v4l2_dev.release = si470x_usb_release; /* * The si470x SiLabs reference design uses the same USB IDs as * 'Thanko's Raremono' si4734 based receiver. So check here which we * have: attempt to read the device ID from the si470x: the lower 12 * bits should be 0x0242 for the si470x. * * We use this check to determine which device we are dealing with. */ if (id->idVendor == 0x10c4 && id->idProduct == 0x818a) { retval = usb_control_msg(radio->usbdev, usb_rcvctrlpipe(radio->usbdev, 0), HID_REQ_GET_REPORT, USB_TYPE_CLASS | USB_RECIP_INTERFACE | USB_DIR_IN, 1, 2, radio->usb_buf, 3, 500); if (retval != 3 || (get_unaligned_be16(&radio->usb_buf[1]) & 0xfff) != 0x0242) { dev_info(&intf->dev, "this is not a si470x device./n"); retval = -ENODEV; goto err_urb; } } retval = v4l2_device_register(&intf->dev, &radio->v4l2_dev); if (retval < 0) { dev_err(&intf->dev, "couldn't register v4l2_device/n"); goto err_urb; } v4l2_ctrl_handler_init(&radio->hdl, 2); v4l2_ctrl_new_std(&radio->hdl, &si470x_ctrl_ops, V4L2_CID_AUDIO_MUTE, 0, 1, 1, 1); v4l2_ctrl_new_std(&radio->hdl, &si470x_ctrl_ops, V4L2_CID_AUDIO_VOLUME, 0, 15, 1, 15); if (radio->hdl.error) { retval = radio->hdl.error; dev_err(&intf->dev, "couldn't register control/n"); goto err_dev; } radio->videodev = si470x_viddev_template;//.........这里部分代码省略.........
开发者ID:AshishNamdev,项目名称:linux,代码行数:101,
示例4: 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,
示例5: appledisplay_probestatic int appledisplay_probe(struct usb_interface *iface, const struct usb_device_id *id){ struct backlight_properties props; struct appledisplay *pdata; struct usb_device *udev = interface_to_usbdev(iface); struct usb_host_interface *iface_desc; struct usb_endpoint_descriptor *endpoint; int int_in_endpointAddr = 0; int i, retval = -ENOMEM, brightness; char bl_name[20]; /* set up the endpoint information */ /* use only the first interrupt-in endpoint */ iface_desc = iface->cur_altsetting; for (i = 0; i < iface_desc->desc.bNumEndpoints; i++) { endpoint = &iface_desc->endpoint[i].desc; if (!int_in_endpointAddr && usb_endpoint_is_int_in(endpoint)) { /* we found an interrupt in endpoint */ int_in_endpointAddr = endpoint->bEndpointAddress; break; } } if (!int_in_endpointAddr) { dev_err(&iface->dev, "Could not find int-in endpoint/n"); return -EIO; } /* allocate memory for our device state and initialize it */ pdata = kzalloc(sizeof(struct appledisplay), GFP_KERNEL); if (!pdata) { retval = -ENOMEM; dev_err(&iface->dev, "Out of memory/n"); goto error; } pdata->udev = udev; spin_lock_init(&pdata->lock); INIT_DELAYED_WORK(&pdata->work, appledisplay_work); /* Allocate buffer for control messages */ pdata->msgdata = kmalloc(ACD_MSG_BUFFER_LEN, GFP_KERNEL); if (!pdata->msgdata) { retval = -ENOMEM; dev_err(&iface->dev, "Allocating buffer for control messages failed/n"); goto error; } /* Allocate interrupt URB */ pdata->urb = usb_alloc_urb(0, GFP_KERNEL); if (!pdata->urb) { retval = -ENOMEM; dev_err(&iface->dev, "Allocating URB failed/n"); goto error; } /* Allocate buffer for interrupt data */ pdata->urbdata = usb_buffer_alloc(pdata->udev, ACD_URB_BUFFER_LEN, GFP_KERNEL, &pdata->urb->transfer_dma); if (!pdata->urbdata) { retval = -ENOMEM; dev_err(&iface->dev, "Allocating URB buffer failed/n"); goto error; } /* Configure interrupt URB */ usb_fill_int_urb(pdata->urb, udev, usb_rcvintpipe(udev, int_in_endpointAddr), pdata->urbdata, ACD_URB_BUFFER_LEN, appledisplay_complete, pdata, 1); if (usb_submit_urb(pdata->urb, GFP_KERNEL)) { retval = -EIO; dev_err(&iface->dev, "Submitting URB failed/n"); goto error; } /* Register backlight device */ snprintf(bl_name, sizeof(bl_name), "appledisplay%d", atomic_inc_return(&count_displays) - 1); memset(&props, 0, sizeof(struct backlight_properties)); props.max_brightness = 0xff; pdata->bd = backlight_device_register(bl_name, NULL, pdata, &appledisplay_bl_data, &props); if (IS_ERR(pdata->bd)) { dev_err(&iface->dev, "Backlight registration failed/n"); retval = PTR_ERR(pdata->bd); goto error; } /* Try to get brightness */ brightness = appledisplay_bl_get_brightness(pdata->bd); if (brightness < 0) { retval = brightness; dev_err(&iface->dev, "Error while getting initial brightness: %d/n", retval); goto error; }//.........这里部分代码省略.........
开发者ID:KaZoom,项目名称:buildroot-linux-kernel-m3,代码行数:101,
示例6: kingsun_probe/* * This routine is called by the USB subsystem for each new device * in the system. We need to check if the device is ours, and in * this case start handling it. */static int kingsun_probe(struct usb_interface *intf, const struct usb_device_id *id){ struct usb_host_interface *interface; struct usb_endpoint_descriptor *endpoint; struct usb_device *dev = interface_to_usbdev(intf); struct kingsun_cb *kingsun = NULL; struct net_device *net = NULL; int ret = -ENOMEM; int pipe, maxp_in, maxp_out; __u8 ep_in; __u8 ep_out; /* Check that there really are two interrupt endpoints. Check based on the one in drivers/usb/input/usbmouse.c */ interface = intf->cur_altsetting; if (interface->desc.bNumEndpoints != 2) { err("kingsun-sir: expected 2 endpoints, found %d", interface->desc.bNumEndpoints); return -ENODEV; } endpoint = &interface->endpoint[KINGSUN_EP_IN].desc; if (!usb_endpoint_is_int_in(endpoint)) { err("kingsun-sir: endpoint 0 is not interrupt IN"); return -ENODEV; } ep_in = endpoint->bEndpointAddress; pipe = usb_rcvintpipe(dev, ep_in); maxp_in = usb_maxpacket(dev, pipe, usb_pipeout(pipe)); if (maxp_in > 255 || maxp_in <= 1) { err("%s: endpoint 0 has max packet size %d not in range", __FILE__, maxp_in); return -ENODEV; } endpoint = &interface->endpoint[KINGSUN_EP_OUT].desc; if (!usb_endpoint_is_int_out(endpoint)) { err("kingsun-sir: endpoint 1 is not interrupt OUT"); return -ENODEV; } ep_out = endpoint->bEndpointAddress; pipe = usb_sndintpipe(dev, ep_out); maxp_out = usb_maxpacket(dev, pipe, usb_pipeout(pipe)); /* Allocate network device container. */ net = alloc_irdadev(sizeof(*kingsun)); if(!net) goto err_out1; SET_MODULE_OWNER(net); SET_NETDEV_DEV(net, &intf->dev); kingsun = netdev_priv(net); kingsun->irlap = NULL; kingsun->tx_urb = NULL; kingsun->rx_urb = NULL; kingsun->ep_in = ep_in; kingsun->ep_out = ep_out; kingsun->in_buf = NULL; kingsun->out_buf = NULL; kingsun->max_rx = (__u8)maxp_in; kingsun->max_tx = (__u8)maxp_out; kingsun->netdev = net; kingsun->usbdev = dev; kingsun->rx_buff.in_frame = FALSE; kingsun->rx_buff.state = OUTSIDE_FRAME; kingsun->rx_buff.skb = NULL; kingsun->receiving = 0; spin_lock_init(&kingsun->lock); /* Allocate input buffer */ kingsun->in_buf = (__u8 *)kmalloc(kingsun->max_rx, GFP_KERNEL); if (!kingsun->in_buf) goto free_mem; /* Allocate output buffer */ kingsun->out_buf = (__u8 *)kmalloc(KINGSUN_FIFO_SIZE, GFP_KERNEL); if (!kingsun->out_buf) goto free_mem; printk(KERN_INFO "KingSun/DonShine IRDA/USB found at address %d, " "Vendor: %x, Product: %x/n", dev->devnum, le16_to_cpu(dev->descriptor.idVendor), le16_to_cpu(dev->descriptor.idProduct)); /* Initialize QoS for this device */ irda_init_max_qos_capabilies(&kingsun->qos); /* That's the Rx capability. */ kingsun->qos.baud_rate.bits &= IR_9600; kingsun->qos.min_turn_time.bits &= KINGSUN_MTT; irda_qos_bits_to_value(&kingsun->qos);//.........这里部分代码省略.........
开发者ID:Mr-Aloof,项目名称:wl500g,代码行数:101,
示例7: ld_usb_probe/** * ld_usb_probe * * Called by the usb core when a new device is connected that it thinks * this driver might be interested in. */static int ld_usb_probe(struct usb_interface *intf, const struct usb_device_id *id){ struct usb_device *udev = interface_to_usbdev(intf); struct ld_usb *dev = NULL; struct usb_host_interface *iface_desc; struct usb_endpoint_descriptor *endpoint; char *buffer; int i; int retval = -ENOMEM; /* allocate memory for our device state and initialize it */ dev = kzalloc(sizeof(*dev), GFP_KERNEL); if (dev == NULL) { dev_err(&intf->dev, "Out of memory/n"); goto exit; } mutex_init(&dev->mutex); spin_lock_init(&dev->rbsl); dev->intf = intf; init_waitqueue_head(&dev->read_wait); init_waitqueue_head(&dev->write_wait); /* workaround for early firmware versions on fast computers */ if ((le16_to_cpu(udev->descriptor.idVendor) == USB_VENDOR_ID_LD) && ((le16_to_cpu(udev->descriptor.idProduct) == USB_DEVICE_ID_LD_CASSY) || (le16_to_cpu(udev->descriptor.idProduct) == USB_DEVICE_ID_LD_COM3LAB)) && (le16_to_cpu(udev->descriptor.bcdDevice) <= 0x103)) { buffer = kmalloc(256, GFP_KERNEL); if (buffer == NULL) { dev_err(&intf->dev, "Couldn't allocate string buffer/n"); goto error; } /* usb_string makes SETUP+STALL to leave always ControlReadLoop */ usb_string(udev, 255, buffer, 256); kfree(buffer); } iface_desc = intf->cur_altsetting; /* set up the endpoint information */ for (i = 0; i < iface_desc->desc.bNumEndpoints; ++i) { endpoint = &iface_desc->endpoint[i].desc; if (usb_endpoint_is_int_in(endpoint)) dev->interrupt_in_endpoint = endpoint; if (usb_endpoint_is_int_out(endpoint)) dev->interrupt_out_endpoint = endpoint; } if (dev->interrupt_in_endpoint == NULL) { dev_err(&intf->dev, "Interrupt in endpoint not found/n"); goto error; } if (dev->interrupt_out_endpoint == NULL) dev_warn(&intf->dev, "Interrupt out endpoint not found (using control endpoint instead)/n"); dev->interrupt_in_endpoint_size = usb_endpoint_maxp(dev->interrupt_in_endpoint); dev->ring_buffer = kmalloc(ring_buffer_size*(sizeof(size_t)+dev->interrupt_in_endpoint_size), GFP_KERNEL); if (!dev->ring_buffer) { dev_err(&intf->dev, "Couldn't allocate ring_buffer/n"); goto error; } dev->interrupt_in_buffer = kmalloc(dev->interrupt_in_endpoint_size, GFP_KERNEL); if (!dev->interrupt_in_buffer) { dev_err(&intf->dev, "Couldn't allocate interrupt_in_buffer/n"); goto error; } dev->interrupt_in_urb = usb_alloc_urb(0, GFP_KERNEL); if (!dev->interrupt_in_urb) { dev_err(&intf->dev, "Couldn't allocate interrupt_in_urb/n"); goto error; } dev->interrupt_out_endpoint_size = dev->interrupt_out_endpoint ? usb_endpoint_maxp(dev->interrupt_out_endpoint) : udev->descriptor.bMaxPacketSize0; dev->interrupt_out_buffer = kmalloc(write_buffer_size*dev->interrupt_out_endpoint_size, GFP_KERNEL); if (!dev->interrupt_out_buffer) { dev_err(&intf->dev, "Couldn't allocate interrupt_out_buffer/n"); goto error; } dev->interrupt_out_urb = usb_alloc_urb(0, GFP_KERNEL); if (!dev->interrupt_out_urb) { dev_err(&intf->dev, "Couldn't allocate interrupt_out_urb/n"); goto error; } dev->interrupt_in_interval = min_interrupt_in_interval > dev->interrupt_in_endpoint->bInterval ? min_interrupt_in_interval : dev->interrupt_in_endpoint->bInterval; if (dev->interrupt_out_endpoint) dev->interrupt_out_interval = min_interrupt_out_interval > dev->interrupt_out_endpoint->bInterval ? min_interrupt_out_interval : dev->interrupt_out_endpoint->bInterval; /* we can register the device now, as it is ready */ usb_set_intfdata(intf, dev); retval = usb_register_dev(intf, &ld_usb_class); if (retval) {//.........这里部分代码省略.........
开发者ID:19Dan01,项目名称:linux,代码行数:101,
示例8: gotemp_probestatic int gotemp_probe(struct usb_interface *interface, const struct usb_device_id *id){ struct usb_device *udev = interface_to_usbdev(interface); struct gotemp *gdev = NULL; int retval = -ENOMEM; int i; struct usb_host_interface *iface_desc; struct usb_endpoint_descriptor *endpoint = NULL; size_t buffer_size = 0; gdev = kzalloc(sizeof(struct gotemp), GFP_KERNEL); if (gdev == NULL) { dev_err(&interface->dev, "Out of memory/n"); goto error; } gdev->udev = usb_get_dev(udev); /* find the one control endpoint of this device */ iface_desc = interface->cur_altsetting; for (i = 0; i < iface_desc->desc.bNumEndpoints; ++i) { endpoint = &iface_desc->endpoint[i].desc; if (usb_endpoint_is_int_in(endpoint)) { buffer_size = le16_to_cpu(endpoint->wMaxPacketSize); gdev->int_in_endpointAddr = endpoint->bEndpointAddress; gdev->int_in_buffer = kmalloc(buffer_size, GFP_KERNEL); if (!gdev->int_in_buffer) { dev_err(&interface->dev, "Could not allocate buffer"); goto error; } break; } } if (!gdev->int_in_endpointAddr) { dev_err(&interface->dev, "Could not find int-in endpoint"); retval = -ENODEV; goto error; } gdev->int_in_urb = usb_alloc_urb(0, GFP_KERNEL); if (!gdev->int_in_urb) { dev_err(&interface->dev, "No free urbs available/n"); goto error; } usb_fill_int_urb(gdev->int_in_urb, udev, usb_rcvintpipe(udev, endpoint->bEndpointAddress), gdev->int_in_buffer, buffer_size, read_int_callback, gdev, endpoint->bInterval); usb_set_intfdata(interface, gdev); init_dev(gdev); /* * this must come last - after this call the device is active * if we delayed any initialization until after this, the user * would read garbage */ retval = device_create_file(&interface->dev, &dev_attr_temperature); if (retval) goto error; dev_info(&interface->dev, "USB GoTemp device now attached/n"); return 0;error: usb_set_intfdata(interface, NULL); if (gdev) { usb_free_urb(gdev->int_in_urb); kfree(gdev->int_in_buffer); } kfree(gdev); return retval;}
开发者ID:alexander-naumov,项目名称:usb_tutorial,代码行数:79,
示例9: 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,
示例10: kobil_port_probestatic int kobil_port_probe(struct usb_serial_port *port){ int i; struct usb_serial *serial = port->serial; struct kobil_private *priv; struct usb_device *pdev; struct usb_host_config *actconfig; struct usb_interface *interface; struct usb_host_interface *altsetting; struct usb_host_endpoint *endpoint; priv = kmalloc(sizeof(struct kobil_private), GFP_KERNEL); if (!priv) return -ENOMEM; priv->filled = 0; priv->cur_pos = 0; priv->device_type = le16_to_cpu(serial->dev->descriptor.idProduct); switch (priv->device_type) { case KOBIL_ADAPTER_B_PRODUCT_ID: dev_dbg(&serial->dev->dev, "KOBIL B1 PRO / KAAN PRO detected/n"); break; case KOBIL_ADAPTER_K_PRODUCT_ID: dev_dbg(&serial->dev->dev, "KOBIL KAAN Standard Plus / SecOVID Reader Plus detected/n"); break; case KOBIL_USBTWIN_PRODUCT_ID: dev_dbg(&serial->dev->dev, "KOBIL USBTWIN detected/n"); break; case KOBIL_KAAN_SIM_PRODUCT_ID: dev_dbg(&serial->dev->dev, "KOBIL KAAN SIM detected/n"); break; } usb_set_serial_port_data(port, priv); /* search for the necessary endpoints */ pdev = serial->dev; actconfig = pdev->actconfig; interface = actconfig->interface[0]; altsetting = interface->cur_altsetting; endpoint = altsetting->endpoint; for (i = 0; i < altsetting->desc.bNumEndpoints; i++) { endpoint = &altsetting->endpoint[i]; if (usb_endpoint_is_int_out(&endpoint->desc)) { dev_dbg(&serial->dev->dev, "%s Found interrupt out endpoint. Address: %d/n", __func__, endpoint->desc.bEndpointAddress); priv->write_int_endpoint_address = endpoint->desc.bEndpointAddress; } if (usb_endpoint_is_int_in(&endpoint->desc)) { dev_dbg(&serial->dev->dev, "%s Found interrupt in endpoint. Address: %d/n", __func__, endpoint->desc.bEndpointAddress); priv->read_int_endpoint_address = endpoint->desc.bEndpointAddress; } } return 0;}
开发者ID:AiWinters,项目名称:linux,代码行数:61,
示例11: adu_probe/** * adu_probe * * Called by the usb core when a new device is connected that it thinks * this driver might be interested in. */static int adu_probe(struct usb_interface *interface, const struct usb_device_id *id){ struct usb_device *udev = interface_to_usbdev(interface); struct adu_device *dev = NULL; struct usb_host_interface *iface_desc; struct usb_endpoint_descriptor *endpoint; int retval = -ENODEV; int in_end_size; int out_end_size; int i; dbg(2," %s : enter", __func__); if (udev == NULL) { dev_err(&interface->dev, "udev is NULL./n"); goto exit; } /* allocate memory for our device state and initialize it */ dev = kzalloc(sizeof(struct adu_device), GFP_KERNEL); if (dev == NULL) { dev_err(&interface->dev, "Out of memory/n"); retval = -ENOMEM; goto exit; } mutex_init(&dev->mtx); spin_lock_init(&dev->buflock); dev->udev = udev; init_waitqueue_head(&dev->read_wait); init_waitqueue_head(&dev->write_wait); iface_desc = &interface->altsetting[0]; /* set up the endpoint information */ for (i = 0; i < iface_desc->desc.bNumEndpoints; ++i) { endpoint = &iface_desc->endpoint[i].desc; if (usb_endpoint_is_int_in(endpoint)) dev->interrupt_in_endpoint = endpoint; if (usb_endpoint_is_int_out(endpoint)) dev->interrupt_out_endpoint = endpoint; } if (dev->interrupt_in_endpoint == NULL) { dev_err(&interface->dev, "interrupt in endpoint not found/n"); goto error; } if (dev->interrupt_out_endpoint == NULL) { dev_err(&interface->dev, "interrupt out endpoint not found/n"); goto error; } in_end_size = le16_to_cpu(dev->interrupt_in_endpoint->wMaxPacketSize); out_end_size = le16_to_cpu(dev->interrupt_out_endpoint->wMaxPacketSize); dev->read_buffer_primary = kmalloc((4 * in_end_size), GFP_KERNEL); if (!dev->read_buffer_primary) { dev_err(&interface->dev, "Couldn't allocate read_buffer_primary/n"); retval = -ENOMEM; goto error; } /* debug code prime the buffer */ memset(dev->read_buffer_primary, 'a', in_end_size); memset(dev->read_buffer_primary + in_end_size, 'b', in_end_size); memset(dev->read_buffer_primary + (2 * in_end_size), 'c', in_end_size); memset(dev->read_buffer_primary + (3 * in_end_size), 'd', in_end_size); dev->read_buffer_secondary = kmalloc((4 * in_end_size), GFP_KERNEL); if (!dev->read_buffer_secondary) { dev_err(&interface->dev, "Couldn't allocate read_buffer_secondary/n"); retval = -ENOMEM; goto error; } /* debug code prime the buffer */ memset(dev->read_buffer_secondary, 'e', in_end_size); memset(dev->read_buffer_secondary + in_end_size, 'f', in_end_size); memset(dev->read_buffer_secondary + (2 * in_end_size), 'g', in_end_size); memset(dev->read_buffer_secondary + (3 * in_end_size), 'h', in_end_size); dev->interrupt_in_buffer = kmalloc(in_end_size, GFP_KERNEL); if (!dev->interrupt_in_buffer) { dev_err(&interface->dev, "Couldn't allocate interrupt_in_buffer/n"); goto error; } /* debug code prime the buffer */ memset(dev->interrupt_in_buffer, 'i', in_end_size); dev->interrupt_in_urb = usb_alloc_urb(0, GFP_KERNEL); if (!dev->interrupt_in_urb) {//.........这里部分代码省略.........
开发者ID:119-org,项目名称:hi3518-osdrv,代码行数:101,
示例12: 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,
示例13: 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 = 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); hdev->open = btusb_open; hdev->close = btusb_close; hdev->flush = btusb_flush; hdev->send = btusb_send_frame;//.........这里部分代码省略.........
开发者ID:ArchangelSmarth,项目名称:linux,代码行数:101,
示例14: usb_alphatrack_probe/** * usb_alphatrack_probe * * Called by the usb core when a new device is connected that it thinks * this driver might be interested in. */static int usb_alphatrack_probe(struct usb_interface *intf, const struct usb_device_id *id){ struct usb_device *udev = interface_to_usbdev(intf); struct usb_alphatrack *dev = NULL; struct usb_host_interface *iface_desc; struct usb_endpoint_descriptor *endpoint; int i; int true_size; int retval = -ENOMEM; /* allocate memory for our device state and intialize it */ dev = kzalloc(sizeof(*dev), GFP_KERNEL); if (dev == NULL) { dev_err(&intf->dev, "Out of memory/n"); goto exit; } init_MUTEX(&dev->sem); dev->intf = intf; init_waitqueue_head(&dev->read_wait); init_waitqueue_head(&dev->write_wait); iface_desc = intf->cur_altsetting; /* set up the endpoint information */ for (i = 0; i < iface_desc->desc.bNumEndpoints; ++i) { endpoint = &iface_desc->endpoint[i].desc; if (usb_endpoint_is_int_in(endpoint)) dev->interrupt_in_endpoint = endpoint; if (usb_endpoint_is_int_out(endpoint)) dev->interrupt_out_endpoint = endpoint; } if (dev->interrupt_in_endpoint == NULL) { dev_err(&intf->dev, "Interrupt in endpoint not found/n"); goto error; } if (dev->interrupt_out_endpoint == NULL) dev_warn(&intf->dev, "Interrupt out endpoint not found" "(using control endpoint instead)/n"); dev->interrupt_in_endpoint_size = le16_to_cpu(dev->interrupt_in_endpoint->wMaxPacketSize); if (dev->interrupt_in_endpoint_size != 64) dev_warn(&intf->dev, "Interrupt in endpoint size is not 64!/n"); if (ring_buffer_size == 0) ring_buffer_size = RING_BUFFER_SIZE; true_size = min(ring_buffer_size, RING_BUFFER_SIZE); /* FIXME - there are more usb_alloc routines for dma correctness. Needed? */ dev->ring_buffer = kmalloc((true_size * sizeof(struct alphatrack_icmd)), GFP_KERNEL); if (!dev->ring_buffer) { dev_err(&intf->dev, "Couldn't allocate input ring_buffer of size %d/n", true_size); goto error; } dev->interrupt_in_buffer = kmalloc(dev->interrupt_in_endpoint_size, GFP_KERNEL); if (!dev->interrupt_in_buffer) { dev_err(&intf->dev, "Couldn't allocate interrupt_in_buffer/n"); goto error; } dev->oldi_buffer = kmalloc(dev->interrupt_in_endpoint_size, GFP_KERNEL); if (!dev->oldi_buffer) { dev_err(&intf->dev, "Couldn't allocate old buffer/n"); goto error; } dev->interrupt_in_urb = usb_alloc_urb(0, GFP_KERNEL); if (!dev->interrupt_in_urb) { dev_err(&intf->dev, "Couldn't allocate interrupt_in_urb/n"); goto error; } dev->interrupt_out_endpoint_size = dev->interrupt_out_endpoint ? le16_to_cpu(dev-> interrupt_out_endpoint-> wMaxPacketSize) : udev-> descriptor.bMaxPacketSize0; if (dev->interrupt_out_endpoint_size != 64) dev_warn(&intf->dev, "Interrupt out endpoint size is not 64!)/n");//.........这里部分代码省略.........
开发者ID:mikuhatsune001,项目名称:linux2.6.32,代码行数:101,
示例15: 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,
示例16: 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,
示例17: 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; 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->type = HCI_USB; hdev->driver_data = data; data->hdev = hdev; SET_HCIDEV_DEV(hdev, &intf->dev); hdev->open = btusb_open; hdev->close = btusb_close; hdev->flush = btusb_flush; hdev->send = btusb_send_frame; hdev->destruct = btusb_destruct; hdev->notify = btusb_notify; hdev->owner = THIS_MODULE;//.........这里部分代码省略.........
开发者ID:LorDClockaN,项目名称:htc-kernel-msm7x30,代码行数:101,
示例18: onetouch_connect_inputstatic int onetouch_connect_input(struct us_data *ss){ struct usb_device *udev = ss->pusb_dev; struct usb_host_interface *interface; struct usb_endpoint_descriptor *endpoint; struct usb_onetouch *onetouch; struct input_dev *input_dev; int pipe, maxp; int error = -ENOMEM; interface = ss->pusb_intf->cur_altsetting; if (interface->desc.bNumEndpoints != 3) return -ENODEV; endpoint = &interface->endpoint[2].desc; if (!usb_endpoint_is_int_in(endpoint)) return -ENODEV; pipe = usb_rcvintpipe(udev, endpoint->bEndpointAddress); maxp = usb_maxpacket(udev, pipe, usb_pipeout(pipe)); onetouch = kzalloc(sizeof(struct usb_onetouch), GFP_KERNEL); input_dev = input_allocate_device(); if (!onetouch || !input_dev) goto fail1; onetouch->data = usb_alloc_coherent(udev, ONETOUCH_PKT_LEN, GFP_KERNEL, &onetouch->data_dma); if (!onetouch->data) goto fail1; onetouch->irq = usb_alloc_urb(0, GFP_KERNEL); if (!onetouch->irq) goto fail2; onetouch->udev = udev; onetouch->dev = input_dev; if (udev->manufacturer) strlcpy(onetouch->name, udev->manufacturer, sizeof(onetouch->name)); if (udev->product) { if (udev->manufacturer) strlcat(onetouch->name, " ", sizeof(onetouch->name)); strlcat(onetouch->name, udev->product, sizeof(onetouch->name)); } if (!strlen(onetouch->name)) snprintf(onetouch->name, sizeof(onetouch->name), "Maxtor Onetouch %04x:%04x", le16_to_cpu(udev->descriptor.idVendor), le16_to_cpu(udev->descriptor.idProduct)); usb_make_path(udev, onetouch->phys, sizeof(onetouch->phys)); strlcat(onetouch->phys, "/input0", sizeof(onetouch->phys)); input_dev->name = onetouch->name; input_dev->phys = onetouch->phys; usb_to_input_id(udev, &input_dev->id); input_dev->dev.parent = &udev->dev; set_bit(EV_KEY, input_dev->evbit); set_bit(ONETOUCH_BUTTON, input_dev->keybit); clear_bit(0, input_dev->keybit); input_set_drvdata(input_dev, onetouch); input_dev->open = usb_onetouch_open; input_dev->close = usb_onetouch_close; usb_fill_int_urb(onetouch->irq, udev, pipe, onetouch->data, (maxp > 8 ? 8 : maxp), usb_onetouch_irq, onetouch, endpoint->bInterval); onetouch->irq->transfer_dma = onetouch->data_dma; onetouch->irq->transfer_flags |= URB_NO_TRANSFER_DMA_MAP; ss->extra_destructor = onetouch_release_input; ss->extra = onetouch;#ifdef CONFIG_PM ss->suspend_resume_hook = usb_onetouch_pm_hook;#endif error = input_register_device(onetouch->dev); if (error) goto fail3; return 0; fail3: usb_free_urb(onetouch->irq); fail2: usb_free_coherent(udev, ONETOUCH_PKT_LEN, onetouch->data, onetouch->data_dma); fail1: kfree(onetouch); input_free_device(input_dev); return error;}
开发者ID:Albinoman887,项目名称:pyramid-3.4.10,代码行数:96,
示例19: usb_tranzport_probe/** * usb_tranzport_probe * * Called by the usb core when a new device is connected that it thinks * this driver might be interested in. */static int usb_tranzport_probe(struct usb_interface *intf, const struct usb_device_id *id){ struct usb_device *udev = interface_to_usbdev(intf); struct usb_tranzport *dev = NULL; struct usb_host_interface *iface_desc; struct usb_endpoint_descriptor *endpoint; int i; int true_size; int retval = -ENOMEM; /* allocate memory for our device state and intialize it */ dev = kzalloc(sizeof(*dev), GFP_KERNEL); if (dev == NULL) { dev_err(&intf->dev, "Out of memory/n"); goto exit; } init_MUTEX(&dev->sem); dev->intf = intf; init_waitqueue_head(&dev->read_wait); init_waitqueue_head(&dev->write_wait); iface_desc = intf->cur_altsetting; /* set up the endpoint information */ for (i = 0; i < iface_desc->desc.bNumEndpoints; ++i) { endpoint = &iface_desc->endpoint[i].desc; if (usb_endpoint_is_int_in(endpoint)) dev->interrupt_in_endpoint = endpoint; if (usb_endpoint_is_int_out(endpoint)) dev->interrupt_out_endpoint = endpoint; } if (dev->interrupt_in_endpoint == NULL) { dev_err(&intf->dev, "Interrupt in endpoint not found/n"); goto error; } if (dev->interrupt_out_endpoint == NULL) dev_warn(&intf->dev, "Interrupt out endpoint not found (using control endpoint instead)/n"); dev->interrupt_in_endpoint_size = le16_to_cpu(dev->interrupt_in_endpoint->wMaxPacketSize); if (dev->interrupt_in_endpoint_size != 8) dev_warn(&intf->dev, "Interrupt in endpoint size is not 8!/n"); if(ring_buffer_size == 0) { ring_buffer_size = RING_BUFFER_SIZE; } true_size = min(ring_buffer_size,RING_BUFFER_SIZE); /* FIXME - there are more usb_alloc routines for dma correctness. Needed? */ dev->ring_buffer = kmalloc((true_size*sizeof(struct tranzport_cmd))+8, GFP_KERNEL); if (!dev->ring_buffer) { dev_err(&intf->dev, "Couldn't allocate ring_buffer of size %d/n",true_size); goto error; } dev->interrupt_in_buffer = kmalloc(dev->interrupt_in_endpoint_size, GFP_KERNEL); if (!dev->interrupt_in_buffer) { dev_err(&intf->dev, "Couldn't allocate interrupt_in_buffer/n"); goto error; } dev->interrupt_in_urb = usb_alloc_urb(0, GFP_KERNEL); if (!dev->interrupt_in_urb) { dev_err(&intf->dev, "Couldn't allocate interrupt_in_urb/n"); goto error; } dev->interrupt_out_endpoint_size = dev->interrupt_out_endpoint ? le16_to_cpu(dev->interrupt_out_endpoint->wMaxPacketSize) : udev->descriptor.bMaxPacketSize0; if (dev->interrupt_out_endpoint_size !=8) dev_warn(&intf->dev, "Interrupt out endpoint size is not 8!)/n"); dev->interrupt_out_buffer = kmalloc(write_buffer_size*dev->interrupt_out_endpoint_size, GFP_KERNEL); if (!dev->interrupt_out_buffer) { dev_err(&intf->dev, "Couldn't allocate interrupt_out_buffer/n"); goto error; } dev->interrupt_out_urb = usb_alloc_urb(0, GFP_KERNEL); if (!dev->interrupt_out_urb) { dev_err(&intf->dev, "Couldn't allocate interrupt_out_urb/n"); goto error; } dev->interrupt_in_interval = min_interrupt_in_interval > dev->interrupt_in_endpoint->bInterval ? min_interrupt_in_interval : dev->interrupt_in_endpoint->bInterval; if (dev->interrupt_out_endpoint) dev->interrupt_out_interval = min_interrupt_out_interval > dev->interrupt_out_endpoint->bInterval ? min_interrupt_out_interval : dev->interrupt_out_endpoint->bInterval; /* we can register the device now, as it is ready */ usb_set_intfdata(intf, dev); retval = usb_register_dev(intf, &usb_tranzport_class); if (retval) { /* something prevented us from registering this driver */ dev_err(&intf->dev, "Not able to get a minor for this device./n");//.........这里部分代码省略.........
开发者ID:63n,项目名称:ardour,代码行数:101,
示例20: iowarrior_probe/** * iowarrior_probe * * Called by the usb core when a new device is connected that it thinks * this driver might be interested in. */static int iowarrior_probe(struct usb_interface *interface, const struct usb_device_id *id){ struct usb_device *udev = interface_to_usbdev(interface); struct iowarrior *dev = NULL; struct usb_host_interface *iface_desc; struct usb_endpoint_descriptor *endpoint; int i; int retval = -ENOMEM; /* allocate memory for our device state and initialize it */ dev = kzalloc(sizeof(struct iowarrior), GFP_KERNEL); if (dev == NULL) { dev_err(&interface->dev, "Out of memory/n"); return retval; } mutex_init(&dev->mutex); atomic_set(&dev->intr_idx, 0); atomic_set(&dev->read_idx, 0); spin_lock_init(&dev->intr_idx_lock); atomic_set(&dev->overflow_flag, 0); init_waitqueue_head(&dev->read_wait); atomic_set(&dev->write_busy, 0); init_waitqueue_head(&dev->write_wait); dev->udev = udev; dev->interface = interface; iface_desc = interface->cur_altsetting; dev->product_id = le16_to_cpu(udev->descriptor.idProduct); /* set up the endpoint information */ for (i = 0; i < iface_desc->desc.bNumEndpoints; ++i) { endpoint = &iface_desc->endpoint[i].desc; if (usb_endpoint_is_int_in(endpoint)) dev->int_in_endpoint = endpoint; if (usb_endpoint_is_int_out(endpoint)) /* this one will match for the IOWarrior56 only */ dev->int_out_endpoint = endpoint; } /* we have to check the report_size often, so remember it in the endianess suitable for our machine */ dev->report_size = usb_endpoint_maxp(dev->int_in_endpoint); if ((dev->interface->cur_altsetting->desc.bInterfaceNumber == 0) && (dev->product_id == USB_DEVICE_ID_CODEMERCS_IOW56)) /* IOWarrior56 has wMaxPacketSize different from report size */ dev->report_size = 7; /* create the urb and buffer for reading */ dev->int_in_urb = usb_alloc_urb(0, GFP_KERNEL); if (!dev->int_in_urb) { dev_err(&interface->dev, "Couldn't allocate interrupt_in_urb/n"); goto error; } dev->int_in_buffer = kmalloc(dev->report_size, GFP_KERNEL); if (!dev->int_in_buffer) { dev_err(&interface->dev, "Couldn't allocate int_in_buffer/n"); goto error; } usb_fill_int_urb(dev->int_in_urb, dev->udev, usb_rcvintpipe(dev->udev, dev->int_in_endpoint->bEndpointAddress), dev->int_in_buffer, dev->report_size, iowarrior_callback, dev, dev->int_in_endpoint->bInterval); /* create an internal buffer for interrupt data from the device */ dev->read_queue = kmalloc(((dev->report_size + 1) * MAX_INTERRUPT_BUFFER), GFP_KERNEL); if (!dev->read_queue) { dev_err(&interface->dev, "Couldn't allocate read_queue/n"); goto error; } /* Get the serial-number of the chip */ memset(dev->chip_serial, 0x00, sizeof(dev->chip_serial)); usb_string(udev, udev->descriptor.iSerialNumber, dev->chip_serial, sizeof(dev->chip_serial)); if (strlen(dev->chip_serial) != 8) memset(dev->chip_serial, 0x00, sizeof(dev->chip_serial)); /* Set the idle timeout to 0, if this is interface 0 */ if (dev->interface->cur_altsetting->desc.bInterfaceNumber == 0) { usb_control_msg(udev, usb_sndctrlpipe(udev, 0), 0x0A, USB_TYPE_CLASS | USB_RECIP_INTERFACE, 0, 0, NULL, 0, USB_CTRL_SET_TIMEOUT); } /* allow device read and ioctl */ dev->present = 1; /* we can register the device now, as it is ready */ usb_set_intfdata(interface, dev);//.........这里部分代码省略.........
开发者ID:96boards,项目名称:wilink8-wlan_wl18xx,代码行数:101,
示例21: usbnet_generic_cdc_bind//.........这里部分代码省略......... } detail = (void *)buf; if (detail->bGuidDescriptorType == 0) { if (detail->bLength < (sizeof(*detail) + 1)) goto bad_desc; } else goto bad_desc; break; case USB_CDC_NCM_TYPE: if (info->ncm) { dev_dbg(&intf->dev, "extra NCM functional descriptor/n"); goto bad_desc; } info->ncm = (void *) buf; if (info->ncm->bLength != sizeof *info->ncm) { dev_dbg(&intf->dev, "CDC NCM len %u/n", info->ncm->bLength); goto bad_desc; } /* ignore bcdVersion, should be 1.0 anyway */ dev_dbg(&intf->dev, "bmNetworkCapabilities: 0x%02x/n", info->ncm->bmNetworkCapabilities); break; }next_desc: len -= buf [0]; /* bLength */ buf += buf [0]; } /* Microsoft ActiveSync based and some regular RNDIS devices lack the * CDC descriptors, so we'll hard-wire the interfaces and not check * for descriptors. */ if (rndis && !info->u) { info->control = usb_ifnum_to_if(dev->udev, 0); info->data = usb_ifnum_to_if(dev->udev, 1); if (!info->control || !info->data) { dev_dbg(&intf->dev, "rndis: master #0/%p slave #1/%p/n", info->control, info->data); goto bad_desc; } } else if (!info->header || !info->u || (!rndis && !info->ether) || (ncm && !info->ncm)) { dev_dbg(&intf->dev, "missing cdc %s%s%s%sdescriptor/n", info->header ? "" : "header ", info->u ? "" : "union ", info->ether ? "" : "ether ", info->ncm ? "" : "ncm "); goto bad_desc; } /* claim data interface and set it up ... with side effects. * network traffic can't flow until an altsetting is enabled. */ status = usb_driver_claim_interface(driver, info->data, dev); if (status < 0) return status; status = usbnet_get_endpoints(dev, info->data); if (status < 0) { /* ensure immediate exit from usbnet_disconnect */ usb_set_intfdata(info->data, NULL); usb_driver_release_interface(driver, info->data); return status; } /* status endpoint: optional for CDC Ethernet, not RNDIS (or ACM) */ dev->status = NULL; if (info->control->cur_altsetting->desc.bNumEndpoints == 1) { struct usb_endpoint_descriptor *desc; dev->status = &info->control->cur_altsetting->endpoint [0]; desc = &dev->status->desc; if (!usb_endpoint_is_int_in(desc) || (le16_to_cpu(desc->wMaxPacketSize) < sizeof(struct usb_cdc_notification)) || !desc->bInterval) { dev_dbg(&intf->dev, "bad notification endpoint/n"); dev->status = NULL; } } if (rndis && !dev->status) { dev_dbg(&intf->dev, "missing RNDIS status endpoint/n"); usb_set_intfdata(info->data, NULL); usb_driver_release_interface(driver, info->data); return -ENODEV; } return 0;bad_desc: dev_info(&dev->udev->dev, "bad CDC descriptors/n"); return -ENODEV;}
开发者ID:AdiPat,项目名称:android_kernel_tegra_n1,代码行数:101,
示例22: usb_mouse_probestatic int usb_mouse_probe(struct usb_interface *intf, const struct usb_device_id *id){ struct usb_device *dev = interface_to_usbdev(intf); struct usb_host_interface *interface; struct usb_endpoint_descriptor *endpoint; struct usb_mouse *mouse; struct input_dev *input_dev; int pipe, maxp; int error = -ENOMEM; interface = intf->cur_altsetting; if (interface->desc.bNumEndpoints != 1) return -ENODEV; endpoint = &interface->endpoint[0].desc; if (!usb_endpoint_is_int_in(endpoint)) return -ENODEV; pipe = usb_rcvintpipe(dev, endpoint->bEndpointAddress); maxp = usb_maxpacket(dev, pipe, usb_pipeout(pipe)); mouse = kzalloc(sizeof(struct usb_mouse), GFP_KERNEL); input_dev = input_allocate_device(); if (!mouse || !input_dev) goto fail1; mouse->data = usb_buffer_alloc(dev, 8, GFP_ATOMIC, &mouse->data_dma); if (!mouse->data) goto fail1; mouse->irq = usb_alloc_urb(0, GFP_KERNEL); if (!mouse->irq) goto fail2; mouse->usbdev = dev; mouse->dev = input_dev; if (dev->manufacturer) strlcpy(mouse->name, dev->manufacturer, sizeof(mouse->name)); if (dev->product) { if (dev->manufacturer) strlcat(mouse->name, " ", sizeof(mouse->name)); strlcat(mouse->name, dev->product, sizeof(mouse->name)); } if (!strlen(mouse->name)) snprintf(mouse->name, sizeof(mouse->name), "USB HIDBP Mouse %04x:%04x", le16_to_cpu(dev->descriptor.idVendor), le16_to_cpu(dev->descriptor.idProduct)); usb_make_path(dev, mouse->phys, sizeof(mouse->phys)); strlcat(mouse->phys, "/input0", sizeof(mouse->phys)); input_dev->name = mouse->name; input_dev->phys = mouse->phys; usb_to_input_id(dev, &input_dev->id); input_dev->dev.parent = &intf->dev; input_dev->evbit[0] = BIT_MASK(EV_KEY) | BIT_MASK(EV_REL); input_dev->keybit[BIT_WORD(BTN_MOUSE)] = BIT_MASK(BTN_LEFT) | BIT_MASK(BTN_RIGHT) | BIT_MASK(BTN_MIDDLE); input_dev->relbit[0] = BIT_MASK(REL_X) | BIT_MASK(REL_Y); input_dev->keybit[BIT_WORD(BTN_MOUSE)] |= BIT_MASK(BTN_SIDE) | BIT_MASK(BTN_EXTRA); input_dev->relbit[0] |= BIT_MASK(REL_WHEEL); input_set_drvdata(input_dev, mouse); input_dev->open = usb_mouse_open; input_dev->close = usb_mouse_close; usb_fill_int_urb(mouse->irq, dev, pipe, mouse->data, (maxp > 8 ? 8 : maxp), usb_mouse_irq, mouse, endpoint->bInterval); mouse->irq->transfer_dma = mouse->data_dma; mouse->irq->transfer_flags |= URB_NO_TRANSFER_DMA_MAP; error = input_register_device(mouse->dev); if (error) goto fail3; usb_set_intfdata(intf, mouse); return 0;fail3: usb_free_urb(mouse->irq);fail2: usb_buffer_free(dev, 8, mouse->data, mouse->data_dma);fail1: input_free_device(input_dev); kfree(mouse); return error;}
开发者ID:johnny,项目名称:CobraDroidBeta,代码行数:96,
注:本文中的usb_endpoint_is_int_in函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 C++ usb_endpoint_is_isoc_in函数代码示例 C++ usb_endpoint_is_bulk_out函数代码示例 |