您当前的位置:首页 > IT编程 > C++
| C语言 | Java | VB | VC | python | Android | TensorFlow | C++ | oracle | 学术与代码 | cnn卷积神经网络 | gnn | 图像修复 | Keras | 数据集 | Neo4j | 自然语言处理 | 深度学习 | 医学CAD | 医学影像 | 超参数 | pointnet | pytorch | 异常检测 | Transformers | 情感分类 | 知识图谱 |

自学教程:C++ usb_unlock_device函数代码示例

51自学网 2021-06-03 09:21:46
  C++
这篇教程C++ usb_unlock_device函数代码示例写得很实用,希望能帮到您。

本文整理汇总了C++中usb_unlock_device函数的典型用法代码示例。如果您正苦于以下问题:C++ usb_unlock_device函数的具体用法?C++ usb_unlock_device怎么用?C++ usb_unlock_device使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。

在下文中一共展示了usb_unlock_device函数的25个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。

示例1: set_level

static ssize_tset_level(struct device *dev, struct device_attribute *attr,          const char *buf, size_t count){    struct usb_device *udev = to_usb_device(dev);    int len = count;    char *cp;    int rc = 0;    int old_autosuspend_disabled, old_autoresume_disabled;    cp = memchr(buf, '/n', count);    if (cp)        len = cp - buf;    usb_lock_device(udev);    old_autosuspend_disabled = udev->autosuspend_disabled;    old_autoresume_disabled = udev->autoresume_disabled;    /* Setting the flags without calling usb_pm_lock is a subject to     * races, but who cares...     */    if (len == sizeof on_string - 1 &&            strncmp(buf, on_string, len) == 0) {        udev->autosuspend_disabled = 1;        udev->autoresume_disabled = 0;        rc = usb_external_resume_device(udev);    } else if (len == sizeof auto_string - 1 &&               strncmp(buf, auto_string, len) == 0) {        udev->autosuspend_disabled = 0;        udev->autoresume_disabled = 0;        rc = usb_external_resume_device(udev);    } else if (len == sizeof suspend_string - 1 &&               strncmp(buf, suspend_string, len) == 0) {        udev->autosuspend_disabled = 0;        udev->autoresume_disabled = 1;        rc = usb_external_suspend_device(udev, PMSG_SUSPEND);    } else        rc = -EINVAL;    if (rc) {        udev->autosuspend_disabled = old_autosuspend_disabled;        udev->autoresume_disabled = old_autoresume_disabled;    }    usb_unlock_device(udev);    return (rc < 0 ? rc : count);}
开发者ID:ECRS,项目名称:Asus-RT-N16,代码行数:49,


示例2: bMaxPower_show

static ssize_t bMaxPower_show(struct device *dev,		struct device_attribute *attr, char *buf){	struct usb_device *udev;	struct usb_host_config *actconfig;	ssize_t rc = 0;	udev = to_usb_device(dev);	usb_lock_device(udev);	actconfig = udev->actconfig;	if (actconfig)		rc = sprintf(buf, "%dmA/n", usb_get_max_power(udev, actconfig));	usb_unlock_device(udev);	return rc;}
开发者ID:Codefollows,项目名称:ps4-linux,代码行数:15,


示例3: mts_scsi_host_reset

static int mts_scsi_host_reset(struct scsi_cmnd *srb){	struct mts_desc* desc = (struct mts_desc*)(srb->device->host->hostdata[0]);	int result;	MTS_DEBUG_GOT_HERE();	mts_debug_dump(desc);	result = usb_lock_device_for_reset(desc->usb_dev, desc->usb_intf);	if (result == 0) {		result = usb_reset_device(desc->usb_dev);		usb_unlock_device(desc->usb_dev);	}	return result ? FAILED : SUCCESS;}
开发者ID:ANFS,项目名称:ANFS-kernel,代码行数:15,


示例4: configuration_show

static ssize_t configuration_show(struct device *dev,		struct device_attribute *attr, char *buf){	struct usb_device *udev;	struct usb_host_config *actconfig;	ssize_t rc = 0;	udev = to_usb_device(dev);	usb_lock_device(udev);	actconfig = udev->actconfig;	if (actconfig && actconfig->string)		rc = sprintf(buf, "%s/n", actconfig->string);	usb_unlock_device(udev);	return rc;}
开发者ID:Codefollows,项目名称:ps4-linux,代码行数:15,


示例5: xmm_power_l2_resume_work

/* Do the work for CP initiated L2->L0 */static void xmm_power_l2_resume_work(struct work_struct *work){	struct usb_interface *intf;	pr_debug("%s {/n", __func__);	if (!usbdev)		return;	usb_lock_device(usbdev);	intf = usb_ifnum_to_if(usbdev, 0);	if (usb_autopm_get_interface(intf) == 0)		usb_autopm_put_interface(intf);	usb_unlock_device(usbdev);	pr_debug("} %s/n", __func__);}
开发者ID:Ntemis,项目名称:LG_X3_P880_v20a,代码行数:17,


示例6: avoid_reset_quirk_store

static ssize_t avoid_reset_quirk_store(struct device *dev,				      struct device_attribute *attr,				      const char *buf, size_t count){	struct usb_device	*udev = to_usb_device(dev);	int			val;	if (sscanf(buf, "%d", &val) != 1 || val < 0 || val > 1)		return -EINVAL;	usb_lock_device(udev);	if (val)		udev->quirks |= USB_QUIRK_RESET;	else		udev->quirks &= ~USB_QUIRK_RESET;	usb_unlock_device(udev);	return count;}
开发者ID:Codefollows,项目名称:ps4-linux,代码行数:17,


示例7: usb3_hardware_lpm_show

static ssize_t usb3_hardware_lpm_show(struct device *dev,				      struct device_attribute *attr, char *buf){	struct usb_device *udev = to_usb_device(dev);	const char *p;	usb_lock_device(udev);	if (udev->usb3_lpm_enabled)		p = "enabled";	else		p = "disabled";	usb_unlock_device(udev);	return sprintf(buf, "%s/n", p);}
开发者ID:Codefollows,项目名称:ps4-linux,代码行数:17,


示例8: persist_store

static ssize_t persist_store(struct device *dev, struct device_attribute *attr,			     const char *buf, size_t count){	struct usb_device *udev = to_usb_device(dev);	int value;	/* Hubs are always enabled for USB_PERSIST */	if (udev->descriptor.bDeviceClass == USB_CLASS_HUB)		return -EPERM;	if (sscanf(buf, "%d", &value) != 1)		return -EINVAL;	usb_lock_device(udev);	udev->persist_enabled = !!value;	usb_unlock_device(udev);	return count;}
开发者ID:Codefollows,项目名称:ps4-linux,代码行数:18,


示例9: remove_store

/* "Safely remove a device" */static ssize_t remove_store(struct device *dev, struct device_attribute *attr,			    const char *buf, size_t count){	struct usb_device *udev = to_usb_device(dev);	int rc = 0;	usb_lock_device(udev);	if (udev->state != USB_STATE_NOTATTACHED) {		/* To avoid races, first unconfigure and then remove */		usb_set_configuration(udev, -1);		rc = usb_remove_device(udev);	}	if (rc == 0)		rc = count;	usb_unlock_device(udev);	return rc;}
开发者ID:Anjali05,项目名称:linux,代码行数:19,


示例10: usb3_hardware_lpm_u2_show

static ssize_t usb3_hardware_lpm_u2_show(struct device *dev,				      struct device_attribute *attr, char *buf){	struct usb_device *udev = to_usb_device(dev);	const char *p;	int rc;	rc = usb_lock_device_interruptible(udev);	if (rc < 0)		return -EINTR;	if (udev->usb3_lpm_u2_enabled)		p = "enabled";	else		p = "disabled";	usb_unlock_device(udev);	return sprintf(buf, "%s/n", p);}
开发者ID:Anjali05,项目名称:linux,代码行数:20,


示例11: hid_reset

/* Workqueue routine to reset the device or clear a halt */static void hid_reset(struct work_struct *work){	struct usbhid_device *usbhid =		container_of(work, struct usbhid_device, reset_work);	struct hid_device *hid = usbhid->hid;	int rc = 0;	if (test_bit(HID_CLEAR_HALT, &usbhid->iofl)) {		dev_dbg(&usbhid->intf->dev, "clear halt/n");		rc = usb_clear_halt(hid_to_usb_dev(hid), usbhid->urbin->pipe);		clear_bit(HID_CLEAR_HALT, &usbhid->iofl);		hid_start_in(hid);	}	else if (test_bit(HID_RESET_PENDING, &usbhid->iofl)) {		dev_dbg(&usbhid->intf->dev, "resetting device/n");		rc = usb_lock_device_for_reset(hid_to_usb_dev(hid), usbhid->intf);		if (rc == 0) {			rc = usb_reset_device(hid_to_usb_dev(hid));			usb_unlock_device(hid_to_usb_dev(hid));		}		clear_bit(HID_RESET_PENDING, &usbhid->iofl);	}	switch (rc) {	case 0:		if (!test_bit(HID_IN_RUNNING, &usbhid->iofl))			hid_io_error(hid);		break;	default:		hid_err(hid, "can't reset device, %s-%s/input%d, status %d/n",			hid_to_usb_dev(hid)->bus->bus_name,			hid_to_usb_dev(hid)->devpath,			usbhid->ifnum, rc);		/* FALLTHROUGH */	case -EHOSTUNREACH:	case -ENODEV:	case -EINTR:		break;	}}
开发者ID:onenonlycasper,项目名称:tf700t_kernel,代码行数:42,


示例12: usb_stor_port_reset

//----- usb_stor_port_reset() ---------------------int usb_stor_port_reset(struct us_data *us){	int result;	//printk("transport --- usb_stor_port_reset/n");	result = usb_lock_device_for_reset(us->pusb_dev, us->pusb_intf);	if (result < 0)		printk("unable to lock device for reset: %d/n", result);	else {		/* Were we disconnected while waiting for the lock? */		if (test_bit(US_FLIDX_DISCONNECTING, &us->dflags)) {			result = -EIO;			//printk("No reset during disconnect/n");		} else {			result = usb_reset_device(us->pusb_dev);			//printk("usb_reset_composite_device returns %d/n", result);		}		usb_unlock_device(us->pusb_dev);	}	return result;}
开发者ID:ANFS,项目名称:ANFS-kernel,代码行数:22,


示例13: m7400_wake_irq

static irqreturn_t m7400_wake_irq(int irq, void *dev_id){    struct usb_interface *intf;    switch (modem_status) {    case BBSTATE_L2:        /* Resume usb host activity. */        if (m7400_usb_device) {            usb_lock_device(m7400_usb_device);            intf = usb_ifnum_to_if(m7400_usb_device, 0);            usb_autopm_get_interface(intf);            usb_autopm_put_interface(intf);            usb_unlock_device(m7400_usb_device);        }        break;    default:        break;    }    return IRQ_HANDLED;}
开发者ID:thoniorf,项目名称:ouya_1_1-kernel,代码行数:21,


示例14: read_descriptors

static 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,


示例15: Egis_Reset_device

int Egis_Reset_device(usb_ss801u *dev) {	int lock, ret;	EgisMsg(dev->bPrintDbgMsg, KERN_INFO, "/r/n=RESET_DEVICE=/r/n");					lock = usb_lock_device_for_reset(dev->udev, dev->interface); 		if (lock < 0) {						    EgisMsg(dev->bPrintDbgMsg, KERN_ERR, "=RESET_DEVICE= locking device failed: %d/r/n", lock);		    return lock;	}							ret = usb_reset_device(dev->udev);				if (ret < 0)						    EgisMsg(dev->bPrintDbgMsg, KERN_ERR, "=RESET_DEVICE= reset device failed: %d/r/n", ret);		if (lock)						    usb_unlock_device(dev->udev);				EgisMsg(dev->bPrintDbgMsg, KERN_INFO, "/r/n=RESET_DEVICE= Finish/r/n");	return ret;}
开发者ID:boozaa,项目名称:rk3x_kernel_3.0.36,代码行数:22,


示例16: read_descriptors

static ssize_tread_descriptors(struct kobject *kobj, struct bin_attribute *attr,		char *buf, loff_t off, size_t count){	struct usb_device *udev = to_usb_device(			container_of(kobj, struct device, kobj));	size_t nleft = count;	size_t srclen, n;	usb_lock_device(udev);	/* The binary attribute begins with the device descriptor */	srclen = sizeof(struct usb_device_descriptor);	if (off < srclen) {		n = min_t(size_t, nleft, srclen - off);		memcpy(buf, off + (char *) &udev->descriptor, n);		nleft -= n;		buf += n;		off = 0;	} else {		off -= srclen;	}	/* Then follows the raw descriptor entry for the current	 * configuration (config plus subsidiary descriptors).	 */	if (udev->actconfig) {		int cfgno = udev->actconfig - udev->config;		srclen = __le16_to_cpu(udev->actconfig->desc.wTotalLength);		if (off < srclen) {			n = min_t(size_t, nleft, srclen - off);			memcpy(buf, off + udev->rawdescriptors[cfgno], n);			nleft -= n;		}	}	usb_unlock_device(udev);	return count - nleft;}
开发者ID:qwerty1023,项目名称:wive-rtnl-firmware,代码行数:39,


示例17: ar9170_usb_reset

static int ar9170_usb_reset(struct ar9170_usb *aru){	int ret, lock = (aru->intf->condition != USB_INTERFACE_BINDING);	if (lock) {		ret = usb_lock_device_for_reset(aru->udev, aru->intf);		if (ret < 0) {			dev_err(&aru->udev->dev, "unable to lock device "				"for reset (%d)./n", ret);			return ret;		}	}	ret = usb_reset_device(aru->udev);	if (lock)		usb_unlock_device(aru->udev);	/* let it rest - for a second - */	msleep(1000);	return ret;}
开发者ID:kronenpj,项目名称:samsung-s3c6410-android.2.0,代码行数:22,


示例18: set_usb2_hardware_lpm

static 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,


示例19: mutex_lock

/** * usb_find_device_by_name - find a specific usb device in the system * @name: the name of the device to find * * Returns a pointer to a struct usb_device if such a specified usb * device is present in the system currently.  The usage count of the * device will be incremented if a device is found.  Make sure to call * usb_put_dev() when the caller is finished with the device. * * If a device with the specified bus id is not found, NULL is returned. */struct usb_device *usb_find_device_by_name(const char *name){	struct list_head *buslist;	struct usb_bus *bus;	struct usb_device *dev = NULL;	mutex_lock(&usb_bus_list_lock);	for (buslist = usb_bus_list.next;	     buslist != &usb_bus_list;	     buslist = buslist->next) {		bus = container_of(buslist, struct usb_bus, bus_list);		if (!bus->root_hub)			continue;		usb_lock_device(bus->root_hub);		dev = match_device_name(bus->root_hub, name);		usb_unlock_device(bus->root_hub);		if (dev)			goto exit;	}exit:	mutex_unlock(&usb_bus_list_lock);	return dev;}
开发者ID:artynet,项目名称:linux-3.3.8,代码行数:34,


示例20: mutex_lock

/** * usb_find_device - find a specific usb device in the system * @vendor_id: the vendor id of the device to find * @product_id: the product id of the device to find * * Returns a pointer to a struct usb_device if such a specified usb * device is present in the system currently.  The usage count of the * device will be incremented if a device is found.  Make sure to call * usb_put_dev() when the caller is finished with the device. * * If a device with the specified vendor and product id is not found, * NULL is returned. */struct usb_device *usb_find_device(u16 vendor_id, u16 product_id){	struct list_head *buslist;	struct usb_bus *bus;	struct usb_device *dev = NULL;	mutex_lock(&usb_bus_list_lock);	for (buslist = usb_bus_list.next;	     buslist != &usb_bus_list;	     buslist = buslist->next) {		bus = container_of(buslist, struct usb_bus, bus_list);		if (!bus->root_hub)			continue;		usb_lock_device(bus->root_hub);		dev = match_device(bus->root_hub, vendor_id, product_id);		usb_unlock_device(bus->root_hub);		if (dev)			goto exit;	}exit:	mutex_unlock(&usb_bus_list_lock);	return dev;}
开发者ID:vovan888,项目名称:p750-kernel,代码行数:36,


示例21: usb_stor_port_reset

/* Issue a USB port reset to the device.  The caller must not hold * us->dev_mutex. */int usb_stor_port_reset(struct us_data *us){	int result, rc_lock;	result = rc_lock =		usb_lock_device_for_reset(us->pusb_dev, us->pusb_intf);	if (result < 0)		US_DEBUGP("unable to lock device for reset: %d/n", result);	else {		/* Were we disconnected while waiting for the lock? */		if (test_bit(US_FLIDX_DISCONNECTING, &us->dflags)) {			result = -EIO;			US_DEBUGP("No reset during disconnect/n");		} else {			result = usb_reset_device(us->pusb_dev);			US_DEBUGP("usb_reset_device returns %d/n",					result);		}		if (rc_lock)			usb_unlock_device(us->pusb_dev);	}	return result;}
开发者ID:deepikateriar,项目名称:Onlive-Source-Backup,代码行数:26,


示例22: tweak_reset_device_cmd

static int tweak_reset_device_cmd(struct urb *urb){	struct usb_ctrlrequest *req;	__u16 value;	__u16 index;	int ret;	req = (struct usb_ctrlrequest *) urb->setup_packet;	value = le16_to_cpu(req->wValue);	index = le16_to_cpu(req->wIndex);#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,30)	uinfo("reset_device (port %d) to %s/n", index, urb->dev->dev.bus_id);#else	uinfo("reset_device (port %d) to %s/n", index, dev_name(&urb->dev->dev));#endif	/* all interfaces should be owned by usbip driver, so just reset it. */	ret = usb_lock_device_for_reset(urb->dev, NULL);	if (ret < 0) {		uerr("lock for reset/n");		return ret;	}	/* try to reset the device */#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,27)    ret = usb_reset_composite_device(urb->dev, NULL);#else	ret = usb_reset_device(urb->dev);#endif	if (ret < 0)		uerr("device reset/n");	usb_unlock_device(urb->dev);	return ret;}
开发者ID:wl500g,项目名称:usbip-no-glib,代码行数:37,


示例23: ohci_hub_status_data

static intohci_hub_status_data (struct usb_hcd *hcd, char *buf){	struct ohci_hcd	*ohci = hcd_to_ohci (hcd);	int		ports, i, changed = 0, length = 1;	int		can_suspend = hcd->can_wakeup;	unsigned long	flags;	spin_lock_irqsave (&ohci->lock, flags);	// hack by cfyeh for usb suspend/resume	if(usb_ehci_suspend_flag == 1)	{		can_suspend = 0;		goto done;	}	/* handle autosuspended root:  finish resuming before	 * letting khubd or root hub timer see state changes.	 */	if ((ohci->hc_control & OHCI_CTRL_HCFS) != OHCI_USB_OPER			|| !HC_IS_RUNNING(hcd->state)) {		can_suspend = 0;		goto done;	}	ports = roothub_a (ohci) & RH_A_NDP; 	if (ports > MAX_ROOT_PORTS) {		ohci_err (ohci, "bogus NDP=%d, rereads as NDP=%d/n", ports,			  ohci_readl (ohci, &ohci->regs->roothub.a) & RH_A_NDP);		/* retry later; "should not happen" */		goto done;	}	/* init status */	if (roothub_status (ohci) & (RH_HS_LPSC | RH_HS_OCIC))		buf [0] = changed = 1;	else		buf [0] = 0;	if (ports > 7) {		buf [1] = 0;		length++;	}	/* look at each port */	for (i = 0; i < ports; i++) {		u32	status = roothub_portstatus (ohci, i);		if (status & (RH_PS_CSC | RH_PS_PESC | RH_PS_PSSC				| RH_PS_OCIC | RH_PS_PRSC)) {			changed = 1;			if (i < 7)			    buf [0] |= 1 << (i + 1);			else			    buf [1] |= 1 << (i - 7);			continue;		}		/* can suspend if no ports are enabled; or if all all		 * enabled ports are suspended AND remote wakeup is on.		 */		if (!(status & RH_PS_CCS))			continue;		if ((status & RH_PS_PSS) && hcd->remote_wakeup)			continue;		can_suspend = 0;	}done:	spin_unlock_irqrestore (&ohci->lock, flags);#if     defined(CONFIG_PM) || defined(CONFIG_REALTEK_VENUS_USB) //cfyeh+ 2005/11/07	/* save power by suspending idle root hubs;	 * INTR_RD wakes us when there's work	 * NOTE: if we can do this, we don't need a root hub timer!	 */	if (can_suspend			&& !changed			&& !ohci->ed_rm_list			&& ((OHCI_CTRL_HCFS | OHCI_SCHED_ENABLES)					& ohci->hc_control)				== OHCI_USB_OPER			&& time_after (jiffies, ohci->next_statechange)			&& usb_trylock_device (hcd->self.root_hub)			) {		ohci_vdbg (ohci, "autosuspend/n");		(void) ohci_hub_suspend (hcd);		hcd->state = HC_STATE_RUNNING;		usb_unlock_device (hcd->self.root_hub);	}#endif	return changed ? length : 0;}
开发者ID:OpenHMR,项目名称:Open-HMR600,代码行数:93,


示例24: ohci_hub_status_data

static intohci_hub_status_data (struct usb_hcd *hcd, char *buf){	struct ohci_hcd	*ohci = hcd_to_ohci (hcd);	int		i, changed = 0, length = 1;	int		can_suspend;	unsigned long	flags;	can_suspend = device_may_wakeup(&hcd->self.root_hub->dev);	spin_lock_irqsave (&ohci->lock, flags);	/* handle autosuspended root:  finish resuming before	 * letting khubd or root hub timer see state changes.	 */	if (unlikely((ohci->hc_control & OHCI_CTRL_HCFS) != OHCI_USB_OPER		     || !HC_IS_RUNNING(hcd->state))) {		can_suspend = 0;		goto done;	}	/* undocumented erratum seen on at least rev D */	if ((ohci->flags & OHCI_QUIRK_AMD756)			&& (roothub_a (ohci) & RH_A_NDP) > MAX_ROOT_PORTS) {		ohci_warn (ohci, "bogus NDP, rereads as NDP=%d/n",			  ohci_readl (ohci, &ohci->regs->roothub.a) & RH_A_NDP);		/* retry later; "should not happen" */		goto done;	}	/* init status */	if (roothub_status (ohci) & (RH_HS_LPSC | RH_HS_OCIC))		buf [0] = changed = 1;	else		buf [0] = 0;	if (ohci->num_ports > 7) {		buf [1] = 0;		length++;	}	/* look at each port */	for (i = 0; i < ohci->num_ports; i++) {		u32	status = roothub_portstatus (ohci, i);		/* can't autosuspend with active ports */		if ((status & RH_PS_PES) && !(status & RH_PS_PSS))			can_suspend = 0;		if (status & (RH_PS_CSC | RH_PS_PESC | RH_PS_PSSC				| RH_PS_OCIC | RH_PS_PRSC)) {			changed = 1;			if (i < 7)			    buf [0] |= 1 << (i + 1);			else			    buf [1] |= 1 << (i - 7);			continue;		}	}	/* after root hub changes, stop polling after debouncing	 * for a while and maybe kicking in autosuspend	 */	if (changed) {		ohci->next_statechange = jiffies + STATECHANGE_DELAY;		can_suspend = 0;	} else if (time_before (jiffies, ohci->next_statechange)) {		can_suspend = 0;	} else {#ifdef	CONFIG_PM		can_suspend = can_suspend			&& !ohci->ed_rm_list			&& ((OHCI_CTRL_HCFS | OHCI_SCHED_ENABLES)					& ohci->hc_control)				== OHCI_USB_OPER;#endif		if (hcd->uses_new_polling) {			hcd->poll_rh = 0;			/* use INTR_RHSC iff INTR_RD won't apply */			if (!can_suspend)				ohci_writel (ohci, OHCI_INTR_RHSC,						&ohci->regs->intrenable);		}	}done:	spin_unlock_irqrestore (&ohci->lock, flags);#ifdef	CONFIG_PM	/* save power by autosuspending idle root hubs;	 * INTR_RD wakes us when there's work	 */	if (can_suspend && usb_trylock_device (hcd->self.root_hub) == 0) {		ohci_vdbg (ohci, "autosuspend/n");		(void) ohci_bus_suspend (hcd);		usb_unlock_device (hcd->self.root_hub);	}#endif	return changed ? length : 0;}
开发者ID:mrtos,项目名称:Logitech-Revue,代码行数:99,


示例25: woal_enter_usb_suspend

/**  *  @brief This function makes USB device to suspend. *   *  @param handle  A pointer to moal_handle structure * *  @return             0 --success, otherwise fail */intwoal_enter_usb_suspend(moal_handle * handle){#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,24)#ifdef CONFIG_PM    struct usb_device *udev = ((struct usb_card_rec *) (handle->card))->udev;#endif /* CONFIG_PM */#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,34)    struct usb_interface *intf = ((struct usb_card_rec *) (handle->card))->intf;#endif /* < 2.6.34 */#endif /* >= 2.6.24 */    ENTER();    if (handle->is_suspended == MTRUE) {        PRINTM(MERROR, "Device already suspended/n");        LEAVE();        return -EFAULT;    }    handle->suspend_wait_q_woken = MFALSE;#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,24)#ifdef CONFIG_PM    /* Enter into USB suspend */    usb_lock_device(udev);#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,38)    udev->autosuspend_delay = 0;        /* Autosuspend delay in jiffies */#else    pm_runtime_set_autosuspend_delay(&udev->dev, 0);    /* Autosuspend delay in                                                            jiffies */#endif /* < 2.6.38 */#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,34)    udev->autosuspend_disabled = 0;     /* /sys/bus/usb/devices/.../power/level                                            < auto */#endif /* < 2.6.34 */#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,33)    udev->autoresume_disabled = 0;#endif /* < 2.6.33 */    usb_unlock_device(udev);#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,34)#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,32)    intf->pm_usage_cnt = 1;#else    atomic_set(&intf->pm_usage_cnt, 1);#endif /* < 2.6.32 */    usb_autopm_put_interface(intf);#else    usb_lock_device(udev);    atomic_set(&udev->dev.power.usage_count, 1);    usb_enable_autosuspend(udev);    usb_unlock_device(udev);#endif /* < 2.6.34 */#endif /* >= 2.6.24 */#endif /* CONFIG_PM */	//lxy    /* Wait for suspend to complete */    wait_event_interruptible(handle->suspend_wait_q,                             handle->suspend_wait_q_woken);    LEAVE();    return 0;}
开发者ID:lshw,项目名称:loongson1-linux-3.0,代码行数:70,



注:本文中的usb_unlock_device函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


C++ usb_write函数代码示例
C++ usb_unanchor_urb函数代码示例
万事OK自学网:51自学网_软件自学网_CAD自学网自学excel、自学PS、自学CAD、自学C语言、自学css3实例,是一个通过网络自主学习工作技能的自学平台,网友喜欢的软件自学网站。