这篇教程C++ to_usb_device函数代码示例写得很实用,希望能帮到您。
本文整理汇总了C++中to_usb_device函数的典型用法代码示例。如果您正苦于以下问题:C++ to_usb_device函数的具体用法?C++ to_usb_device怎么用?C++ to_usb_device使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。 在下文中一共展示了to_usb_device函数的17个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。 示例1: show_removablestatic ssize_tshow_removable(struct device *dev, struct device_attribute *attr, char *buf){ struct usb_device *udev; char *state; udev = to_usb_device(dev); switch (udev->removable) { case USB_DEVICE_REMOVABLE: state = "removable"; break; case USB_DEVICE_FIXED: state = "fixed"; break; default: state = "unknown"; } return sprintf(buf, "%s/n", state);}
开发者ID:Albinoman887,项目名称:pyramid-3.4.10,代码行数:21,
示例2: set_autosuspendstatic ssize_tset_autosuspend(struct device *dev, struct device_attribute *attr, const char *buf, size_t count){ struct usb_device *udev = to_usb_device(dev); int value; if (sscanf(buf, "%d", &value) != 1 || value >= INT_MAX/HZ || value <= - INT_MAX/HZ) return -EINVAL; value *= HZ; udev->autosuspend_delay = value; if (value >= 0) usb_try_autosuspend_device(udev); else { if (usb_autoresume_device(udev) == 0) usb_autosuspend_device(udev); } return count;}
开发者ID:13xiaobang,项目名称:mini2440_linux-2.6.32.2,代码行数:21,
示例3: _usb_writeN_syncstatic void _usb_writeN_sync(struct rtl_priv *rtlpriv, u32 addr, void *data, u16 len){ struct device *dev = rtlpriv->io.dev; struct usb_device *udev = to_usb_device(dev); u8 request = REALTEK_USB_VENQT_CMD_REQ; u8 reqtype = REALTEK_USB_VENQT_WRITE; u16 wvalue; u16 index = REALTEK_USB_VENQT_CMD_IDX; int pipe = usb_sndctrlpipe(udev, 0); /* write_out */ u8 *buffer; wvalue = (u16)(addr & 0x0000ffff); buffer = kmemdup(data, len, GFP_ATOMIC); if (!buffer) return; usb_control_msg(udev, pipe, request, reqtype, wvalue, index, buffer, len, 50); kfree(buffer);}
开发者ID:7799,项目名称:linux,代码行数:21,
示例4: read_descriptorsstatic ssize_tread_descriptors(struct file *filp, struct kobject *kobj, struct bin_attribute *attr, char *buf, loff_t off, size_t count){ struct device *dev = container_of(kobj, struct device, kobj); struct usb_device *udev = to_usb_device(dev); size_t nleft = count; size_t srclen, n; int cfgno; void *src; /* The binary attribute begins with the device descriptor. * Following that are the raw descriptor entries for all the * configurations (config plus subsidiary descriptors). */ usb_lock_device(udev); for (cfgno = -1; cfgno < udev->descriptor.bNumConfigurations && nleft > 0; ++cfgno) { if (cfgno < 0) { src = &udev->descriptor; srclen = sizeof(struct usb_device_descriptor); } else { src = udev->rawdescriptors[cfgno]; srclen = __le16_to_cpu(udev->config[cfgno].desc. wTotalLength); } if (off < srclen) { n = min(nleft, srclen - (size_t) off); memcpy(buf, src + off, n); nleft -= n; buf += n; off = 0; } else { off -= srclen; } } usb_unlock_device(udev); return count - nleft;}
开发者ID:Codefollows,项目名称:ps4-linux,代码行数:40,
示例5: usb_port_runtime_suspendstatic int usb_port_runtime_suspend(struct device *dev){ struct usb_port *port_dev = to_usb_port(dev); struct usb_device *hdev = to_usb_device(dev->parent->parent); struct usb_interface *intf = to_usb_interface(dev->parent); struct usb_hub *hub = usb_hub_to_struct_hub(hdev); struct usb_port *peer = port_dev->peer; int port1 = port_dev->portnum; int retval; if (!hub) return -EINVAL; if (hub->in_reset) return -EBUSY; if (dev_pm_qos_flags(&port_dev->dev, PM_QOS_FLAG_NO_POWER_OFF) == PM_QOS_FLAGS_ALL) return -EAGAIN; if (usb_port_block_power_off) return -EBUSY; usb_autopm_get_interface(intf); retval = usb_hub_set_port_power(hdev, hub, port1, false); usb_clear_port_feature(hdev, port1, USB_PORT_FEAT_C_CONNECTION); if (!port_dev->is_superspeed) usb_clear_port_feature(hdev, port1, USB_PORT_FEAT_C_ENABLE); usb_autopm_put_interface(intf); /* * Our peer usb3 port may now be able to suspend, so * asynchronously queue a suspend request to observe that this * usb2 port is now off. */ if (!port_dev->is_superspeed && peer) pm_runtime_put(&peer->dev); return retval;}
开发者ID:abhinav90,项目名称:linux,代码行数:39,
示例6: set_usb2_hardware_lpmstatic ssize_tset_usb2_hardware_lpm(struct device *dev, struct device_attribute *attr, const char *buf, size_t count){ struct usb_device *udev = to_usb_device(dev); bool value; int ret; usb_lock_device(udev); ret = strtobool(buf, &value); if (!ret) ret = usb_set_usb2_hardware_lpm(udev, value); usb_unlock_device(udev); if (!ret) return count; return ret;}
开发者ID:jue-jiang,项目名称:rc3-linux,代码行数:22,
示例7: usb_port_runtime_resumestatic int usb_port_runtime_resume(struct device *dev){ struct usb_port *port_dev = to_usb_port(dev); struct usb_device *hdev = to_usb_device(dev->parent->parent); struct usb_interface *intf = to_usb_interface(dev->parent); struct usb_hub *hub = usb_hub_to_struct_hub(hdev); int port1 = port_dev->portnum; int retval; if (!hub) return -EINVAL; usb_autopm_get_interface(intf); set_bit(port1, hub->busy_bits); retval = usb_hub_set_port_power(hdev, hub, port1, true); if (port_dev->child && !retval) { /* * Wait for usb hub port to be reconnected in order to make * the resume procedure successful. */ retval = hub_port_debounce_be_connected(hub, port1); if (retval < 0) { dev_dbg(&port_dev->dev, "can't get reconnection after setting port power on, status %d/n", retval); goto out; } usb_clear_port_feature(hdev, port1, USB_PORT_FEAT_C_ENABLE); /* Set return value to 0 if debounce successful */ retval = 0; }out: clear_bit(port1, hub->busy_bits); usb_autopm_put_interface(intf); return retval;}
开发者ID:AD5GB,项目名称:kernel_n5_3.10-experimental,代码行数:38,
示例8: show_speedstatic ssize_tshow_speed(struct device *dev, struct device_attribute *attr, char *buf){ struct usb_device *udev; char *speed; udev = to_usb_device(dev); switch (udev->speed) { case USB_SPEED_LOW: speed = "1.5"; break; case USB_SPEED_UNKNOWN: case USB_SPEED_FULL: speed = "12"; break; case USB_SPEED_HIGH: speed = "480"; break; default: speed = "unknown"; } return sprintf(buf, "%s/n", speed);}
开发者ID:ECRS,项目名称:Asus-RT-N16,代码行数:24,
示例9: usb_acpi_find_devicestatic int usb_acpi_find_device(struct device *dev, acpi_handle *handle){ struct usb_device *udev; acpi_handle *parent_handle; int port_num; /* * In the ACPI DSDT table, only usb root hub and usb ports are * acpi device nodes. The hierarchy like following. * Device (EHC1) * Device (HUBN) * Device (PR01) * Device (PR11) * Device (PR12) * Device (PR13) * ... * So all binding process is divided into two parts. binding * root hub and usb ports. */ if (is_usb_device(dev)) { udev = to_usb_device(dev); if (udev->parent) { enum usb_port_connect_type type; /* * According usb port's connect type to set usb device's * removability. */ type = usb_get_hub_port_connect_type(udev->parent, udev->portnum); switch (type) { case USB_PORT_CONNECT_TYPE_HOT_PLUG: udev->removable = USB_DEVICE_REMOVABLE; break; case USB_PORT_CONNECT_TYPE_HARD_WIRED: udev->removable = USB_DEVICE_FIXED; break; default: udev->removable = USB_DEVICE_REMOVABLE_UNKNOWN; break; } return -ENODEV; } /* root hub's parent is the usb hcd. */ parent_handle = DEVICE_ACPI_HANDLE(dev->parent); *handle = acpi_get_child(parent_handle, udev->portnum); if (!*handle) return -ENODEV; return 0; } else if (is_usb_port(dev)) { sscanf(dev_name(dev), "port%d", &port_num); /* Get the struct usb_device point of port's hub */ udev = to_usb_device(dev->parent->parent); /* * The root hub ports' parent is the root hub. The non-root-hub * ports' parent is the parent hub port which the hub is * connected to. */ if (!udev->parent) { *handle = acpi_get_child(DEVICE_ACPI_HANDLE(&udev->dev), port_num); if (!*handle) return -ENODEV; } else { parent_handle = usb_get_hub_port_acpi_handle(udev->parent, udev->portnum); if (!parent_handle) return -ENODEV; *handle = acpi_get_child(parent_handle, port_num); if (!*handle) return -ENODEV; } usb_acpi_check_port_connect_type(udev, *handle, port_num); } else return -ENODEV; return 0;}
开发者ID:AdrianHuang,项目名称:linux-3.8.13,代码行数:83,
示例10: do_IRQasmlinkage void do_IRQ(int irq, struct pt_regs * regs){ struct irqaction *action; int do_random, cpu; int ret, retval = 0; cpu = smp_processor_id(); irq_enter(); kstat_cpu(cpu).irqs[irq - FIRST_IRQ]++; action = irq_action[irq - FIRST_IRQ]; if (action) { if (!(action->flags & SA_INTERRUPT)) local_irq_enable(); do_random = 0; do { ret = action->handler(irq, action->dev_id, regs); if (ret == IRQ_HANDLED) do_random |= action->flags; retval |= ret; action = action->next; } while (action); if (retval != 1) { if (retval) { printk("irq event %d: bogus retval mask %x/n", irq, retval); } else { printk("irq %d: nobody cared/n", irq); // add by cfyeh : debug for irq 2: nobody cared +++ if(irq == 2) { u32 regs; int i; int regs_num; #define HCS_N_PORTS(p) (((p)>>0)&0xf) /* bits 3:0, ports on HC */ regs_num= 21 + HCS_N_PORTS(inl(VENUS_USB_EHCI_HCSPARAMS)); udev = to_usb_device (dev); actconfig = udev->actconfig; printk("/n EHCI regs/n"); regs=VENUS_USB_EHCI_USBBASE; for(i=0;i<regs_num;i++) { if((i%4)==0) printk("0x%.8x : ", regs); printk("%.8x ", inl(regs)); regs+=4; if((i%4)==3) printk("/n"); } printk("/n"); } // add by cfyeh : debug for irq 2: nobody cared --- } } if (do_random & SA_SAMPLE_RANDOM) add_interrupt_randomness(irq); local_irq_disable(); } irq_exit();}
开发者ID:OpenHMR,项目名称:Open-HMR600,代码行数:64,
示例11: usb_parse_endpointstatic int usb_parse_endpoint(struct device *ddev, int cfgno, int inum, int asnum, struct usb_host_interface *ifp, int num_ep, unsigned char *buffer, int size){ unsigned char *buffer0 = buffer; struct usb_endpoint_descriptor *d; struct usb_host_endpoint *endpoint; int n, i, j; d = (struct usb_endpoint_descriptor *) buffer; buffer += d->bLength; size -= d->bLength; if (d->bLength >= USB_DT_ENDPOINT_AUDIO_SIZE) n = USB_DT_ENDPOINT_AUDIO_SIZE; else if (d->bLength >= USB_DT_ENDPOINT_SIZE) n = USB_DT_ENDPOINT_SIZE; else { dev_warn(ddev, "config %d interface %d altsetting %d has an " "invalid endpoint descriptor of length %d, skipping/n", cfgno, inum, asnum, d->bLength); goto skip_to_next_endpoint_or_interface_descriptor; } i = d->bEndpointAddress & ~USB_ENDPOINT_DIR_MASK; if (i >= 16 || i == 0) { dev_warn(ddev, "config %d interface %d altsetting %d has an " "invalid endpoint with address 0x%X, skipping/n", cfgno, inum, asnum, d->bEndpointAddress); goto skip_to_next_endpoint_or_interface_descriptor; } /* Only store as many endpoints as we have room for */ if (ifp->desc.bNumEndpoints >= num_ep) goto skip_to_next_endpoint_or_interface_descriptor; endpoint = &ifp->endpoint[ifp->desc.bNumEndpoints]; ++ifp->desc.bNumEndpoints; memcpy(&endpoint->desc, d, n); INIT_LIST_HEAD(&endpoint->urb_list); /* Fix up bInterval values outside the legal range. Use 32 ms if no * proper value can be guessed. */ i = 0; /* i = min, j = max, n = default */ j = 255; if (usb_endpoint_xfer_int(d)) { i = 1; switch (to_usb_device(ddev)->speed) { case USB_SPEED_HIGH: /* Many device manufacturers are using full-speed * bInterval values in high-speed interrupt endpoint * descriptors. Try to fix those and fall back to a * 32 ms default value otherwise. */ n = fls(d->bInterval*8); if (n == 0) n = 9; /* 32 ms = 2^(9-1) uframes */ j = 16; break; default: /* USB_SPEED_FULL or _LOW */ /* For low-speed, 10 ms is the official minimum. * But some "overclocked" devices might want faster * polling so we'll allow it. */ n = 32; break; } } else if (usb_endpoint_xfer_isoc(d)) { i = 1; j = 16; switch (to_usb_device(ddev)->speed) { case USB_SPEED_HIGH: n = 9; /* 32 ms = 2^(9-1) uframes */ break; default: /* USB_SPEED_FULL */ n = 6; /* 32 ms = 2^(6-1) frames */ break; } } if (d->bInterval < i || d->bInterval > j) { dev_warn(ddev, "config %d interface %d altsetting %d " "endpoint 0x%X has an invalid bInterval %d, " "changing to %d/n", cfgno, inum, asnum, d->bEndpointAddress, d->bInterval, n); endpoint->desc.bInterval = n; } /* Some buggy low-speed devices have Bulk endpoints, which is * explicitly forbidden by the USB spec. In an attempt to make * them usable, we will try treating them as Interrupt endpoints. */ if (to_usb_device(ddev)->speed == USB_SPEED_LOW && usb_endpoint_xfer_bulk(d)) { dev_warn(ddev, "config %d interface %d altsetting %d " "endpoint 0x%X is Bulk; changing to Interrupt/n", cfgno, inum, asnum, d->bEndpointAddress); endpoint->desc.bmAttributes = USB_ENDPOINT_XFER_INT; endpoint->desc.bInterval = 1; if (le16_to_cpu(endpoint->desc.wMaxPacketSize) > 8) endpoint->desc.wMaxPacketSize = cpu_to_le16(8);//.........这里部分代码省略.........
开发者ID:loginab,项目名称:esxdrivers,代码行数:101,
示例12: usb_parse_endpointstatic int usb_parse_endpoint(struct device *ddev, int cfgno, int inum, int asnum, struct usb_host_interface *ifp, int num_ep, unsigned char *buffer, int size){ unsigned char *buffer0 = buffer; struct usb_endpoint_descriptor *d; struct usb_host_endpoint *endpoint; int n, i, j, retval; d = (struct usb_endpoint_descriptor *) buffer; buffer += d->bLength; size -= d->bLength; if (d->bLength >= USB_DT_ENDPOINT_AUDIO_SIZE) n = USB_DT_ENDPOINT_AUDIO_SIZE; else if (d->bLength >= USB_DT_ENDPOINT_SIZE) n = USB_DT_ENDPOINT_SIZE; else { dev_warn(ddev, "config %d interface %d altsetting %d has an " "invalid endpoint descriptor of length %d, skipping/n", cfgno, inum, asnum, d->bLength); goto skip_to_next_endpoint_or_interface_descriptor; } i = d->bEndpointAddress & ~USB_ENDPOINT_DIR_MASK; if (i >= 16 || i == 0) { dev_warn(ddev, "config %d interface %d altsetting %d has an " "invalid endpoint with address 0x%X, skipping/n", cfgno, inum, asnum, d->bEndpointAddress); goto skip_to_next_endpoint_or_interface_descriptor; } if (ifp->desc.bNumEndpoints >= num_ep) goto skip_to_next_endpoint_or_interface_descriptor; endpoint = &ifp->endpoint[ifp->desc.bNumEndpoints]; ++ifp->desc.bNumEndpoints; memcpy(&endpoint->desc, d, n); INIT_LIST_HEAD(&endpoint->urb_list); i = 0; j = 255; if (usb_endpoint_xfer_int(d)) { i = 1; switch (to_usb_device(ddev)->speed) { case USB_SPEED_SUPER: case USB_SPEED_HIGH: n = fls(d->bInterval*8); if (n == 0) n = 9; j = 16; break; default: n = 32; break; } } else if (usb_endpoint_xfer_isoc(d)) { i = 1; j = 16; switch (to_usb_device(ddev)->speed) { case USB_SPEED_HIGH: n = 9; break; default: n = 6; break; } } if (d->bInterval < i || d->bInterval > j) { dev_warn(ddev, "config %d interface %d altsetting %d " "endpoint 0x%X has an invalid bInterval %d, " "changing to %d/n", cfgno, inum, asnum, d->bEndpointAddress, d->bInterval, n); endpoint->desc.bInterval = n; } if (to_usb_device(ddev)->speed == USB_SPEED_LOW && usb_endpoint_xfer_bulk(d)) { dev_warn(ddev, "config %d interface %d altsetting %d " "endpoint 0x%X is Bulk; changing to Interrupt/n", cfgno, inum, asnum, d->bEndpointAddress); endpoint->desc.bmAttributes = USB_ENDPOINT_XFER_INT; endpoint->desc.bInterval = 1; if (usb_endpoint_maxp(&endpoint->desc) > 8) endpoint->desc.wMaxPacketSize = cpu_to_le16(8); } if (to_usb_device(ddev)->speed == USB_SPEED_HIGH && usb_endpoint_xfer_bulk(d)) { unsigned maxp; maxp = usb_endpoint_maxp(&endpoint->desc) & 0x07ff; if (maxp != 512) dev_warn(ddev, "config %d interface %d altsetting %d " "bulk endpoint 0x%X has invalid maxpacket %d/n", cfgno, inum, asnum, d->bEndpointAddress, maxp);//.........这里部分代码省略.........
开发者ID:mjduddin,项目名称:B14CKB1RD_kernel_m8,代码行数:101,
示例13: authorized_show/* show if the device is authorized (1) or not (0) */static ssize_t authorized_show(struct device *dev, struct device_attribute *attr, char *buf){ struct usb_device *usb_dev = to_usb_device(dev); return snprintf(buf, PAGE_SIZE, "%u/n", usb_dev->authorized);}
开发者ID:Anjali05,项目名称:linux,代码行数:7,
示例14: usb2_lpm_besl_showstatic ssize_t usb2_lpm_besl_show(struct device *dev, struct device_attribute *attr, char *buf){ struct usb_device *udev = to_usb_device(dev); return sprintf(buf, "%d/n", udev->l1_params.besl);}
开发者ID:Anjali05,项目名称:linux,代码行数:6,
示例15: usb_parse_endpointstatic int usb_parse_endpoint(struct device *ddev, int cfgno, int inum, int asnum, struct usb_host_interface *ifp, int num_ep, unsigned char *buffer, int size){ unsigned char *buffer0 = buffer; struct usb_endpoint_descriptor *d; struct usb_host_endpoint *endpoint; int n, i, j, retval; unsigned int maxp; const unsigned short *maxpacket_maxes; d = (struct usb_endpoint_descriptor *) buffer; buffer += d->bLength; size -= d->bLength; if (d->bLength >= USB_DT_ENDPOINT_AUDIO_SIZE) n = USB_DT_ENDPOINT_AUDIO_SIZE; else if (d->bLength >= USB_DT_ENDPOINT_SIZE) n = USB_DT_ENDPOINT_SIZE; else { dev_warn(ddev, "config %d interface %d altsetting %d has an " "invalid endpoint descriptor of length %d, skipping/n", cfgno, inum, asnum, d->bLength); goto skip_to_next_endpoint_or_interface_descriptor; } i = d->bEndpointAddress & ~USB_ENDPOINT_DIR_MASK; if (i >= 16 || i == 0) { dev_warn(ddev, "config %d interface %d altsetting %d has an " "invalid endpoint with address 0x%X, skipping/n", cfgno, inum, asnum, d->bEndpointAddress); goto skip_to_next_endpoint_or_interface_descriptor; } /* Only store as many endpoints as we have room for */ if (ifp->desc.bNumEndpoints >= num_ep) goto skip_to_next_endpoint_or_interface_descriptor; endpoint = &ifp->endpoint[ifp->desc.bNumEndpoints]; ++ifp->desc.bNumEndpoints; memcpy(&endpoint->desc, d, n); INIT_LIST_HEAD(&endpoint->urb_list); /* * Fix up bInterval values outside the legal range. * Use 10 or 8 ms if no proper value can be guessed. */ i = 0; /* i = min, j = max, n = default */ j = 255; if (usb_endpoint_xfer_int(d)) { i = 1; switch (to_usb_device(ddev)->speed) { case USB_SPEED_SUPER_PLUS: case USB_SPEED_SUPER: case USB_SPEED_HIGH: /* * Many device manufacturers are using full-speed * bInterval values in high-speed interrupt endpoint * descriptors. Try to fix those and fall back to an * 8-ms default value otherwise. */ n = fls(d->bInterval*8); if (n == 0) n = 7; /* 8 ms = 2^(7-1) uframes */ j = 16; /* * Adjust bInterval for quirked devices. * This quirk fixes bIntervals reported in * linear microframes. */ if (to_usb_device(ddev)->quirks & USB_QUIRK_LINEAR_UFRAME_INTR_BINTERVAL) { n = clamp(fls(d->bInterval), i, j); i = j = n; } break; default: /* USB_SPEED_FULL or _LOW */ /* * For low-speed, 10 ms is the official minimum. * But some "overclocked" devices might want faster * polling so we'll allow it. */ n = 10; break; } } else if (usb_endpoint_xfer_isoc(d)) { i = 1; j = 16; switch (to_usb_device(ddev)->speed) { case USB_SPEED_HIGH: n = 7; /* 8 ms = 2^(7-1) uframes */ break; default: /* USB_SPEED_FULL */ n = 4; /* 8 ms = 2^(4-1) frames */ break; } } if (d->bInterval < i || d->bInterval > j) {//.........这里部分代码省略.........
开发者ID:acton393,项目名称:linux,代码行数:101,
示例16: to_usb_devicestatic struct acpi_device *usb_acpi_find_companion(struct device *dev){ int port1; struct usb_device *udev; acpi_handle *parent_handle; /* * In the ACPI DSDT table, only usb root hub and usb ports are * acpi device nodes. The hierarchy like following. * Device (EHC1) * Device (HUBN) * Device (PR01) * Device (PR11) * Device (PR12) * Device (PR13) * ... * So all binding process is divided into two parts. binding * root hub and usb ports. */ if (is_usb_device(dev)) { udev = to_usb_device(dev); port1 = udev->portnum; if (udev->parent) { struct usb_hub *hub; hub = usb_hub_to_struct_hub(udev->parent); /* * According usb port's connect type to set usb device's * removability. */ switch (hub->ports[port1 - 1]->connect_type) { case USB_PORT_CONNECT_TYPE_HOT_PLUG: udev->removable = USB_DEVICE_REMOVABLE; break; case USB_PORT_CONNECT_TYPE_HARD_WIRED: udev->removable = USB_DEVICE_FIXED; break; default: udev->removable = USB_DEVICE_REMOVABLE_UNKNOWN; break; } return NULL; } /* root hub's parent is the usb hcd. */ return acpi_find_child_device(ACPI_COMPANION(dev->parent), port1, false); } else if (is_usb_port(dev)) { struct usb_port *port_dev = to_usb_port(dev); struct acpi_device *adev = NULL; /* Get the struct usb_device point of port's hub */ udev = to_usb_device(dev->parent->parent); port1 = port_dev->portnum; /* * The root hub ports' parent is the root hub. The non-root-hub * ports' parent is the parent hub port which the hub is * connected to. */ if (!udev->parent) { struct usb_hcd *hcd = bus_to_hcd(udev->bus); int raw; raw = usb_hcd_find_raw_port_number(hcd, port1); adev = acpi_find_child_device(ACPI_COMPANION(&udev->dev), raw, false); if (!adev) return NULL; } else { parent_handle = usb_get_hub_port_acpi_handle(udev->parent, udev->portnum); if (!parent_handle) return NULL; acpi_bus_get_device(parent_handle, &adev); adev = acpi_find_child_device(adev, port1, false); if (!adev) return NULL; } usb_acpi_check_port_connect_type(udev, adev->handle, port1); return adev; } return NULL;}
开发者ID:atmark-techno,项目名称:linux-3.14-at,代码行数:88,
示例17: usb_parse_endpointstatic int usb_parse_endpoint(struct device *ddev, int cfgno, int inum, int asnum, struct usb_host_interface *ifp, int num_ep, unsigned char *buffer, int size){ unsigned char *buffer0 = buffer; struct usb_endpoint_descriptor *d; struct usb_host_endpoint *endpoint; int n, i, j, retval; d = (struct usb_endpoint_descriptor *) buffer; buffer += d->bLength; size -= d->bLength; if (d->bLength >= USB_DT_ENDPOINT_AUDIO_SIZE) n = USB_DT_ENDPOINT_AUDIO_SIZE; else if (d->bLength >= USB_DT_ENDPOINT_SIZE) n = USB_DT_ENDPOINT_SIZE; else { dev_warn(ddev, "config %d interface %d altsetting %d has an " "invalid endpoint descriptor of length %d, skipping/n", cfgno, inum, asnum, d->bLength); goto skip_to_next_endpoint_or_interface_descriptor; } i = d->bEndpointAddress & ~USB_ENDPOINT_DIR_MASK; if (i >= 16 || i == 0) { dev_warn(ddev, "config %d interface %d altsetting %d has an " "invalid endpoint with address 0x%X, skipping/n", cfgno, inum, asnum, d->bEndpointAddress); goto skip_to_next_endpoint_or_interface_descriptor; } /* Only store as many endpoints as we have room for */ if (ifp->desc.bNumEndpoints >= num_ep) goto skip_to_next_endpoint_or_interface_descriptor; endpoint = &ifp->endpoint[ifp->desc.bNumEndpoints]; ++ifp->desc.bNumEndpoints; memcpy(&endpoint->desc, d, n); INIT_LIST_HEAD(&endpoint->urb_list); /* Fix up bInterval values outside the legal range. Use 32 ms if no * proper value can be guessed. */ i = 0; /* i = min, j = max, n = default */ j = 255; if (usb_endpoint_xfer_int(d)) { i = 1; switch (to_usb_device(ddev)->speed) { case USB_SPEED_SUPER: case USB_SPEED_HIGH: /* Many device manufacturers are using full-speed * bInterval values in high-speed interrupt endpoint * descriptors. Try to fix those and fall back to a * 32 ms default value otherwise. */ n = fls(d->bInterval*8); if (n == 0) n = 9; /* 32 ms = 2^(9-1) uframes */ j = 16; break; default: /* USB_SPEED_FULL or _LOW */ /* For low-speed, 10 ms is the official minimum. * But some "overclocked" devices might want faster * polling so we'll allow it. */ n = 32; break; } } else if (usb_endpoint_xfer_isoc(d)) { i = 1; j = 16; switch (to_usb_device(ddev)->speed) { case USB_SPEED_HIGH: n = 9; /* 32 ms = 2^(9-1) uframes */ break; default: /* USB_SPEED_FULL */ n = 6; /* 32 ms = 2^(6-1) frames */ break; } } if (d->bInterval < i || d->bInterval > j) { dev_warn(ddev, "config %d interface %d altsetting %d " "endpoint 0x%X has an invalid bInterval %d, " "changing to %d/n", cfgno, inum, asnum, d->bEndpointAddress, d->bInterval, n); endpoint->desc.bInterval = n; } /* Some buggy low-speed devices have Bulk endpoints, which is * explicitly forbidden by the USB spec. In an attempt to make * them usable, we will try treating them as Interrupt endpoints. */ if (to_usb_device(ddev)->speed == USB_SPEED_LOW && usb_endpoint_xfer_bulk(d)) { dev_warn(ddev, "config %d interface %d altsetting %d " "endpoint 0x%X is Bulk; changing to Interrupt/n", cfgno, inum, asnum, d->bEndpointAddress); endpoint->desc.bmAttributes = USB_ENDPOINT_XFER_INT; endpoint->desc.bInterval = 1; if (le16_to_cpu(endpoint->desc.wMaxPacketSize) > 8)//.........这里部分代码省略.........
开发者ID:vps2fast,项目名称:openvz-kernel,代码行数:101,
注:本文中的to_usb_device函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 C++ to_usb_interface函数代码示例 C++ to_upper函数代码示例 |