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

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

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

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

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

示例1: acm_tty_open

static int acm_tty_open(struct tty_struct *tty, struct file *filp){	struct acm *acm;	int rv = -EINVAL;	int i;	dbg("Entering acm_tty_open.");	mutex_lock(&open_mutex);	acm = acm_table[tty->index];	if (!acm || !acm->dev)		goto err_out;	else		rv = 0;	set_bit(TTY_NO_WRITE_SPLIT, &tty->flags);	tty->driver_data = acm;	acm->tty = tty;	/* force low_latency on so that our tty_push actually forces the data through,	   otherwise it is scheduled, and with high data rates data can get lost. */	tty->low_latency = 1;	if (usb_autopm_get_interface(acm->control) < 0)		goto early_bail;	else		acm->control->needs_remote_wakeup = 1;	mutex_lock(&acm->mutex);	if (acm->used++) {		usb_autopm_put_interface(acm->control);		goto done;        }	acm->ctrlurb->dev = acm->dev;	if (usb_submit_urb(acm->ctrlurb, GFP_KERNEL)) {		dbg("usb_submit_urb(ctrl irq) failed");		goto bail_out;	}	if (0 > acm_set_control(acm, acm->ctrlout = ACM_CTRL_DTR | ACM_CTRL_RTS) &&	    (acm->ctrl_caps & USB_CDC_CAP_LINE))		goto full_bailout;	usb_autopm_put_interface(acm->control);	INIT_LIST_HEAD(&acm->spare_read_urbs);	INIT_LIST_HEAD(&acm->spare_read_bufs);	INIT_LIST_HEAD(&acm->filled_read_bufs);	for (i = 0; i < acm->rx_buflimit; i++) {		list_add(&(acm->ru[i].list), &acm->spare_read_urbs);	}	for (i = 0; i < acm->rx_buflimit; i++) {		list_add(&(acm->rb[i].list), &acm->spare_read_bufs);	}	acm->throttle = 0;	tasklet_schedule(&acm->urb_task);done:	mutex_unlock(&acm->mutex);err_out:	mutex_unlock(&open_mutex);	return rv;full_bailout:	usb_kill_urb(acm->ctrlurb);bail_out:	usb_autopm_put_interface(acm->control);	acm->used--;	mutex_unlock(&acm->mutex);early_bail:	mutex_unlock(&open_mutex);	return -EIO;}
开发者ID:masbog,项目名称:iphonelinux-kernel,代码行数:76,


示例2: usbnet_open

int usbnet_open (struct net_device *net){	struct usbnet		*dev = netdev_priv(net);	int			retval;	struct driver_info	*info = dev->driver_info;	if ((retval = usb_autopm_get_interface(dev->intf)) < 0) {		netif_info(dev, ifup, dev->net,			   "resumption fail (%d) usbnet usb-%s-%s, %s/n",			   retval,			   dev->udev->bus->bus_name,			   dev->udev->devpath,			   info->description);		goto done_nopm;	}	// put into "known safe" state	if (info->reset && (retval = info->reset (dev)) < 0) {		netif_info(dev, ifup, dev->net,			   "open reset fail (%d) usbnet usb-%s-%s, %s/n",			   retval,			   dev->udev->bus->bus_name,			   dev->udev->devpath,			   info->description);		goto done;	}	// insist peer be connected	if (info->check_connect && (retval = info->check_connect (dev)) < 0) {		netif_dbg(dev, ifup, dev->net, "can't open; %d/n", retval);		goto done;	}	/* start any status interrupt transfer */	if (dev->interrupt) {		retval = usb_submit_urb (dev->interrupt, GFP_KERNEL);		if (retval < 0) {			netif_err(dev, ifup, dev->net,				  "intr submit %d/n", retval);			goto done;		}	}	set_bit(EVENT_DEV_OPEN, &dev->flags);	netif_start_queue (net);	netif_info(dev, ifup, dev->net,		   "open: enable queueing (rx %d, tx %d) mtu %d %s framing/n",		   (int)RX_QLEN(dev), (int)TX_QLEN(dev),		   dev->net->mtu,		   (dev->driver_info->flags & FLAG_FRAMING_NC) ? "NetChip" :		   (dev->driver_info->flags & FLAG_FRAMING_GL) ? "GeneSys" :		   (dev->driver_info->flags & FLAG_FRAMING_Z) ? "Zaurus" :		   (dev->driver_info->flags & FLAG_FRAMING_RN) ? "RNDIS" :		   (dev->driver_info->flags & FLAG_FRAMING_AX) ? "ASIX" :		   "simple");	// delay posting reads until we're fully open	queue_work(usbnet_wq, &dev->bh_w);	if (info->manage_power) {		retval = info->manage_power(dev, 1);		if (retval < 0)			goto done;		usb_autopm_put_interface(dev->intf);	}	return retval;done:	usb_autopm_put_interface(dev->intf);done_nopm:	return retval;}
开发者ID:android-armv7a-belalang-tempur,项目名称:gp-peak-kernel,代码行数:71,


示例3: __i2400mu_send_barker

/* * Sends a barker buffer to the device * * This helper will allocate a kmalloced buffer and use it to transmit * (then free it). Reason for this is that other arches cannot use * stack/vmalloc/text areas for DMA transfers. * * Error recovery here is simpler: anything is considered a hard error * and will move the reset code to use a last-resort bus-based reset. */staticint __i2400mu_send_barker(struct i2400mu *i2400mu,			  const __le32 *barker,			  size_t barker_size,			  unsigned endpoint){	struct usb_endpoint_descriptor *epd = NULL;	int pipe, actual_len, ret;	struct device *dev = &i2400mu->usb_iface->dev;	void *buffer;	int do_autopm = 1;	ret = usb_autopm_get_interface(i2400mu->usb_iface);	if (ret < 0) {		dev_err(dev, "RESET: can't get autopm: %d/n", ret);		do_autopm = 0;	}	ret = -ENOMEM;	buffer = kmalloc(barker_size, GFP_KERNEL);	if (buffer == NULL)		goto error_kzalloc;	epd = usb_get_epd(i2400mu->usb_iface, endpoint);	pipe = usb_sndbulkpipe(i2400mu->usb_dev, epd->bEndpointAddress);	memcpy(buffer, barker, barker_size);retry:	ret = usb_bulk_msg(i2400mu->usb_dev, pipe, buffer, barker_size,			   &actual_len, 200);	switch (ret) {	case 0:		if (actual_len != barker_size) {	/* Too short? drop it */			dev_err(dev, "E: %s: short write (%d B vs %zu "				"expected)/n",				__func__, actual_len, barker_size);			ret = -EIO;		}		break;	case -EPIPE:		/*		 * Stall -- maybe the device is choking with our		 * requests. Clear it and give it some time. If they		 * happen to often, it might be another symptom, so we		 * reset.		 *		 * No error handling for usb_clear_halt(0; if it		 * works, the retry works; if it fails, this switch		 * does the error handling for us.		 */		if (edc_inc(&i2400mu->urb_edc,			    10 * EDC_MAX_ERRORS, EDC_ERROR_TIMEFRAME)) {			dev_err(dev, "E: %s: too many stalls in "				"URB; resetting device/n", __func__);			usb_queue_reset_device(i2400mu->usb_iface);			/* fallthrough */		} else {			usb_clear_halt(i2400mu->usb_dev, pipe);			msleep(10);	/* give the device some time */			goto retry;		}	case -EINVAL:			/* while removing driver */	case -ENODEV:			/* dev disconnect ... */	case -ENOENT:			/* just ignore it */	case -ESHUTDOWN:		/* and exit */	case -ECONNRESET:		ret = -ESHUTDOWN;		break;	default:			/* Some error? */		if (edc_inc(&i2400mu->urb_edc,			    EDC_MAX_ERRORS, EDC_ERROR_TIMEFRAME)) {			dev_err(dev, "E: %s: maximum errors in URB "				"exceeded; resetting device/n",				__func__);			usb_queue_reset_device(i2400mu->usb_iface);		} else {			dev_warn(dev, "W: %s: cannot send URB: %d/n",				 __func__, ret);			goto retry;		}	}	kfree(buffer);error_kzalloc:	if (do_autopm)		usb_autopm_put_interface(i2400mu->usb_iface);	return ret;}
开发者ID:0xroot,项目名称:Blackphone-BP1-Kernel,代码行数:94,


示例4: rtusb_fast_probe

int rtusb_fast_probe(VOID *handle, VOID **ppAd, struct usb_interface *intf){	VOID *pAd = *ppAd;	VOID *pCookie = NULL;	struct net_device *net_dev;#if (defined(WOW_SUPPORT) && defined(RTMP_MAC_USB)) || defined(NEW_WOW_SUPPORT)	UCHAR WOWRun;#endif /* (defined(WOW_SUPPORT) && defined(RTMP_MAC_USB)) || defined(NEW_WOW_SUPPORT) */#ifdef USB_SUPPORT_SELECTIVE_SUSPEND	INT pm_usage_cnt; #endif /* USB_SUPPORT_SELECTIVE_SUSPEND */	struct usb_device *usb_dev = NULL;		pCookie = RTMPCheckOsCookie(handle, &pAd);	if (pCookie == NULL)		return NDIS_STATUS_FAILURE;	usb_dev = ((POS_COOKIE)pCookie)->pUsb_Dev;	if (USBDevConfigInit(usb_dev, intf, pAd) == FALSE)	{		RTMPFreeAdapter(pAd);		return NDIS_STATUS_FAILURE;	}			RTMP_DRIVER_USB_INIT(pAd, usb_dev, 0);	/* netdevice-related structure set-up */	netdev_sysfs_reinit(&pAd, usb_dev);	if (RTMP_DRIVER_IOCTL_SANITY_CHECK(pAd, NULL) != NDIS_STATUS_SUCCESS)	{		DBGPRINT(RT_DEBUG_ERROR, ("Driver is not init, ignore %s/n", __func__));		return NDIS_STATUS_SUCCESS;	} #ifdef USB_SUPPORT_SELECTIVE_SUSPEND#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,32)	pm_usage_cnt = atomic_read(&intf->pm_usage_cnt);	#else	pm_usage_cnt = intf->pm_usage_cnt;#endif	if(pm_usage_cnt  <= 0)		usb_autopm_get_interface(intf);				RTMP_DRIVER_ADAPTER_RT28XX_CMD_RADIO_ON(pAd);	DBGPRINT(RT_DEBUG_ERROR, ("%s(): <=autosuspend/n", __func__));		return NDIS_STATUS_SUCCESS;#endif /* USB_SUPPORT_SELECTIVE_SUSPEND */			#if (defined(WOW_SUPPORT) && defined(RTMP_MAC_USB)) || defined(NEW_WOW_SUPPORT)	RTMP_DRIVER_ADAPTER_RT28XX_WOW_RUNSTATUS(pAd, &WOWRun);	if (WOWRun)		RTMP_DRIVER_ADAPTER_RT28XX_WOW_DISABLE(pAd);	else#endif /* (defined(WOW_SUPPORT) && defined(RTMP_MAC_USB)) || defined(NEW_WOW_SUPPORT) */	{		DBGPRINT(RT_DEBUG_ERROR, ("%s :radio_on /n", __func__));		RTMP_DRIVER_ADAPTER_RT28XX_CMD_RADIO_ON(pAd);		RTMP_DRIVER_NET_DEV_GET(pAd, &net_dev);		netif_device_attach(net_dev);		netif_start_queue(net_dev);		netif_carrier_on(net_dev);		netif_wake_queue(net_dev);	}	RTMP_DRIVER_USB_RESUME(pAd);	DBGPRINT(RT_DEBUG_TRACE, ("<=%s()/n", __func__));	return NDIS_STATUS_SUCCESS;}
开发者ID:vm3vuy,项目名称:my-local-repository,代码行数:72,


示例5: rtusb_resume

static int rtusb_resume(struct usb_interface *intf){	struct net_device *net_dev;#if (defined(WOW_SUPPORT) && defined(RTMP_MAC_USB)) || defined(NEW_WOW_SUPPORT)    UCHAR WOWRun;#endif /* (defined(WOW_SUPPORT) && defined(RTMP_MAC_USB)) || defined(NEW_WOW_SUPPORT) */#ifdef USB_SUPPORT_SELECTIVE_SUSPEND	INT	pm_usage_cnt;	UCHAR Flag;#endif /* USB_SUPPORT_SELECTIVE_SUSPEND */	VOID *pAd = usb_get_intfdata(intf);	DBGPRINT(RT_DEBUG_TRACE, ("%s()=>/n", __func__));	if (!RTMP_TEST_FLAG((PRTMP_ADAPTER)pAd, fRTMP_ADAPTER_START_UP))		return 0;#ifdef RESUME_WITH_USB_RESET_SUPPORT	if (last_pm_cnt != os_get_sync_anchor())	{		DBGPRINT(RT_DEBUG_ERROR, ("real suspend before/n"));		return 0;	}#endif /* RESUME_WITH_USB_RESET_SUPPORT */#ifdef USB_SUPPORT_SELECTIVE_SUSPEND#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,32)	pm_usage_cnt = atomic_read(&intf->pm_usage_cnt);	#else	pm_usage_cnt = intf->pm_usage_cnt;#endif	if(pm_usage_cnt  <= 0)		usb_autopm_get_interface(intf);		RTMP_DRIVER_ADAPTER_RT28XX_CMD_RADIO_ON(pAd);	DBGPRINT(RT_DEBUG_ERROR, ("%s():=>autosuspend/n", __func__));	return 0;#endif /* USB_SUPPORT_SELECTIVE_SUSPEND */#if (defined(WOW_SUPPORT) && defined(RTMP_MAC_USB)) || defined(NEW_WOW_SUPPORT)	RTMP_DRIVER_ADAPTER_RT28XX_WOW_RUNSTATUS(pAd, &WOWRun);	if (WOWRun)		RTMP_DRIVER_ADAPTER_RT28XX_WOW_DISABLE(pAd);	else#endif /* (defined(WOW_SUPPORT) && defined(RTMP_MAC_USB)) || defined(NEW_WOW_SUPPORT) */	{		DBGPRINT(RT_DEBUG_ERROR, ("%s :radio_on /n", __func__));		RTMP_DRIVER_ADAPTER_RT28XX_CMD_RADIO_ON(pAd);		RTMP_DRIVER_NET_DEV_GET(pAd, &net_dev);		netif_device_attach(net_dev);		netif_start_queue(net_dev);		netif_carrier_on(net_dev);		netif_wake_queue(net_dev);	}	RTMP_DRIVER_USB_RESUME(pAd);	DBGPRINT(RT_DEBUG_TRACE, ("<=%s()/n", __func__));	return 0;}
开发者ID:vm3vuy,项目名称:my-local-repository,代码行数:61,


示例6: rt2870_probe

static int rt2870_probe(	IN struct usb_interface *intf,	IN struct usb_device *usb_dev,	IN const USB_DEVICE_ID *dev_id,	IN VOID **ppAd){	struct  net_device		*net_dev = NULL;	VOID       				*pAd = (VOID *) NULL;	int                 	status, rv;	PVOID					handle;	RTMP_OS_NETDEV_OP_HOOK	netDevHook;	ULONG					OpMode;#ifdef CONFIG_PM#ifdef USB_SUPPORT_SELECTIVE_SUSPEND/*	int 		pm_usage_cnt; */	int		 res =1 ; #endif /* USB_SUPPORT_SELECTIVE_SUSPEND */#endif /* CONFIG_PM */			DBGPRINT(RT_DEBUG_TRACE, ("===>rt2870_probe()!/n"));	#ifdef CONFIG_PM#ifdef USB_SUPPORT_SELECTIVE_SUSPEND        res = usb_autopm_get_interface(intf);	if (res)	{			DBGPRINT(RT_DEBUG_ERROR, ("rt2870_probe autopm_resume fail ------/n"));		     return -EIO;	}#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,32)	atomic_set(&intf->pm_usage_cnt, 1);	 printk(" rt2870_probe ====> pm_usage_cnt %d /n", atomic_read(&intf->pm_usage_cnt));#else         intf->pm_usage_cnt = 1;	 printk(" rt2870_probe ====> pm_usage_cnt %d /n", intf->pm_usage_cnt);#endif	#endif /* USB_SUPPORT_SELECTIVE_SUSPEND */#endif /* CONFIG_PM *//*RtmpDevInit============================================= */	/* Allocate RTMP_ADAPTER adapter structure *//*	handle = kmalloc(sizeof(struct os_cookie), GFP_KERNEL); */	os_alloc_mem(NULL, (UCHAR **)&handle, sizeof(struct os_cookie));	if (handle == NULL)	{		printk("rt2870_probe(): Allocate memory for os handle failed!/n");		return -ENOMEM;	}	memset(handle, 0, sizeof(struct os_cookie));	((POS_COOKIE)handle)->pUsb_Dev = usb_dev;#ifdef CONFIG_PM#ifdef USB_SUPPORT_SELECTIVE_SUSPEND	((POS_COOKIE)handle)->intf = intf;#endif /* USB_SUPPORT_SELECTIVE_SUSPEND */#endif /* CONFIG_PM */	/* set/get operators to/from DRIVER module */#ifdef OS_ABL_FUNC_SUPPORT	/* get DRIVER operations */	RtmpNetOpsInit(pRtmpDrvNetOps);	RTMP_DRV_OPS_FUNCTION(pRtmpDrvOps, pRtmpDrvNetOps, NULL, NULL);	RtmpNetOpsSet(pRtmpDrvNetOps);#endif /* OS_ABL_FUNC_SUPPORT */	rv = RTMPAllocAdapterBlock(handle, &pAd);	if (rv != NDIS_STATUS_SUCCESS) 	{/*		kfree(handle); */		os_free_mem(NULL, handle);		goto err_out;	}/*USBDevInit============================================== */	if (USBDevConfigInit(usb_dev, intf, pAd) == FALSE)		goto err_out_free_radev;	RtmpRaDevCtrlInit(pAd, RTMP_DEV_INF_USB);	/*NetDevInit============================================== */	net_dev = RtmpPhyNetDevInit(pAd, &netDevHook);	if (net_dev == NULL)		goto err_out_free_radev;		/* Here are the net_device structure with usb specific parameters. */#ifdef NATIVE_WPA_SUPPLICANT_SUPPORT	/* for supporting Network Manager.	  * Set the sysfs physical device reference for the network logical device if set prior to registration will 	  * cause a symlink during initialization.//.........这里部分代码省略.........
开发者ID:32743069,项目名称:amlogic_common_3050,代码行数:101,


示例7: InterfaceAbortIdlemode

static int InterfaceAbortIdlemode(PMINI_ADAPTER Adapter, unsigned int Pattern){	int 	status = STATUS_SUCCESS;	unsigned int value;	unsigned int chip_id ;	unsigned long timeout = 0 ,itr = 0;	int 	lenwritten = 0;	unsigned char aucAbortPattern[8]={0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF};	PS_INTERFACE_ADAPTER psInterfaceAdapter = Adapter->pvInterfaceAdapter;	//Abort Bus suspend if its already suspended	if((TRUE == psInterfaceAdapter->bSuspended) && (TRUE == Adapter->bDoSuspend))	{		status = usb_autopm_get_interface(psInterfaceAdapter->interface);		BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, IDLE_MODE, DBG_LVL_ALL,"Bus got wakeup..Aborting Idle mode... status:%d /n",status);	}	if((Adapter->ulPowerSaveMode == DEVICE_POWERSAVE_MODE_AS_MANUAL_CLOCK_GATING)									||	   (Adapter->ulPowerSaveMode == DEVICE_POWERSAVE_MODE_AS_PROTOCOL_IDLE_MODE))	{		//write the SW abort pattern.		BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, IDLE_MODE, DBG_LVL_ALL, "Writing pattern<%d> to SW_ABORT_IDLEMODE_LOC/n", Pattern);		status = wrmalt(Adapter,SW_ABORT_IDLEMODE_LOC, &Pattern, sizeof(Pattern));		if(status)		{				BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, IDLE_MODE, DBG_LVL_ALL,"WRM to Register SW_ABORT_IDLEMODE_LOC failed..");				return status;		}	}	if(Adapter->ulPowerSaveMode == DEVICE_POWERSAVE_MODE_AS_MANUAL_CLOCK_GATING)	{		value = 0x80000000;		status = wrmalt(Adapter,DEBUG_INTERRUPT_GENERATOR_REGISTOR, &value, sizeof(value));		if(status)		{			BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, IDLE_MODE, DBG_LVL_ALL,"WRM to DEBUG_INTERRUPT_GENERATOR_REGISTOR Register failed");			return status;		}	}	else if(Adapter->ulPowerSaveMode != DEVICE_POWERSAVE_MODE_AS_PROTOCOL_IDLE_MODE)	{		/*		 * Get a Interrupt Out URB and send 8 Bytes Down		 * To be Done in Thread Context.		 * Not using Asynchronous Mechanism.		 */		status = usb_interrupt_msg (psInterfaceAdapter->udev,			usb_sndintpipe(psInterfaceAdapter->udev,			psInterfaceAdapter->sIntrOut.int_out_endpointAddr),			aucAbortPattern,			8,			&lenwritten,			5000);		if(status)		{			BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, IDLE_MODE, DBG_LVL_ALL, "Sending Abort pattern down fails with status:%d../n",status);			return status;		}		else		{			BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, IDLE_MODE, DBG_LVL_ALL, "NOB Sent down :%d", lenwritten);		}		//mdelay(25);		timeout= jiffies +  msecs_to_jiffies(50) ;		while( timeout > jiffies )		{			itr++ ;			rdmalt(Adapter, CHIP_ID_REG, &chip_id, sizeof(UINT));			if(0xbece3200==(chip_id&~(0xF0)))			{				chip_id = chip_id&~(0xF0);			}			if(chip_id == Adapter->chip_id)				break;		}		if(timeout < jiffies )		{			BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, IDLE_MODE, DBG_LVL_ALL,"Not able to read chip-id even after 25 msec");		}		else		{			BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, IDLE_MODE, DBG_LVL_ALL,"Number of completed iteration to read chip-id :%lu", itr);		}		status = wrmalt(Adapter,SW_ABORT_IDLEMODE_LOC, &Pattern, sizeof(status));		if(status)		{			BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0,"WRM to Register SW_ABORT_IDLEMODE_LOC failed..");			return status;		}	}	return status;}
开发者ID:openube,项目名称:android_kernel_sony_c2305,代码行数:99,


示例8: rt2870_resume

static int rt2870_resume(	struct usb_interface *intf){	struct net_device *net_dev;	VOID *pAd = usb_get_intfdata(intf);#if (defined(WOW_SUPPORT) && defined(RTMP_MAC_USB)) || defined(NEW_WOW_SUPPORT)	UCHAR Flag;#endif /* (defined(WOW_SUPPORT) && defined(RTMP_MAC_USB)) || defined(NEW_WOW_SUPPORT) */#ifdef USB_SUPPORT_SELECTIVE_SUSPEND	INT 		pm_usage_cnt;	UCHAR Flag;#endif /* USB_SUPPORT_SELECTIVE_SUSPEND */#if (defined(WOW_SUPPORT) && defined(RTMP_MAC_USB)) || defined(NEW_WOW_SUPPORT)	RTMP_DRIVER_ADAPTER_RT28XX_WOW_STATUS(pAd, &Flag);#endif /* (defined(WOW_SUPPORT) && defined(RTMP_MAC_USB)) || defined(NEW_WOW_SUPPORT) */#ifdef USB_SUPPORT_SELECTIVE_SUSPEND#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,32)	pm_usage_cnt = atomic_read(&intf->pm_usage_cnt);	#else	pm_usage_cnt = intf->pm_usage_cnt;#endif	if(pm_usage_cnt  <= 0)		usb_autopm_get_interface(intf);	DBGPRINT(RT_DEBUG_ERROR, ("autosuspend===> rt2870_resume()/n"));	/*RTMP_CLEAR_FLAG(pAd, fRTMP_ADAPTER_SUSPEND); */	RTMP_DRIVER_ADAPTER_SUSPEND_CLEAR(pAd);#if (defined(WOW_SUPPORT) && defined(RTMP_MAC_USB)) || defined(NEW_WOW_SUPPORT)	if (Flag == FALSE)#endif /* (defined(WOW_SUPPORT) && defined(RTMP_MAC_USB)) || defined(NEW_WOW_SUPPORT) */		/*RT28xxUsbAsicRadioOn(pAd); */		RTMP_DRIVER_ADAPTER_RT28XX_USB_ASICRADIO_ON(pAd);	DBGPRINT(RT_DEBUG_ERROR, ("autosuspend<===  rt2870_resume()/n"));	return 0;#endif /* USB_SUPPORT_SELECTIVE_SUSPEND */	DBGPRINT(RT_DEBUG_TRACE, ("===> rt2870_resume()/n"));#if (defined(WOW_SUPPORT) && defined(RTMP_MAC_USB)) || defined(NEW_WOW_SUPPORT)	if (Flag == TRUE)		RTMP_DRIVER_ADAPTER_RT28XX_WOW_DISABLE(pAd);	else#endif /* (defined(WOW_SUPPORT) && defined(RTMP_MAC_USB)) || defined(NEW_WOW_SUPPORT) */	{		RTMP_DRIVER_ADAPTER_SUSPEND_CLEAR(pAd);		RTMP_DRIVER_ADAPTER_RT28XX_USB_ASICRADIO_ON(pAd);	}	DBGPRINT(RT_DEBUG_TRACE, ("<=== rt2870_resume()/n"));	return 0;}
开发者ID:YuleiXiao,项目名称:xiaomiwifi_driver,代码行数:65,


示例9: i2400mu_tx_bulk_out

/* * Synchronous write to the device * * Takes care of updating EDC counts and thus, handle device errors. */staticssize_t i2400mu_tx_bulk_out(struct i2400mu *i2400mu, void *buf, size_t buf_size){	int result;	struct device *dev = &i2400mu->usb_iface->dev;	int len;	struct usb_endpoint_descriptor *epd;	int pipe, do_autopm = 1;	result = usb_autopm_get_interface(i2400mu->usb_iface);	if (result < 0) {		dev_err(dev, "BM-CMD: can't get autopm: %d/n", result);		do_autopm = 0;	}	epd = usb_get_epd(i2400mu->usb_iface, i2400mu->endpoint_cfg.bulk_out);	pipe = usb_sndbulkpipe(i2400mu->usb_dev, epd->bEndpointAddress);retry:	result = usb_bulk_msg(i2400mu->usb_dev, pipe, buf, buf_size, &len, 200);	switch (result) {	case 0:		if (len != buf_size) {			dev_err(dev, "BM-CMD: short write (%u B vs %zu "				"expected)/n", len, buf_size);			result = -EIO;			break;		}		result = len;		break;	case -EPIPE:		/*		 * Stall -- maybe the device is choking with our		 * requests. Clear it and give it some time. If they		 * happen to often, it might be another symptom, so we		 * reset.		 *		 * No error handling for usb_clear_halt(0; if it		 * works, the retry works; if it fails, this switch		 * does the error handling for us.		 */		if (edc_inc(&i2400mu->urb_edc,			    10 * EDC_MAX_ERRORS, EDC_ERROR_TIMEFRAME)) {			dev_err(dev, "BM-CMD: too many stalls in "				"URB; resetting device/n");			usb_queue_reset_device(i2400mu->usb_iface);			/* fallthrough */		} else {			usb_clear_halt(i2400mu->usb_dev, pipe);			msleep(10);	/* give the device some time */			goto retry;		}	case -EINVAL:			/* while removing driver */	case -ENODEV:			/* dev disconnect ... */	case -ENOENT:			/* just ignore it */	case -ESHUTDOWN:		/* and exit */	case -ECONNRESET:		result = -ESHUTDOWN;		break;	case -ETIMEDOUT:			/* bah... */		break;	default:				/* any other? */		if (edc_inc(&i2400mu->urb_edc,			    EDC_MAX_ERRORS, EDC_ERROR_TIMEFRAME)) {				dev_err(dev, "BM-CMD: maximum errors in "					"URB exceeded; resetting device/n");				usb_queue_reset_device(i2400mu->usb_iface);				result = -ENODEV;				break;		}		dev_err(dev, "BM-CMD: URB error %d, retrying/n",			result);		goto retry;	}	if (do_autopm)		usb_autopm_put_interface(i2400mu->usb_iface);	return result;}
开发者ID:CSCLOG,项目名称:beaglebone,代码行数:81,


示例10: i2400mu_bus_bm_wait_for_ack

/* * Read an ack from  the notification endpoint * * @i2400m: * @_ack: pointer to where to store the read data * @ack_size: how many bytes we should read * * Returns: < 0 errno code on error; otherwise, amount of received bytes. * * Submits a notification read, appends the read data to the given ack * buffer and then repeats (until @ack_size bytes have been * received). */ssize_t i2400mu_bus_bm_wait_for_ack(struct i2400m *i2400m,				    struct i2400m_bootrom_header *_ack,				    size_t ack_size){	ssize_t result = -ENOMEM;	struct device *dev = i2400m_dev(i2400m);	struct i2400mu *i2400mu = container_of(i2400m, struct i2400mu, i2400m);	struct urb notif_urb;	void *ack = _ack;	size_t offset, len;	long val;	int do_autopm = 1;	DECLARE_COMPLETION_ONSTACK(notif_completion);	d_fnstart(8, dev, "(i2400m %p ack %p size %zu)/n",		  i2400m, ack, ack_size);	BUG_ON(_ack == i2400m->bm_ack_buf);	result = usb_autopm_get_interface(i2400mu->usb_iface);	if (result < 0) {		dev_err(dev, "BM-ACK: can't get autopm: %d/n", (int) result);		do_autopm = 0;	}	usb_init_urb(&notif_urb);	/* ready notifications */	usb_get_urb(&notif_urb);	offset = 0;	while (offset < ack_size) {		init_completion(&notif_completion);		result = i2400mu_notif_submit(i2400mu, &notif_urb,					      &notif_completion);		if (result < 0)			goto error_notif_urb_submit;		val = wait_for_completion_interruptible_timeout(			&notif_completion, HZ);		if (val == 0) {			result = -ETIMEDOUT;			usb_kill_urb(&notif_urb);	/* Timedout */			goto error_notif_wait;		}		if (val == -ERESTARTSYS) {			result = -EINTR;		/* Interrupted */			usb_kill_urb(&notif_urb);			goto error_notif_wait;		}		result = notif_urb.status;		/* How was the ack? */		switch (result) {		case 0:			break;		case -EINVAL:			/* while removing driver */		case -ENODEV:			/* dev disconnect ... */		case -ENOENT:			/* just ignore it */		case -ESHUTDOWN:		/* and exit */		case -ECONNRESET:			result = -ESHUTDOWN;			goto error_dev_gone;		default:				/* any other? */			usb_kill_urb(&notif_urb);	/* Timedout */			if (edc_inc(&i2400mu->urb_edc,				    EDC_MAX_ERRORS, EDC_ERROR_TIMEFRAME))				goto error_exceeded;			dev_err(dev, "BM-ACK: URB error %d, "				"retrying/n", notif_urb.status);			continue;	/* retry */		}		if (notif_urb.actual_length == 0) {			d_printf(6, dev, "ZLP received, retrying/n");			continue;		}		/* Got data, append it to the buffer */		len = min(ack_size - offset, (size_t) notif_urb.actual_length);		memcpy(ack + offset, i2400m->bm_ack_buf, len);		offset += len;	}	result = offset;error_notif_urb_submit:error_notif_wait:error_dev_gone:out:	if (do_autopm)		usb_autopm_put_interface(i2400mu->usb_iface);	d_fnend(8, dev, "(i2400m %p ack %p size %zu) = %ld/n",		i2400m, ack, ack_size, (long) result);	return result;error_exceeded:	dev_err(dev, "bm: maximum errors in notification URB exceeded; "		"resetting device/n");	usb_queue_reset_device(i2400mu->usb_iface);//.........这里部分代码省略.........
开发者ID:CSCLOG,项目名称:beaglebone,代码行数:101,


示例11: kevent

/* work that cannot be done in interrupt context uses keventd. * * NOTE:  with 2.5 we could do more of this using completion callbacks, * especially now that control transfers can be queued. */static voidkevent (struct work_struct *work){	struct usbnet		*dev =		container_of(work, struct usbnet, kevent);	int			status;	/* usb_clear_halt() needs a thread context */	if (test_bit (EVENT_TX_HALT, &dev->flags)) {		unlink_urbs (dev, &dev->txq);		status = usb_autopm_get_interface(dev->intf);		if (status < 0)			goto fail_pipe;		status = usb_clear_halt (dev->udev, dev->out);		usb_autopm_put_interface(dev->intf);		if (status < 0 &&		    status != -EPIPE &&		    status != -ESHUTDOWN) {			if (netif_msg_tx_err (dev))fail_pipe:				netdev_err(dev->net, "can't clear tx halt, status %d/n",					   status);		} else {			clear_bit (EVENT_TX_HALT, &dev->flags);			if (status != -ESHUTDOWN)				netif_wake_queue (dev->net);		}	}	if (test_bit (EVENT_RX_HALT, &dev->flags)) {		//HTC+++		//lock cpu perf		usbnet_lock_perf();		//queue usbnet_unlock_perf_delayed_work		usbnet_rx_len = 0;		schedule_delayed_work(&usbnet_unlock_perf_delayed_work, msecs_to_jiffies(PM_QOS_USBNET_PERF_UNLOCK_TIMER));		pr_info("%s(%d) [USBNET] EVENT_RX_HALT unlink_urbs !!!/n", __func__, __LINE__);		pr_info("%s(%d) [USBNET] dev->rxq.qlen:%d/n", __func__, __LINE__, dev->rxq.qlen);		//HTC---		unlink_urbs (dev, &dev->rxq);		status = usb_autopm_get_interface(dev->intf);		if (status < 0)			goto fail_halt;		status = usb_clear_halt (dev->udev, dev->in);		//HTC+++		pr_info("%s(%d) [USBNET] EVENT_RX_HALT usb_clear_halt:%d !!!/n", __func__, __LINE__, status);		//HTC---		usb_autopm_put_interface(dev->intf);		if (status < 0 &&		    status != -EPIPE &&		    status != -ESHUTDOWN) {			if (netif_msg_rx_err (dev))fail_halt:				netdev_err(dev->net, "can't clear rx halt, status %d/n",					   status);		} else {			//HTC+++			pr_info("%s(%d) [USBNET] clear_bit EVENT_RX_HALT !!!/n", __func__, __LINE__);			//HTC---			clear_bit (EVENT_RX_HALT, &dev->flags);			tasklet_schedule (&dev->bh);		}	}	/* tasklet could resubmit itself forever if memory is tight */	if (test_bit (EVENT_RX_MEMORY, &dev->flags)) {		struct urb	*urb = NULL;		int resched = 1;		if (netif_running (dev->net))			urb = usb_alloc_urb (0, GFP_KERNEL);		else			clear_bit (EVENT_RX_MEMORY, &dev->flags);		if (urb != NULL) {			clear_bit (EVENT_RX_MEMORY, &dev->flags);			status = usb_autopm_get_interface(dev->intf);			if (status < 0) {				usb_free_urb(urb);				goto fail_lowmem;			}			if (rx_submit (dev, urb, GFP_KERNEL) == -ENOLINK)				resched = 0;			usb_autopm_put_interface(dev->intf);fail_lowmem:			if (resched)				tasklet_schedule (&dev->bh);		}	}	if (test_bit (EVENT_LINK_RESET, &dev->flags)) {		struct driver_info	*info = dev->driver_info;//.........这里部分代码省略.........
开发者ID:Austs5,项目名称:enrc2b-kernel-BLADE,代码行数:101,


示例12: GobiUSBNetAutoPMThread

//.........这里部分代码省略.........      // Is our URB active?      spin_lock_irqsave( &pAutoPM->mActiveURBLock, activeURBflags );      // EAGAIN used to signify callback is done      if (IS_ERR( pAutoPM->mpActiveURB )       &&  PTR_ERR( pAutoPM->mpActiveURB ) == -EAGAIN )      {         pAutoPM->mpActiveURB = NULL;         // Restore IRQs so task can sleep         spin_unlock_irqrestore( &pAutoPM->mActiveURBLock, activeURBflags );                  // URB is done, decrement the Auto PM usage count         usb_autopm_put_interface( pAutoPM->mpIntf );         // Lock ActiveURB again         spin_lock_irqsave( &pAutoPM->mActiveURBLock, activeURBflags );      }      if (pAutoPM->mpActiveURB != NULL)      {         // There is already a URB active, go back to sleep         spin_unlock_irqrestore( &pAutoPM->mActiveURBLock, activeURBflags );         continue;      }            // Is there a URB waiting to be submitted?      spin_lock_irqsave( &pAutoPM->mURBListLock, URBListFlags );      if (pAutoPM->mpURBList == NULL)      {         // No more URBs to submit, go back to sleep         spin_unlock_irqrestore( &pAutoPM->mURBListLock, URBListFlags );         spin_unlock_irqrestore( &pAutoPM->mActiveURBLock, activeURBflags );         continue;      }      // Pop an element      pURBListEntry = pAutoPM->mpURBList;      pAutoPM->mpURBList = pAutoPM->mpURBList->mpNext;      atomic_dec( &pAutoPM->mURBListLen );      spin_unlock_irqrestore( &pAutoPM->mURBListLock, URBListFlags );      // Set ActiveURB      pAutoPM->mpActiveURB = pURBListEntry->mpURB;      spin_unlock_irqrestore( &pAutoPM->mActiveURBLock, activeURBflags );      // Tell autopm core we need device woken up      status = usb_autopm_get_interface( pAutoPM->mpIntf );#if (LINUX_VERSION_CODE > KERNEL_VERSION( 2,6,23 ))      if (status < 0)      {         DBG( "unable to autoresume interface: %d/n", status );         // likely caused by device going from autosuspend -> full suspend         if (status == -EPERM)         {#if (LINUX_VERSION_CODE < KERNEL_VERSION( 2,6,33 ))            pUdev->auto_pm = 0;#endif            GobiSuspend( pAutoPM->mpIntf, PMSG_SUSPEND );         }         // Add pURBListEntry back onto pAutoPM->mpURBList         spin_lock_irqsave( &pAutoPM->mURBListLock, URBListFlags );         pURBListEntry->mpNext = pAutoPM->mpURBList;         pAutoPM->mpURBList = pURBListEntry;         atomic_inc( &pAutoPM->mURBListLen );         spin_unlock_irqrestore( &pAutoPM->mURBListLock, URBListFlags );                  spin_lock_irqsave( &pAutoPM->mActiveURBLock, activeURBflags );         pAutoPM->mpActiveURB = NULL;         spin_unlock_irqrestore( &pAutoPM->mActiveURBLock, activeURBflags );                  // Go back to sleep         continue;      }#endif      // Submit URB      status = usb_submit_urb( pAutoPM->mpActiveURB, GFP_KERNEL );      if (status < 0)      {         // Could happen for a number of reasons         DBG( "Failed to submit URB: %d.  Packet dropped/n", status );         spin_lock_irqsave( &pAutoPM->mActiveURBLock, activeURBflags );         usb_free_urb( pAutoPM->mpActiveURB );         pAutoPM->mpActiveURB = NULL;         spin_unlock_irqrestore( &pAutoPM->mActiveURBLock, activeURBflags );         usb_autopm_put_interface( pAutoPM->mpIntf );         // Loop again         complete( &pAutoPM->mThreadDoWork );      }            kfree( pURBListEntry );   }         DBG( "traffic thread exiting/n" );   pAutoPM->mpThread = NULL;   return 0;}      
开发者ID:tcdog001,项目名称:apv5sdk-v15,代码行数:101,


示例13: rausb_autopm_get_interface

int  rausb_autopm_get_interface( void *intf){	return usb_autopm_get_interface((struct usb_interface *)intf);}
开发者ID:NikhilNJ,项目名称:screenplay-dx,代码行数:4,


示例14: usbnet_open

int usbnet_open (struct net_device *net){	struct usbnet		*dev = netdev_priv(net);	int			retval;	struct driver_info	*info = dev->driver_info;	if ((retval = usb_autopm_get_interface(dev->intf)) < 0) {		if (netif_msg_ifup (dev))			devinfo (dev,				"resumption fail (%d) usbnet usb-%s-%s, %s",				retval,				dev->udev->bus->bus_name, dev->udev->devpath,			info->description);		goto done_nopm;	}	// put into "known safe" state	if (info->reset && (retval = info->reset (dev)) < 0) {		if (netif_msg_ifup (dev))			devinfo (dev,				"open reset fail (%d) usbnet usb-%s-%s, %s",				retval,				dev->udev->bus->bus_name, dev->udev->devpath,			info->description);		goto done;	}	// insist peer be connected	if (info->check_connect && (retval = info->check_connect (dev)) < 0) {		if (netif_msg_ifup (dev))			devdbg (dev, "can't open; %d", retval);		goto done;	}	/* start any status interrupt transfer */	if (dev->interrupt) {		retval = usb_submit_urb (dev->interrupt, GFP_KERNEL);		if (retval < 0) {			if (netif_msg_ifup (dev))				deverr (dev, "intr submit %d", retval);			goto done;		}	}	netif_start_queue (net);	if (netif_msg_ifup (dev)) {		char	*framing;		if (dev->driver_info->flags & FLAG_FRAMING_NC)			framing = "NetChip";		else if (dev->driver_info->flags & FLAG_FRAMING_GL)			framing = "GeneSys";		else if (dev->driver_info->flags & FLAG_FRAMING_Z)			framing = "Zaurus";		else if (dev->driver_info->flags & FLAG_FRAMING_RN)			framing = "RNDIS";		else if (dev->driver_info->flags & FLAG_FRAMING_AX)			framing = "ASIX";		else			framing = "simple";		devinfo (dev, "open: enable queueing "				"(rx %d, tx %d) mtu %d %s framing",			(int)RX_QLEN (dev), (int)TX_QLEN (dev), dev->net->mtu,			framing);	}	// delay posting reads until we're fully open	tasklet_schedule (&dev->bh);#if defined(CONFIG_ERICSSON_F3307_ENABLE)	if (info->manage_power) {		retval = info->manage_power(dev, 1);		if (retval < 0)			goto done;		usb_autopm_put_interface(dev->intf);	}#endif	return retval;done:	usb_autopm_put_interface(dev->intf);done_nopm:	return retval;}
开发者ID:marcero,项目名称:ab73kernel-Hannspad-2632,代码行数:83,


示例15: rt2870_probe

static int rt2870_probe(	struct usb_interface *intf,	struct usb_device *usb_dev,	const USB_DEVICE_ID *dev_id,	VOID **ppAd){	struct net_device *net_dev = NULL;#ifdef RESUME_WITH_USB_RESET_SUPPORT	VOID *pAd = (VOID *) gpAd;#else	VOID *pAd = (VOID *) NULL;#endif /* RESUME_WITH_USB_RESET_SUPPORT */	INT status, rv;	PVOID handle;	RTMP_OS_NETDEV_OP_HOOK netDevHook;	ULONG OpMode;#ifdef CONFIG_PM#ifdef USB_SUPPORT_SELECTIVE_SUSPEND/*	INT pm_usage_cnt; */	INT res =1 ; #endif /* USB_SUPPORT_SELECTIVE_SUSPEND */#endif /* CONFIG_PM */		DBGPRINT(RT_DEBUG_TRACE, ("===>rt2870_probe()!/n"));	#ifdef CONFIG_PM#ifdef USB_SUPPORT_SELECTIVE_SUSPEND        res = usb_autopm_get_interface(intf);	if (res)	{		DBGPRINT(RT_DEBUG_ERROR, ("rt2870_probe autopm_resume fail ------/n"));		return -EIO;	}#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,32)	atomic_set(&intf->pm_usage_cnt, 1);	 printk(" rt2870_probe ====> pm_usage_cnt %d /n", atomic_read(&intf->pm_usage_cnt));#else         intf->pm_usage_cnt = 1;	 printk(" rt2870_probe ====> pm_usage_cnt %d /n", intf->pm_usage_cnt);#endif	#endif /* USB_SUPPORT_SELECTIVE_SUSPEND */#endif /* CONFIG_PM */	os_alloc_mem(NULL, (UCHAR **)&handle, sizeof(struct os_cookie));	if (handle == NULL)	{		printk("rt2870_probe(): Allocate memory for os handle failed!/n");		return -ENOMEM;	}	memset(handle, 0, sizeof(struct os_cookie));	((POS_COOKIE)handle)->pUsb_Dev = usb_dev;#ifdef CONFIG_PM#ifdef USB_SUPPORT_SELECTIVE_SUSPEND	((POS_COOKIE)handle)->intf = intf;#endif /* USB_SUPPORT_SELECTIVE_SUSPEND */#endif /* CONFIG_PM */	/* set/get operators to/from DRIVER module */#ifdef OS_ABL_FUNC_SUPPORT	/* get DRIVER operations */	RtmpNetOpsInit(pRtmpDrvNetOps);	RTMP_DRV_OPS_FUNCTION(pRtmpDrvOps, pRtmpDrvNetOps, NULL, NULL);	RtmpNetOpsSet(pRtmpDrvNetOps);#endif /* OS_ABL_FUNC_SUPPORT */#ifdef RESUME_WITH_USB_RESET_SUPPORT	if (rtusb_fast_probe(handle, &pAd, intf) == NDIS_STATUS_SUCCESS)	{		*ppAd = pAd;		goto fast_probe_done;	}	#endif /* RESUME_WITH_USB_RESET_SUPPORT */	rv = RTMPAllocAdapterBlock(handle, &pAd);	if (rv != NDIS_STATUS_SUCCESS) 	{		os_free_mem(NULL, handle);		goto err_out;	}	if (USBDevConfigInit(usb_dev, intf, pAd) == FALSE)		goto err_out_free_radev;	RTMP_DRIVER_USB_INIT(pAd, usb_dev, dev_id->driver_info);		net_dev = RtmpPhyNetDevInit(pAd, &netDevHook);	if (net_dev == NULL)		goto err_out_free_radev;		/* Here are the net_device structure with usb specific parameters. */#ifdef NATIVE_WPA_SUPPLICANT_SUPPORT	/* for supporting Network Manager.	  * Set the sysfs physical device reference for the network logical device if set prior to registration will //.........这里部分代码省略.........
开发者ID:vm3vuy,项目名称:my-local-repository,代码行数:101,


示例16: kevent

/* work that cannot be done in interrupt context uses keventd. * * NOTE:  with 2.5 we could do more of this using completion callbacks, * especially now that control transfers can be queued. */static voidkevent (struct work_struct *work){	struct usbnet		*dev =		container_of(work, struct usbnet, kevent);	int			status;	/* usb_clear_halt() needs a thread context */	if (test_bit (EVENT_TX_HALT, &dev->flags)) {		unlink_urbs (dev, &dev->txq);#if defined(CONFIG_ERICSSON_F3307_ENABLE)		status = usb_autopm_get_interface(dev->intf); 		if (status < 0) 			goto fail_pipe;#endif		status = usb_clear_halt (dev->udev, dev->out);#if defined(CONFIG_ERICSSON_F3307_ENABLE)		usb_autopm_put_interface(dev->intf);#endif		if (status < 0				&& status != -EPIPE				&& status != -ESHUTDOWN) {			if (netif_msg_tx_err (dev))#if defined(CONFIG_ERICSSON_F3307_ENABLE)fail_pipe:#endif				deverr (dev, "can't clear tx halt, status %d",					status);		} else {			clear_bit (EVENT_TX_HALT, &dev->flags);			if (status != -ESHUTDOWN)				netif_wake_queue (dev->net);		}	}	if (test_bit (EVENT_RX_HALT, &dev->flags)) {		unlink_urbs (dev, &dev->rxq);#if defined(CONFIG_ERICSSON_F3307_ENABLE)		status = usb_autopm_get_interface(dev->intf); 		if (status < 0) 			goto fail_halt;#endif		status = usb_clear_halt (dev->udev, dev->in);#if defined(CONFIG_ERICSSON_F3307_ENABLE)		usb_autopm_put_interface(dev->intf);#endif		if (status < 0				&& status != -EPIPE				&& status != -ESHUTDOWN) {			if (netif_msg_rx_err (dev))#if defined(CONFIG_ERICSSON_F3307_ENABLE)fail_halt:#endif				deverr (dev, "can't clear rx halt, status %d",					status);		} else {			clear_bit (EVENT_RX_HALT, &dev->flags);			tasklet_schedule (&dev->bh);		}	}	/* tasklet could resubmit itself forever if memory is tight */	if (test_bit (EVENT_RX_MEMORY, &dev->flags)) {		struct urb	*urb = NULL;		if (netif_running (dev->net))			urb = usb_alloc_urb (0, GFP_KERNEL);		else			clear_bit (EVENT_RX_MEMORY, &dev->flags);		if (urb != NULL) {			clear_bit (EVENT_RX_MEMORY, &dev->flags);#if defined(CONFIG_ERICSSON_F3307_ENABLE)			status = usb_autopm_get_interface(dev->intf);			if (status < 0)				goto fail_lowmem;#endif			rx_submit (dev, urb, GFP_KERNEL);#if defined(CONFIG_ERICSSON_F3307_ENABLE)			usb_autopm_put_interface(dev->intf);fail_lowmem:#endif			tasklet_schedule (&dev->bh);		}	}	if (test_bit (EVENT_LINK_RESET, &dev->flags)) {		struct driver_info	*info = dev->driver_info;		int			retval = 0;		clear_bit (EVENT_LINK_RESET, &dev->flags);#if defined(CONFIG_ERICSSON_F3307_ENABLE)		status = usb_autopm_get_interface(dev->intf);		if (status < 0)//.........这里部分代码省略.........
开发者ID:marcero,项目名称:ab73kernel-Hannspad-2632,代码行数:101,


示例17: spin_lock_irq

static ssize_t wdm_write(struct file *file, const char __user *buffer, size_t count, loff_t *ppos){	u8 *buf;	int rv = -EMSGSIZE, r, we;	struct wdm_device *desc = file->private_data;	struct usb_ctrlrequest *req;	if (count > desc->wMaxCommand)		count = desc->wMaxCommand;	spin_lock_irq(&desc->iuspin);	we = desc->werr;	desc->werr = 0;	spin_unlock_irq(&desc->iuspin);	if (we < 0)		return -EIO;	desc->outbuf = buf = kmalloc(count, GFP_KERNEL);	if (!buf) {		rv = -ENOMEM;		goto outnl;	}	r = copy_from_user(buf, buffer, count);	if (r > 0) {		kfree(buf);		rv = -EFAULT;		goto outnl;	}	/* concurrent writes and disconnect */	r = mutex_lock_interruptible(&desc->lock);	rv = -ERESTARTSYS;	if (r) {		kfree(buf);		goto outnl;	}	if (test_bit(WDM_DISCONNECTING, &desc->flags)) {		kfree(buf);		rv = -ENODEV;		goto outnp;	}	r = usb_autopm_get_interface(desc->intf);	if (r < 0) {		kfree(buf);		goto outnp;	}	if (!(file->f_flags & O_NONBLOCK))		r = wait_event_interruptible(desc->wait, !test_bit(WDM_IN_USE,								&desc->flags));	else		if (test_bit(WDM_IN_USE, &desc->flags))			r = -EAGAIN;	if (r < 0) {		kfree(buf);		goto out;	}	req = desc->orq;	usb_fill_control_urb(		desc->command,		interface_to_usbdev(desc->intf),		/* using common endpoint 0 */		usb_sndctrlpipe(interface_to_usbdev(desc->intf), 0),		(unsigned char *)req,		buf,		count,		wdm_out_callback,		desc	);	req->bRequestType = (USB_DIR_OUT | USB_TYPE_CLASS |			     USB_RECIP_INTERFACE);	req->bRequest = USB_CDC_SEND_ENCAPSULATED_COMMAND;	req->wValue = 0;	req->wIndex = desc->inum;	req->wLength = cpu_to_le16(count);	set_bit(WDM_IN_USE, &desc->flags);	rv = usb_submit_urb(desc->command, GFP_KERNEL);	if (rv < 0) {		kfree(buf);		clear_bit(WDM_IN_USE, &desc->flags);		dev_err(&desc->intf->dev, "Tx URB error: %d/n", rv);	} else {		dev_dbg(&desc->intf->dev, "Tx URB has been submitted index=%d",			req->wIndex);	}out:	usb_autopm_put_interface(desc->intf);outnp:	mutex_unlock(&desc->lock);outnl:	return rv < 0 ? rv : count;}
开发者ID:jbaldus,项目名称:android_kernel_a100,代码行数:99,


示例18: kevent

/* work that cannot be done in interrupt context uses keventd. * * NOTE:  with 2.5 we could do more of this using completion callbacks, * especially now that control transfers can be queued. */static voidkevent (struct work_struct *work){	struct usbnet		*dev =		container_of(work, struct usbnet, kevent);	int			status;	/* usb_clear_halt() needs a thread context */	if (test_bit (EVENT_TX_HALT, &dev->flags)) {		unlink_urbs (dev, &dev->txq);		status = usb_autopm_get_interface(dev->intf);		if (status < 0)			goto fail_pipe;		status = usb_clear_halt (dev->udev, dev->out);		usb_autopm_put_interface(dev->intf);		if (status < 0 &&		    status != -EPIPE &&		    status != -ESHUTDOWN) {			if (netif_msg_tx_err (dev))fail_pipe:				netdev_err(dev->net, "can't clear tx halt, status %d/n",					   status);		} else {			clear_bit (EVENT_TX_HALT, &dev->flags);			if (status != -ESHUTDOWN)				netif_wake_queue (dev->net);		}	}	if (test_bit (EVENT_RX_HALT, &dev->flags)) {		unlink_urbs (dev, &dev->rxq);		status = usb_autopm_get_interface(dev->intf);		if (status < 0)			goto fail_halt;		status = usb_clear_halt (dev->udev, dev->in);		usb_autopm_put_interface(dev->intf);		if (status < 0 &&		    status != -EPIPE &&		    status != -ESHUTDOWN) {			if (netif_msg_rx_err (dev))fail_halt:				netdev_err(dev->net, "can't clear rx halt, status %d/n",					   status);		} else {			clear_bit (EVENT_RX_HALT, &dev->flags);			queue_work(usbnet_wq, &dev->bh_w);		}	}	/* tasklet could resubmit itself forever if memory is tight */	if (test_bit (EVENT_RX_MEMORY, &dev->flags)) {		struct urb	*urb = NULL;		int resched = 1;		if (netif_running (dev->net))			urb = usb_alloc_urb (0, GFP_KERNEL);		else			clear_bit (EVENT_RX_MEMORY, &dev->flags);		if (urb != NULL) {			clear_bit (EVENT_RX_MEMORY, &dev->flags);			status = usb_autopm_get_interface(dev->intf);			if (status < 0) {				usb_free_urb(urb);				goto fail_lowmem;			}			if (rx_submit (dev, urb, GFP_KERNEL) == -ENOLINK)				resched = 0;			usb_autopm_put_interface(dev->intf);fail_lowmem:			if (resched)				queue_work(usbnet_wq, &dev->bh_w);		}	}	if (test_bit (EVENT_LINK_RESET, &dev->flags)) {		struct driver_info	*info = dev->driver_info;		int			retval = 0;		clear_bit (EVENT_LINK_RESET, &dev->flags);		status = usb_autopm_get_interface(dev->intf);		if (status < 0)			goto skip_reset;		if(info->link_reset && (retval = info->link_reset(dev)) < 0) {			usb_autopm_put_interface(dev->intf);skip_reset:			netdev_info(dev->net, "link reset failed (%d) usbnet usb-%s-%s, %s/n",				    retval,				    dev->udev->bus->bus_name,				    dev->udev->devpath,				    info->description);		} else {			usb_autopm_put_interface(dev->intf);		}	}	if (dev->flags)//.........这里部分代码省略.........
开发者ID:android-armv7a-belalang-tempur,项目名称:gp-peak-kernel,代码行数:101,


示例19: ksb_start_rx_work

static void ksb_start_rx_work(struct work_struct *w){	struct ks_bridge *ksb =			container_of(w, struct ks_bridge, start_rx_work);	struct data_pkt	*pkt;	struct urb *urb;	int i = 0;	int ret;	bool put = true;	ret = usb_autopm_get_interface(ksb->ifc);	if (ret < 0) {		if (ret != -EAGAIN && ret != -EACCES) {			pr_err_ratelimited("%s: autopm_get failed:%d",					ksb->fs_dev.name, ret);			return;		}		put = false;	}	for (i = 0; i < NO_RX_REQS; i++) {		if (!test_bit(USB_DEV_CONNECTED, &ksb->flags))			break;		pkt = ksb_alloc_data_pkt(MAX_DATA_PKT_SIZE, GFP_KERNEL, ksb);		if (IS_ERR(pkt)) {			dev_err(&ksb->udev->dev, "unable to allocate data pkt");			break;		}		urb = usb_alloc_urb(0, GFP_KERNEL);		if (!urb) {			dev_err(&ksb->udev->dev, "unable to allocate urb");			ksb_free_data_pkt(pkt);			break;		}		usb_fill_bulk_urb(urb, ksb->udev, ksb->in_pipe,				pkt->buf, pkt->len,				ksb_rx_cb, pkt);		usb_anchor_urb(urb, &ksb->submitted);		dbg_log_event(ksb, "S RX_URB", pkt->len, 0);		atomic_inc(&ksb->rx_pending_cnt);		ret = usb_submit_urb(urb, GFP_KERNEL);		if (ret) {			dev_err(&ksb->udev->dev, "in urb submission failed");			usb_unanchor_urb(urb);			usb_free_urb(urb);			ksb_free_data_pkt(pkt);			atomic_dec(&ksb->rx_pending_cnt);			wake_up(&ksb->pending_urb_wait);			break;		}		usb_free_urb(urb);	}	if (put)		usb_autopm_put_interface_async(ksb->ifc);}
开发者ID:98416,项目名称:Z7Max_NX505J_H129_kernel,代码行数:61,


示例20: usb_console_setup

/* * The parsing of the command line works exactly like the * serial.c code, except that the specifier is "ttyUSB" instead * of "ttyS". */static int usb_console_setup(struct console *co, char *options){    struct usbcons_info *info = &usbcons_info;    int baud = 9600;    int bits = 8;    int parity = 'n';    int doflow = 0;    int cflag = CREAD | HUPCL | CLOCAL;    char *s;    struct usb_serial *serial;    struct usb_serial_port *port;    int retval;    struct tty_struct *tty = NULL;    struct ktermios dummy;    dbg("%s", __func__);    if (options) {        baud = simple_strtoul(options, NULL, 10);        s = options;        while (*s >= '0' && *s <= '9')            s++;        if (*s)            parity = *s++;        if (*s)            bits   = *s++ - '0';        if (*s)            doflow = (*s++ == 'r');    }    /* Sane default */    if (baud == 0)        baud = 9600;    switch (bits) {    case 7:        cflag |= CS7;        break;    default:    case 8:        cflag |= CS8;        break;    }    switch (parity) {    case 'o':    case 'O':        cflag |= PARODD;        break;    case 'e':    case 'E':        cflag |= PARENB;        break;    }    co->cflag = cflag;    /*     * no need to check the index here: if the index is wrong, console     * code won't call us     */    serial = usb_serial_get_by_index(co->index);    if (serial == NULL) {        /* no device is connected yet, sorry :( */        err("No USB device connected to ttyUSB%i", co->index);        return -ENODEV;    }    retval = usb_autopm_get_interface(serial->interface);    if (retval)        goto error_get_interface;    port = serial->port[co->index - serial->minor];    tty_port_tty_set(&port->port, NULL);    info->port = port;    ++port->port.count;    if (!test_bit(ASYNCB_INITIALIZED, &port->port.flags)) {        if (serial->type->set_termios) {            /*             * allocate a fake tty so the driver can initialize             * the termios structure, then later call set_termios to             * configure according to command line arguments             */            tty = kzalloc(sizeof(*tty), GFP_KERNEL);            if (!tty) {                retval = -ENOMEM;                err("no more memory");                goto reset_open_count;            }            kref_init(&tty->kref);            tty_port_tty_set(&port->port, tty);            tty->driver = usb_serial_tty_driver;            tty->index = co->index;            if (tty_init_termios(tty)) {                retval = -ENOMEM;//.........这里部分代码省略.........
开发者ID:CSCLOG,项目名称:beaglebone,代码行数:101,


示例21: rmnet_usb_ctrl_write

static int rmnet_usb_ctrl_write(struct rmnet_ctrl_dev *dev, char *buf,		size_t size){	int			result;	struct urb		*sndurb;	struct usb_ctrlrequest	*out_ctlreq;	struct usb_device	*udev;	if (!is_dev_connected(dev))		return -ENETRESET;	udev = interface_to_usbdev(dev->intf);	sndurb = usb_alloc_urb(0, GFP_KERNEL);	if (!sndurb) {		dev_err(dev->devicep, "Error allocating read urb/n");		return -ENOMEM;	}	out_ctlreq = kmalloc(sizeof(*out_ctlreq), GFP_KERNEL);	if (!out_ctlreq) {		usb_free_urb(sndurb);		dev_err(dev->devicep, "Error allocating setup packet buffer/n");		return -ENOMEM;	}	/* CDC Send Encapsulated Request packet */	out_ctlreq->bRequestType = (USB_DIR_OUT | USB_TYPE_CLASS |			     USB_RECIP_INTERFACE);	out_ctlreq->bRequest = USB_CDC_SEND_ENCAPSULATED_COMMAND;	out_ctlreq->wValue = 0;	out_ctlreq->wIndex = dev->intf->cur_altsetting->desc.bInterfaceNumber;	out_ctlreq->wLength = cpu_to_le16(size);	usb_fill_control_urb(sndurb, udev,			     usb_sndctrlpipe(udev, 0),			     (unsigned char *)out_ctlreq, (void *)buf, size,			     ctrl_write_callback, dev);	result = usb_autopm_get_interface(dev->intf);	if (result < 0) {		dev_dbg(dev->devicep, "%s: Unable to resume interface: %d/n",			__func__, result);		/*		* Revisit:  if (result == -EPERM)		*		rmnet_usb_suspend(dev->intf, PMSG_SUSPEND);		*/		usb_free_urb(sndurb);		kfree(out_ctlreq);		return result;	}	usb_anchor_urb(sndurb, &dev->tx_submitted);	dev->snd_encap_cmd_cnt++;	result = usb_submit_urb(sndurb, GFP_KERNEL);	if (result < 0) {		dev_err(dev->devicep, "%s: Submit URB error %d/n",			__func__, result);		dev->snd_encap_cmd_cnt--;		usb_autopm_put_interface(dev->intf);		usb_unanchor_urb(sndurb);		usb_free_urb(sndurb);		kfree(out_ctlreq);		return result;	}	return size;}
开发者ID:ColonelSaumon,项目名称:android_kernel_nokia_msm8x25,代码行数:70,


示例22: diag_bridge_write

int diag_bridge_write(int id, char *data, int size){	struct urb		*urb = NULL;	unsigned int		pipe;	struct diag_bridge	*dev;	int			ret;	if (id < 0 || id >= MAX_DIAG_BRIDGE_DEVS) {		pr_err("Invalid device ID");		return -ENODEV;	}	pr_debug("writing %d bytes", size);	dev = __dev[id];	if (!dev) {		pr_err("device is disconnected");		return -ENODEV;	}	mutex_lock(&dev->ifc_mutex);	if (!dev->ifc) {		ret = -ENODEV;		goto error;	}	if (!dev->ops) {		pr_err("bridge is not open");		ret = -ENODEV;		goto error;	}	if (!size) {		dev_err(&dev->ifc->dev, "invalid size:%d/n", size);		ret = -EINVAL;		goto error;	}	/* if there was a previous unrecoverable error, just quit */	if (dev->err) {		ret = -ENODEV;		goto error;	}	kref_get(&dev->kref);	urb = usb_alloc_urb(0, GFP_KERNEL);	if (!urb) {		dev_err(&dev->ifc->dev, "unable to allocate urb/n");		ret = -ENOMEM;		goto put_error;	}	ret = usb_autopm_get_interface(dev->ifc);	if (ret < 0 && ret != -EAGAIN && ret != -EACCES) {		pr_err_ratelimited("write: autopm_get failed:%d", ret);		goto free_error;	}	pipe = usb_sndbulkpipe(dev->udev, dev->out_epAddr);	usb_fill_bulk_urb(urb, dev->udev, pipe, data, size,				diag_bridge_write_cb, dev);	urb->transfer_flags |= URB_ZERO_PACKET;	usb_anchor_urb(urb, &dev->submitted);	dev->pending_writes++;	ret = usb_submit_urb(urb, GFP_KERNEL);	if (ret) {		pr_err_ratelimited("submitting urb failed err:%d", ret);		dev->pending_writes--;		usb_unanchor_urb(urb);		usb_autopm_put_interface(dev->ifc);		goto free_error;	}free_error:	usb_free_urb(urb);put_error:	if (ret) /* otherwise this is done in the completion handler */		kref_put(&dev->kref, diag_bridge_delete);error:	mutex_unlock(&dev->ifc_mutex);	return ret;}
开发者ID:AD5GB,项目名称:wicked_kernel_lge_hammerhead,代码行数:84,


示例23: _chaoskey_fill

/* Fill the buffer. Called with dev->lock held */static int _chaoskey_fill(struct chaoskey *dev){	DEFINE_WAIT(wait);	int result;	bool started;	usb_dbg(dev->interface, "fill");	/* Return immediately if someone called before the buffer was	 * empty */	if (dev->valid != dev->used) {		usb_dbg(dev->interface, "not empty yet (valid %d used %d)",			dev->valid, dev->used);		return 0;	}	/* Bail if the device has been removed */	if (!dev->present) {		usb_dbg(dev->interface, "device not present");		return -ENODEV;	}	/* Make sure the device is awake */	result = usb_autopm_get_interface(dev->interface);	if (result) {		usb_dbg(dev->interface, "wakeup failed (result %d)", result);		return result;	}	dev->reading = true;	result = usb_submit_urb(dev->urb, GFP_KERNEL);	if (result < 0) {		result = usb_translate_errors(result);		dev->reading = false;		goto out;	}	/* The first read on the Alea takes a little under 2 seconds.	 * Reads after the first read take only a few microseconds	 * though.  Presumably the entropy-generating circuit needs	 * time to ramp up.  So, we wait longer on the first read.	 */	started = dev->reads_started;	dev->reads_started = true;	result = wait_event_interruptible_timeout(		dev->wait_q,		!dev->reading,		(started ? NAK_TIMEOUT : ALEA_FIRST_TIMEOUT) );	if (result < 0)		goto out;	if (result == 0)		result = -ETIMEDOUT;	else		result = dev->valid;out:	/* Let the device go back to sleep eventually */	usb_autopm_put_interface(dev->interface);	usb_dbg(dev->interface, "read %d bytes", dev->valid);	return result;}
开发者ID:mkrufky,项目名称:linux,代码行数:66,


示例24: rt2870_resume

static int rt2870_resume(	struct usb_interface *intf){	struct net_device *net_dev;	VOID *pAd = usb_get_intfdata(intf);#ifdef USB_SUPPORT_SELECTIVE_SUSPEND	struct usb_device		*pUsb_Dev;	UCHAR Flag;	int 		pm_usage_cnt;	RTMP_DRIVER_USB_DEV_GET(pAd, &pUsb_Dev);	RTMP_DRIVER_USB_INTF_GET(pAd, &intf);#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,32)	pm_usage_cnt = atomic_read(&intf->pm_usage_cnt);	#else	pm_usage_cnt = intf->pm_usage_cnt;#endif#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,33)	if(pUsb_Dev->autosuspend_disabled == 0)#else	if(pUsb_Dev->auto_pm == 1)#endif	{		if(pm_usage_cnt  <= 0)			usb_autopm_get_interface(intf);	}	DBGPRINT(RT_DEBUG_ERROR, ("autosuspend===> rt2870_resume()/n"));	/*RTMP_CLEAR_FLAG(pAd, fRTMP_ADAPTER_SUSPEND); */	RTMP_DRIVER_ADAPTER_SUSPEND_CLEAR(pAd);	RTMP_DRIVER_ADAPTER_CPU_SUSPEND_TEST(pAd, &Flag);	if(Flag)	/*if(RTMP_TEST_FLAG(pAd, fRTMP_ADAPTER_CPU_SUSPEND)) */	{		/*RTMP_CLEAR_FLAG(pAd, fRTMP_ADAPTER_CPU_SUSPEND); */		RTMP_DRIVER_ADAPTER_CPU_SUSPEND_CLEAR(pAd);	}	/*RT28xxUsbAsicRadioOn(pAd); */	RTMP_DRIVER_ADAPTER_RT28XX_USB_ASICRADIO_ON(pAd);	DBGPRINT(RT_DEBUG_ERROR, ("autosuspend<===  rt2870_resume()/n"));	return 0;#endif /* USB_SUPPORT_SELECTIVE_SUSPEND */	DBGPRINT(RT_DEBUG_TRACE, ("===> rt2870_resume()/n"));/*	pAd->PM_FlgSuspend = 0; */	RTMP_DRIVER_USB_RESUME(pAd);/*	net_dev = pAd->net_dev; */	RTMP_DRIVER_NET_DEV_GET(pAd, &net_dev);	netif_device_attach(net_dev);	netif_start_queue(net_dev);	netif_carrier_on(net_dev);	netif_wake_queue(net_dev);	DBGPRINT(RT_DEBUG_TRACE, ("<=== rt2870_resume()/n"));	return 0;}
开发者ID:CoreTech-Development,项目名称:buildroot-linux-kernel,代码行数:66,



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


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