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

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

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

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

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

示例1: usb_alphatrack_probe

/** *	usb_alphatrack_probe * *	Called by the usb core when a new device is connected that it thinks *	this driver might be interested in. */static int usb_alphatrack_probe(struct usb_interface *intf, const struct usb_device_id *id){	struct usb_device *udev = interface_to_usbdev(intf);	struct usb_alphatrack *dev = NULL;	struct usb_host_interface *iface_desc;	struct usb_endpoint_descriptor *endpoint;	int i;	int true_size;	int retval = -ENOMEM;	/* allocate memory for our device state and intialize it */	dev = kzalloc(sizeof(*dev), GFP_KERNEL);	if (dev == NULL) {		dev_err(&intf->dev, "Out of memory/n");		goto exit;	}	init_MUTEX(&dev->sem);	dev->intf = intf;	init_waitqueue_head(&dev->read_wait);	init_waitqueue_head(&dev->write_wait);	iface_desc = intf->cur_altsetting;	/* set up the endpoint information */	for (i = 0; i < iface_desc->desc.bNumEndpoints; ++i) {		endpoint = &iface_desc->endpoint[i].desc;		if (usb_endpoint_is_int_in(endpoint))			dev->interrupt_in_endpoint = endpoint;		if (usb_endpoint_is_int_out(endpoint))			dev->interrupt_out_endpoint = endpoint;	}	if (dev->interrupt_in_endpoint == NULL) {		dev_err(&intf->dev, "Interrupt in endpoint not found/n");		goto error;	}	if (dev->interrupt_out_endpoint == NULL)		dev_warn(&intf->dev, "Interrupt out endpoint not found (using control endpoint instead)/n");	dev->interrupt_in_endpoint_size = le16_to_cpu(dev->interrupt_in_endpoint->wMaxPacketSize);	if (dev->interrupt_in_endpoint_size != 64)	    dev_warn(&intf->dev, "Interrupt in endpoint size is not 64!/n");	if(ring_buffer_size == 0) { ring_buffer_size = RING_BUFFER_SIZE; }	true_size = min(ring_buffer_size,RING_BUFFER_SIZE);	/* FIXME - there are more usb_alloc routines for dma correctness. Needed? *///	dev->ring_buffer = kmalloc((true_size*sizeof(struct alphatrack_icmd))+12, GFP_KERNEL);	dev->ring_buffer = kmalloc((true_size*sizeof(struct alphatrack_icmd)), GFP_KERNEL);	if (!dev->ring_buffer) {		dev_err(&intf->dev, "Couldn't allocate input ring_buffer of size %d/n",true_size);		goto error;	}	dev->interrupt_in_buffer = kmalloc(dev->interrupt_in_endpoint_size, GFP_KERNEL);	if (!dev->interrupt_in_buffer) {		dev_err(&intf->dev, "Couldn't allocate interrupt_in_buffer/n");		goto error;	}	dev->oldi_buffer = kmalloc(dev->interrupt_in_endpoint_size, GFP_KERNEL);	if (!dev->oldi_buffer) {		dev_err(&intf->dev, "Couldn't allocate old buffer/n");		goto error;	}	dev->interrupt_in_urb = usb_alloc_urb(0, GFP_KERNEL);	if (!dev->interrupt_in_urb) {		dev_err(&intf->dev, "Couldn't allocate interrupt_in_urb/n");		goto error;	}	dev->interrupt_out_endpoint_size = dev->interrupt_out_endpoint ? le16_to_cpu(dev->interrupt_out_endpoint->wMaxPacketSize) :									 udev->descriptor.bMaxPacketSize0;	if (dev->interrupt_out_endpoint_size !=64)		dev_warn(&intf->dev, "Interrupt out endpoint size is not 64!)/n");	if(write_buffer_size == 0) { write_buffer_size = WRITE_BUFFER_SIZE; }	true_size = min(write_buffer_size,WRITE_BUFFER_SIZE);	dev->interrupt_out_buffer = kmalloc(true_size*dev->interrupt_out_endpoint_size, GFP_KERNEL);	if (!dev->interrupt_out_buffer) {		dev_err(&intf->dev, "Couldn't allocate interrupt_out_buffer/n");		goto error;	}	dev->write_buffer = kmalloc(sizeof(struct alphatrack_ocmd)*true_size, GFP_KERNEL);//.........这里部分代码省略.........
开发者ID:johnny,项目名称:CobraDroidBeta,代码行数:101,


示例2: opticon_startup

static int opticon_startup(struct usb_serial *serial){	struct opticon_private *priv;	struct usb_host_interface *intf;	int i;	int retval = -ENOMEM;	bool bulk_in_found = false;	/* create our private serial structure */	priv = kzalloc(sizeof(*priv), GFP_KERNEL);	if (priv == NULL) {		dev_err(&serial->dev->dev, "%s - Out of memory/n", __func__);		return -ENOMEM;	}	spin_lock_init(&priv->lock);	priv->serial = serial;	priv->port = serial->port[0];	priv->udev = serial->dev;	/* find our bulk endpoint */	intf = serial->interface->altsetting;	for (i = 0; i < intf->desc.bNumEndpoints; ++i) {		struct usb_endpoint_descriptor *endpoint;		endpoint = &intf->endpoint[i].desc;		if (!usb_endpoint_is_bulk_in(endpoint))			continue;		priv->bulk_read_urb = usb_alloc_urb(0, GFP_KERNEL);		if (!priv->bulk_read_urb) {			dev_err(&priv->udev->dev, "out of memory/n");			goto error;		}		priv->buffer_size = le16_to_cpu(endpoint->wMaxPacketSize) * 2;		priv->bulk_in_buffer = kmalloc(priv->buffer_size, GFP_KERNEL);		if (!priv->bulk_in_buffer) {			dev_err(&priv->udev->dev, "out of memory/n");			goto error;		}		priv->bulk_address = endpoint->bEndpointAddress;		/* set up our bulk urb */		usb_fill_bulk_urb(priv->bulk_read_urb, priv->udev,				  usb_rcvbulkpipe(priv->udev,						  endpoint->bEndpointAddress),				  priv->bulk_in_buffer, priv->buffer_size,				  opticon_bulk_callback, priv);		bulk_in_found = true;		break;		}	if (!bulk_in_found) {		dev_err(&priv->udev->dev,			"Error - the proper endpoints were not found!/n");		goto error;	}	usb_set_serial_data(serial, priv);	return 0;error:	usb_free_urb(priv->bulk_read_urb);	kfree(priv->bulk_in_buffer);	kfree(priv);	return retval;}
开发者ID:johnny,项目名称:CobraDroidBeta,代码行数:69,


示例3: usb_mdc800_init

int __init usb_mdc800_init (void){	/* Allocate Memory */	try (mdc800=kmalloc (sizeof (struct mdc800_data), GFP_KERNEL));	memset(mdc800, 0, sizeof(struct mdc800_data));	mdc800->dev=0;	mdc800->open=0;	mdc800->state=NOT_CONNECTED;	spin_lock_init (&mdc800->io_lock);	init_waitqueue_head (&mdc800->irq_wait);	init_waitqueue_head (&mdc800->write_wait);	init_waitqueue_head (&mdc800->download_wait);	try (mdc800->irq_urb_buffer=kmalloc (8, GFP_KERNEL));	try (mdc800->write_urb_buffer=kmalloc (8, GFP_KERNEL));	try (mdc800->download_urb_buffer=kmalloc (64, GFP_KERNEL));	try (mdc800->irq_urb=usb_alloc_urb (0));	try (mdc800->download_urb=usb_alloc_urb (0));	try (mdc800->write_urb=usb_alloc_urb (0));	/* Register the driver */	if (usb_register (&mdc800_usb_driver) < 0)		goto cleanup_on_fail;	info ("Mustek Digital Camera Driver " VERSION " (MDC800)");	info (RELEASE_DATE " Henning Zabel <[email
C++ usb_altnum_to_altsetting函数代码示例
C++ usb_add_hcd函数代码示例
万事OK自学网:51自学网_软件自学网_CAD自学网自学excel、自学PS、自学CAD、自学C语言、自学css3实例,是一个通过网络自主学习工作技能的自学平台,网友喜欢的软件自学网站。