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

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

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

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

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

示例1: mt76u_set_endpoints

static intmt76u_set_endpoints(struct usb_interface *intf,		    struct mt76_usb *usb){	struct usb_host_interface *intf_desc = intf->cur_altsetting;	struct usb_endpoint_descriptor *ep_desc;	int i, in_ep = 0, out_ep = 0;	for (i = 0; i < intf_desc->desc.bNumEndpoints; i++) {		ep_desc = &intf_desc->endpoint[i].desc;		if (usb_endpoint_is_bulk_in(ep_desc) &&		    in_ep < __MT_EP_IN_MAX) {			usb->in_ep[in_ep] = usb_endpoint_num(ep_desc);			usb->in_max_packet = usb_endpoint_maxp(ep_desc);			in_ep++;		} else if (usb_endpoint_is_bulk_out(ep_desc) &&			   out_ep < __MT_EP_OUT_MAX) {			usb->out_ep[out_ep] = usb_endpoint_num(ep_desc);			usb->out_max_packet = usb_endpoint_maxp(ep_desc);			out_ep++;		}	}	if (in_ep != __MT_EP_IN_MAX || out_ep != __MT_EP_OUT_MAX)		return -EINVAL;	return 0;}
开发者ID:markus-oberhumer,项目名称:linux,代码行数:28,


示例2: config_ep

static int config_ep(struct fusb300_ep *ep,                     const struct usb_endpoint_descriptor *desc){    struct fusb300 *fusb300 = ep->fusb300;    struct fusb300_ep_info info;    ep->ep.desc = desc;    info.interval = 0;    info.addrofs = 0;    info.bw_num = 0;    info.type = desc->bmAttributes & USB_ENDPOINT_XFERTYPE_MASK;    info.dir_in = (desc->bEndpointAddress & USB_ENDPOINT_DIR_MASK) ? 1 : 0;    info.maxpacket = usb_endpoint_maxp(desc);    info.epnum = desc->bEndpointAddress & USB_ENDPOINT_NUMBER_MASK;    if ((info.type == USB_ENDPOINT_XFER_INT) ||            (info.type == USB_ENDPOINT_XFER_ISOC)) {        info.interval = desc->bInterval;        if (info.type == USB_ENDPOINT_XFER_ISOC)            info.bw_num = usb_endpoint_maxp_mult(desc);    }    ep_fifo_setting(fusb300, info);    set_ep_reg(fusb300, info);    fusb300_ep_setting(ep, info);    fusb300->ep[info.epnum] = ep;    return 0;}
开发者ID:kdave,项目名称:btrfs-devel,代码行数:34,


示例3: wa_create

/** * Assumes * * wa->usb_dev and wa->usb_iface initialized and refcounted, * wa->wa_descr initialized. */int wa_create(struct wahc *wa, struct usb_interface *iface){	int result;	struct device *dev = &iface->dev;	result = wa_rpipes_create(wa);	if (result < 0)		goto error_rpipes_create;	/* Fill up Data Transfer EP pointers */	wa->dti_epd = &iface->cur_altsetting->endpoint[1].desc;	wa->dto_epd = &iface->cur_altsetting->endpoint[2].desc;	wa->xfer_result_size = usb_endpoint_maxp(wa->dti_epd);	wa->xfer_result = kmalloc(wa->xfer_result_size, GFP_KERNEL);	if (wa->xfer_result == NULL)		goto error_xfer_result_alloc;	result = wa_nep_create(wa, iface);	if (result < 0) {		dev_err(dev, "WA-CDS: can't initialize notif endpoint: %d/n",			result);		goto error_nep_create;	}	return 0;error_nep_create:	kfree(wa->xfer_result);error_xfer_result_alloc:	wa_rpipes_destroy(wa);error_rpipes_create:	return result;}
开发者ID:openube,项目名称:android_kernel_sony_c2305,代码行数:36,


示例4: usbtv_probe

static int usbtv_probe(struct usb_interface *intf,	const struct usb_device_id *id){	int ret;	int size;	struct device *dev = &intf->dev;	struct usbtv *usbtv;	struct usb_host_endpoint *ep;	/* Checks that the device is what we think it is. */	if (intf->num_altsetting != 2)		return -ENODEV;	if (intf->altsetting[1].desc.bNumEndpoints != 4)		return -ENODEV;	ep = &intf->altsetting[1].endpoint[0];	/* Packet size is split into 11 bits of base size and count of	 * extra multiplies of it.*/	size = usb_endpoint_maxp(&ep->desc);	size = (size & 0x07ff) * usb_endpoint_maxp_mult(&ep->desc);	/* Device structure */	usbtv = kzalloc(sizeof(struct usbtv), GFP_KERNEL);	if (usbtv == NULL)		return -ENOMEM;	usbtv->dev = dev;	usbtv->udev = usb_get_dev(interface_to_usbdev(intf));	usbtv->iso_size = size;	usb_set_intfdata(intf, usbtv);	ret = usbtv_video_init(usbtv);	if (ret < 0)		goto usbtv_video_fail;	ret = usbtv_audio_init(usbtv);	if (ret < 0)		goto usbtv_audio_fail;	/* for simplicity we exploit the v4l2_device reference counting */	v4l2_device_get(&usbtv->v4l2_dev);	dev_info(dev, "Fushicai USBTV007 Audio-Video Grabber/n");	return 0;usbtv_audio_fail:	usbtv_video_free(usbtv);usbtv_video_fail:	usb_set_intfdata(intf, NULL);	usb_put_dev(usbtv->udev);	kfree(usbtv);	return ret;}
开发者ID:mkrufky,项目名称:linux,代码行数:57,


示例5: usbhsg_ep_enable

/* * *		usb_ep_ops * */static int usbhsg_ep_enable(struct usb_ep *ep,			 const struct usb_endpoint_descriptor *desc){	struct usbhsg_uep *uep   = usbhsg_ep_to_uep(ep);	struct usbhsg_gpriv *gpriv = usbhsg_uep_to_gpriv(uep);	struct usbhs_priv *priv = usbhsg_gpriv_to_priv(gpriv);	struct usbhs_pipe *pipe;	int ret = -EIO;	unsigned long flags;	usbhs_lock(priv, flags);	/*	 * if it already have pipe,	 * nothing to do	 */	if (uep->pipe) {		usbhs_pipe_clear(uep->pipe);		usbhs_pipe_sequence_data0(uep->pipe);		ret = 0;		goto usbhsg_ep_enable_end;	}	pipe = usbhs_pipe_malloc(priv,				 usb_endpoint_type(desc),				 usb_endpoint_dir_in(desc));	if (pipe) {		uep->pipe		= pipe;		pipe->mod_private	= uep;		/* set epnum / maxp */		usbhs_pipe_config_update(pipe, 0,					 usb_endpoint_num(desc),					 usb_endpoint_maxp(desc));		/*		 * usbhs_fifo_dma_push/pop_handler try to		 * use dmaengine if possible.		 * It will use pio handler if impossible.		 */		if (usb_endpoint_dir_in(desc)) {			pipe->handler = &usbhs_fifo_dma_push_handler;		} else {			pipe->handler = &usbhs_fifo_dma_pop_handler;			usbhs_xxxsts_clear(priv, BRDYSTS,					   usbhs_pipe_number(pipe));		}		ret = 0;	}usbhsg_ep_enable_end:	usbhs_unlock(priv, flags);	return ret;}
开发者ID:mkrufky,项目名称:linux,代码行数:61,


示例6: mt7601u_assign_pipes

static int mt7601u_assign_pipes(struct usb_interface *usb_intf,				struct mt7601u_dev *dev){	struct usb_endpoint_descriptor *ep_desc;	struct usb_host_interface *intf_desc = usb_intf->cur_altsetting;	unsigned i, ep_i = 0, ep_o = 0;	BUILD_BUG_ON(sizeof(dev->in_eps) < __MT_EP_IN_MAX);	BUILD_BUG_ON(sizeof(dev->out_eps) < __MT_EP_OUT_MAX);	for (i = 0; i < intf_desc->desc.bNumEndpoints; i++) {		ep_desc = &intf_desc->endpoint[i].desc;		if (usb_endpoint_is_bulk_in(ep_desc) &&		    ep_i++ < __MT_EP_IN_MAX) {			dev->in_eps[ep_i - 1] = usb_endpoint_num(ep_desc);			dev->in_max_packet = usb_endpoint_maxp(ep_desc);			/* Note: this is ignored by usb sub-system but vendor			 *	 code does it. We can drop this at some point.			 */			dev->in_eps[ep_i - 1] |= USB_DIR_IN;		} else if (usb_endpoint_is_bulk_out(ep_desc) &&			   ep_o++ < __MT_EP_OUT_MAX) {			dev->out_eps[ep_o - 1] = usb_endpoint_num(ep_desc);			dev->out_max_packet = usb_endpoint_maxp(ep_desc);		}	}	if (ep_i != __MT_EP_IN_MAX || ep_o != __MT_EP_OUT_MAX) {		dev_err(dev->dev, "Error: wrong pipe number in:%d out:%d/n",			ep_i, ep_o);		return -EINVAL;	}	return 0;}
开发者ID:Kingbalou,项目名称:mt7601u,代码行数:36,


示例7: fotg210_ep_enable

static int fotg210_ep_enable(struct usb_ep *_ep,			  const struct usb_endpoint_descriptor *desc){	struct fotg210_ep *ep;	ep = container_of(_ep, struct fotg210_ep, ep);	ep->desc = desc;	ep->epnum = usb_endpoint_num(desc);	ep->type = usb_endpoint_type(desc);	ep->dir_in = usb_endpoint_dir_in(desc);	ep->ep.maxpacket = usb_endpoint_maxp(desc);	return fotg210_config_ep(ep, desc);}
开发者ID:Cool-Joe,项目名称:imx23-audio,代码行数:15,


示例8: adu_interrupt_in_callback

static void adu_interrupt_in_callback(struct urb *urb){	struct adu_device *dev = urb->context;	int status = urb->status;	dbg(4," %s : enter, status %d", __func__, status);	adu_debug_data(5, __func__, urb->actual_length,		       urb->transfer_buffer);	spin_lock(&dev->buflock);	if (status != 0) {		if ((status != -ENOENT) && (status != -ECONNRESET) &&			(status != -ESHUTDOWN)) {			dbg(1," %s : nonzero status received: %d",			    __func__, status);		}		goto exit;	}	if (urb->actual_length > 0 && dev->interrupt_in_buffer[0] != 0x00) {		if (dev->read_buffer_length <		    (4 * usb_endpoint_maxp(dev->interrupt_in_endpoint)) -		     (urb->actual_length)) {			memcpy (dev->read_buffer_primary +				dev->read_buffer_length,				dev->interrupt_in_buffer, urb->actual_length);			dev->read_buffer_length += urb->actual_length;			dbg(2," %s reading  %d ", __func__,			    urb->actual_length);		} else {			dbg(1," %s : read_buffer overflow", __func__);		}	}exit:	dev->read_urb_finished = 1;	spin_unlock(&dev->buflock);	/* always wake up so we recover from errors */	wake_up_interruptible(&dev->read_wait);	adu_debug_data(5, __func__, urb->actual_length,		       urb->transfer_buffer);	dbg(4," %s : leave, status %d", __func__, status);}
开发者ID:AbdulrahmanAmir,项目名称:Dorimanx-LG-G2-D802-Kernel,代码行数:45,


示例9: usbhsh_endpoint_sequence_save

/* *		pipe control */static void usbhsh_endpoint_sequence_save(struct usbhsh_hpriv *hpriv,					  struct urb *urb,					  struct usbhs_pkt *pkt){	int len = urb->actual_length;	int maxp = usb_endpoint_maxp(&urb->ep->desc);	int t = 0;	/* DCP is out of sequence control */	if (usb_pipecontrol(urb->pipe))		return;	/*	 * renesas_usbhs pipe has a limitation in a number.	 * So, driver should re-use the limited pipe for each device/endpoint.	 * DATA0/1 sequence should be saved for it.	 * see [image of mod_host]	 *     [HARDWARE LIMITATION]	 */	/*	 * next sequence depends on actual_length	 *	 * ex) actual_length = 1147, maxp = 512	 * data0 : 512	 * data1 : 512	 * data0 : 123	 * data1 is the next sequence	 */	t = len / maxp;	if (len % maxp)		t++;	if (pkt->zero)		t++;	t %= 2;	if (t)		usb_dotoggle(urb->dev,			     usb_pipeendpoint(urb->pipe),			     usb_pipeout(urb->pipe));}
开发者ID:513855417,项目名称:linux,代码行数:44,


示例10: config_ep

static int config_ep(struct fusb300_ep *ep,		     const struct usb_endpoint_descriptor *desc){	struct fusb300 *fusb300 = ep->fusb300;	struct fusb300_ep_info info;	ep->ep.desc = desc;	info.interval = 0;	info.addrofs = 0;	info.bw_num = 0;	info.type = desc->bmAttributes & USB_ENDPOINT_XFERTYPE_MASK;	info.dir_in = (desc->bEndpointAddress & USB_ENDPOINT_DIR_MASK) ? 1 : 0;	info.maxpacket = usb_endpoint_maxp(desc);	info.epnum = desc->bEndpointAddress & USB_ENDPOINT_NUMBER_MASK;	if ((info.type == USB_ENDPOINT_XFER_INT) ||	   (info.type == USB_ENDPOINT_XFER_ISOC)) {		info.interval = desc->bInterval;		if (info.type == USB_ENDPOINT_XFER_ISOC)			info.bw_num = ((desc->wMaxPacketSize & 0x1800) >> 11);	}
开发者ID:Felixneu,项目名称:Power-Management,代码行数:23,


示例11: skel_probe

static int skel_probe(struct usb_interface *interface,		      const struct usb_device_id *id){	struct usb_skel *dev;	struct usb_host_interface *iface_desc;	struct usb_endpoint_descriptor *endpoint;	int buffer_size;	int i;	int retval = -ENOMEM;	/* allocate memory for our device state and initialize it */	dev = kzalloc(sizeof(*dev), GFP_KERNEL);	if (!dev) {		dev_err(&interface->dev, "Out of memory/n");		goto error;	}	kref_init(&dev->kref);	sema_init(&dev->limit_sem, WRITES_IN_FLIGHT);	mutex_init(&dev->io_mutex);	spin_lock_init(&dev->err_lock);	init_usb_anchor(&dev->submitted);	init_waitqueue_head(&dev->bulk_in_wait);	dev->udev = usb_get_dev(interface_to_usbdev(interface));	dev->interface = interface;	/* set up the endpoint information */	/* use only the first bulk-in and bulk-out endpoints */	iface_desc = interface->cur_altsetting;	for (i = 0; i < iface_desc->desc.bNumEndpoints; ++i) {		endpoint = &iface_desc->endpoint[i].desc;		if (!dev->bulk_in_endpointAddr &&		    usb_endpoint_is_bulk_in(endpoint)) {			/* we found a bulk in endpoint */			buffer_size = usb_endpoint_maxp(endpoint);			dev->bulk_in_size = buffer_size;			dev->bulk_in_endpointAddr = endpoint->bEndpointAddress;			dev->bulk_in_buffer = kmalloc(buffer_size, GFP_KERNEL);			if (!dev->bulk_in_buffer) {				dev_err(&interface->dev,					"Could not allocate bulk_in_buffer/n");				goto error;			}			dev->bulk_in_urb = usb_alloc_urb(0, GFP_KERNEL);			if (!dev->bulk_in_urb) {				dev_err(&interface->dev,					"Could not allocate bulk_in_urb/n");				goto error;			}		}		if (!dev->bulk_out_endpointAddr &&		    usb_endpoint_is_bulk_out(endpoint)) {			/* we found a bulk out endpoint */			dev->bulk_out_endpointAddr = endpoint->bEndpointAddress;		}	}	if (!(dev->bulk_in_endpointAddr && dev->bulk_out_endpointAddr)) {		dev_err(&interface->dev,			"Could not find both bulk-in and bulk-out endpoints/n");		goto error;	}	/* save our data pointer in this interface device */	usb_set_intfdata(interface, dev);	/* we can register the device now, as it is ready */	retval = usb_register_dev(interface, &skel_class);	if (retval) {		/* something prevented us from registering this driver */		dev_err(&interface->dev,			"Not able to get a minor for this device./n");		usb_set_intfdata(interface, NULL);		goto error;	}	/* let the user know what node this device is now attached to */	dev_info(&interface->dev,		 "USB Skeleton device now attached to USBSkel-%d",		 interface->minor);	return 0;error:	if (dev)		/* this frees allocated memory */		kref_put(&dev->kref, skel_delete);	return retval;}
开发者ID:MercyMM,项目名称:os,代码行数:89,


示例12: bdc_config_ep

/* Configure an endpoint */int bdc_config_ep(struct bdc *bdc, struct bdc_ep *ep){	const struct usb_ss_ep_comp_descriptor *comp_desc;	const struct usb_endpoint_descriptor	*desc;	u32 param0, param1, param2, cmd_sc;	u32 mps, mbs, mul, si;	int ret;	desc = ep->desc;	comp_desc = ep->comp_desc;	cmd_sc = mul = mbs = param2 = 0;	param0 = lower_32_bits(ep->bd_list.bd_table_array[0]->dma);	param1 = upper_32_bits(ep->bd_list.bd_table_array[0]->dma);	cpu_to_le32s(&param0);	cpu_to_le32s(&param1);	dev_dbg(bdc->dev, "%s: param0=%08x param1=%08x",						__func__, param0, param1);	si = desc->bInterval;	si = clamp_val(si, 1, 16) - 1;	mps = usb_endpoint_maxp(desc);	mps &= 0x7ff;	param2 |= mps << MP_SHIFT;	param2 |= usb_endpoint_type(desc) << EPT_SHIFT;	switch (bdc->gadget.speed) {	case USB_SPEED_SUPER:		if (usb_endpoint_xfer_int(desc) ||					usb_endpoint_xfer_isoc(desc)) {			param2 |= si;			if (usb_endpoint_xfer_isoc(desc) && comp_desc)					mul = comp_desc->bmAttributes;		}		param2 |= mul << EPM_SHIFT;		if (comp_desc)			mbs = comp_desc->bMaxBurst;		param2 |= mbs << MB_SHIFT;		break;	case USB_SPEED_HIGH:		if (usb_endpoint_xfer_isoc(desc) ||					usb_endpoint_xfer_int(desc)) {			param2 |= si;			mbs = (usb_endpoint_maxp(desc) & 0x1800) >> 11;			param2 |= mbs << MB_SHIFT;		}		break;	case USB_SPEED_FULL:	case USB_SPEED_LOW:		/* the hardware accepts SI in 125usec range */		if (usb_endpoint_xfer_isoc(desc))			si += 3;		/*		 * FS Int endpoints can have si of 1-255ms but the controller		 * accepts 2^bInterval*125usec, so convert ms to nearest power		 * of 2		 */		if (usb_endpoint_xfer_int(desc))			si = fls(desc->bInterval * 8) - 1;		param2 |= si;		break;	default:		dev_err(bdc->dev, "UNKNOWN speed ERR/n");		return -EINVAL;	}
开发者ID:AK101111,项目名称:linux,代码行数:72,


示例13: 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;	priv->outstanding_urbs = 0;	/* Init the outstanding urbs */	/* 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 = usb_endpoint_maxp(endpoint) * 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;		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:openube,项目名称:android_kernel_sony_c2305,代码行数:63,


示例14: iowarrior_probe

/** *	iowarrior_probe * *	Called by the usb core when a new device is connected that it thinks *	this driver might be interested in. */static int iowarrior_probe(struct usb_interface *interface,			   const struct usb_device_id *id){	struct usb_device *udev = interface_to_usbdev(interface);	struct iowarrior *dev = NULL;	struct usb_host_interface *iface_desc;	struct usb_endpoint_descriptor *endpoint;	int i;	int retval = -ENOMEM;	/* allocate memory for our device state and initialize it */	dev = kzalloc(sizeof(struct iowarrior), GFP_KERNEL);	if (dev == NULL) {		dev_err(&interface->dev, "Out of memory/n");		return retval;	}	mutex_init(&dev->mutex);	atomic_set(&dev->intr_idx, 0);	atomic_set(&dev->read_idx, 0);	spin_lock_init(&dev->intr_idx_lock);	atomic_set(&dev->overflow_flag, 0);	init_waitqueue_head(&dev->read_wait);	atomic_set(&dev->write_busy, 0);	init_waitqueue_head(&dev->write_wait);	dev->udev = udev;	dev->interface = interface;	iface_desc = interface->cur_altsetting;	dev->product_id = le16_to_cpu(udev->descriptor.idProduct);	/* set up the endpoint information */	for (i = 0; i < iface_desc->desc.bNumEndpoints; ++i) {		endpoint = &iface_desc->endpoint[i].desc;		if (usb_endpoint_is_int_in(endpoint))			dev->int_in_endpoint = endpoint;		if (usb_endpoint_is_int_out(endpoint))			/* this one will match for the IOWarrior56 only */			dev->int_out_endpoint = endpoint;	}	/* we have to check the report_size often, so remember it in the endianess suitable for our machine */	dev->report_size = usb_endpoint_maxp(dev->int_in_endpoint);	if ((dev->interface->cur_altsetting->desc.bInterfaceNumber == 0) &&	    (dev->product_id == USB_DEVICE_ID_CODEMERCS_IOW56))		/* IOWarrior56 has wMaxPacketSize different from report size */		dev->report_size = 7;	/* create the urb and buffer for reading */	dev->int_in_urb = usb_alloc_urb(0, GFP_KERNEL);	if (!dev->int_in_urb) {		dev_err(&interface->dev, "Couldn't allocate interrupt_in_urb/n");		goto error;	}	dev->int_in_buffer = kmalloc(dev->report_size, GFP_KERNEL);	if (!dev->int_in_buffer) {		dev_err(&interface->dev, "Couldn't allocate int_in_buffer/n");		goto error;	}	usb_fill_int_urb(dev->int_in_urb, dev->udev,			 usb_rcvintpipe(dev->udev,					dev->int_in_endpoint->bEndpointAddress),			 dev->int_in_buffer, dev->report_size,			 iowarrior_callback, dev,			 dev->int_in_endpoint->bInterval);	/* create an internal buffer for interrupt data from the device */	dev->read_queue =	    kmalloc(((dev->report_size + 1) * MAX_INTERRUPT_BUFFER),		    GFP_KERNEL);	if (!dev->read_queue) {		dev_err(&interface->dev, "Couldn't allocate read_queue/n");		goto error;	}	/* Get the serial-number of the chip */	memset(dev->chip_serial, 0x00, sizeof(dev->chip_serial));	usb_string(udev, udev->descriptor.iSerialNumber, dev->chip_serial,		   sizeof(dev->chip_serial));	if (strlen(dev->chip_serial) != 8)		memset(dev->chip_serial, 0x00, sizeof(dev->chip_serial));	/* Set the idle timeout to 0, if this is interface 0 */	if (dev->interface->cur_altsetting->desc.bInterfaceNumber == 0) {	    usb_control_msg(udev, usb_sndctrlpipe(udev, 0),			    0x0A,			    USB_TYPE_CLASS | USB_RECIP_INTERFACE, 0,			    0, NULL, 0, USB_CTRL_SET_TIMEOUT);	}	/* allow device read and ioctl */	dev->present = 1;	/* we can register the device now, as it is ready */	usb_set_intfdata(interface, dev);//.........这里部分代码省略.........
开发者ID:96boards,项目名称:wilink8-wlan_wl18xx,代码行数:101,


示例15: ld_usb_probe

/** *	ld_usb_probe * *	Called by the usb core when a new device is connected that it thinks *	this driver might be interested in. */static int ld_usb_probe(struct usb_interface *intf, const struct usb_device_id *id){	struct usb_device *udev = interface_to_usbdev(intf);	struct ld_usb *dev = NULL;	struct usb_host_interface *iface_desc;	struct usb_endpoint_descriptor *endpoint;	char *buffer;	int i;	int retval = -ENOMEM;	/* allocate memory for our device state and initialize it */	dev = kzalloc(sizeof(*dev), GFP_KERNEL);	if (dev == NULL) {		dev_err(&intf->dev, "Out of memory/n");		goto exit;	}	mutex_init(&dev->mutex);	spin_lock_init(&dev->rbsl);	dev->intf = intf;	init_waitqueue_head(&dev->read_wait);	init_waitqueue_head(&dev->write_wait);	/* workaround for early firmware versions on fast computers */	if ((le16_to_cpu(udev->descriptor.idVendor) == USB_VENDOR_ID_LD) &&	    ((le16_to_cpu(udev->descriptor.idProduct) == USB_DEVICE_ID_LD_CASSY) ||	     (le16_to_cpu(udev->descriptor.idProduct) == USB_DEVICE_ID_LD_COM3LAB)) &&	    (le16_to_cpu(udev->descriptor.bcdDevice) <= 0x103)) {		buffer = kmalloc(256, GFP_KERNEL);		if (buffer == NULL) {			dev_err(&intf->dev, "Couldn't allocate string buffer/n");			goto error;		}		/* usb_string makes SETUP+STALL to leave always ControlReadLoop */		usb_string(udev, 255, buffer, 256);		kfree(buffer);	}	iface_desc = intf->cur_altsetting;	/* set up the endpoint information */	for (i = 0; i < iface_desc->desc.bNumEndpoints; ++i) {		endpoint = &iface_desc->endpoint[i].desc;		if (usb_endpoint_is_int_in(endpoint))			dev->interrupt_in_endpoint = endpoint;		if (usb_endpoint_is_int_out(endpoint))			dev->interrupt_out_endpoint = endpoint;	}	if (dev->interrupt_in_endpoint == NULL) {		dev_err(&intf->dev, "Interrupt in endpoint not found/n");		goto error;	}	if (dev->interrupt_out_endpoint == NULL)		dev_warn(&intf->dev, "Interrupt out endpoint not found (using control endpoint instead)/n");	dev->interrupt_in_endpoint_size = usb_endpoint_maxp(dev->interrupt_in_endpoint);	dev->ring_buffer = kmalloc(ring_buffer_size*(sizeof(size_t)+dev->interrupt_in_endpoint_size), GFP_KERNEL);	if (!dev->ring_buffer) {		dev_err(&intf->dev, "Couldn't allocate ring_buffer/n");		goto error;	}	dev->interrupt_in_buffer = kmalloc(dev->interrupt_in_endpoint_size, GFP_KERNEL);	if (!dev->interrupt_in_buffer) {		dev_err(&intf->dev, "Couldn't allocate interrupt_in_buffer/n");		goto error;	}	dev->interrupt_in_urb = usb_alloc_urb(0, GFP_KERNEL);	if (!dev->interrupt_in_urb) {		dev_err(&intf->dev, "Couldn't allocate interrupt_in_urb/n");		goto error;	}	dev->interrupt_out_endpoint_size = dev->interrupt_out_endpoint ? usb_endpoint_maxp(dev->interrupt_out_endpoint) :									 udev->descriptor.bMaxPacketSize0;	dev->interrupt_out_buffer = kmalloc(write_buffer_size*dev->interrupt_out_endpoint_size, GFP_KERNEL);	if (!dev->interrupt_out_buffer) {		dev_err(&intf->dev, "Couldn't allocate interrupt_out_buffer/n");		goto error;	}	dev->interrupt_out_urb = usb_alloc_urb(0, GFP_KERNEL);	if (!dev->interrupt_out_urb) {		dev_err(&intf->dev, "Couldn't allocate interrupt_out_urb/n");		goto error;	}	dev->interrupt_in_interval = min_interrupt_in_interval > dev->interrupt_in_endpoint->bInterval ? min_interrupt_in_interval : dev->interrupt_in_endpoint->bInterval;	if (dev->interrupt_out_endpoint)		dev->interrupt_out_interval = min_interrupt_out_interval > dev->interrupt_out_endpoint->bInterval ? min_interrupt_out_interval : dev->interrupt_out_endpoint->bInterval;	/* we can register the device now, as it is ready */	usb_set_intfdata(intf, dev);	retval = usb_register_dev(intf, &ld_usb_class);	if (retval) {//.........这里部分代码省略.........
开发者ID:19Dan01,项目名称:linux,代码行数:101,


示例16: usb_parse_endpoint

static 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 (usb_endpoint_maxp(&endpoint->desc) > 8)//.........这里部分代码省略.........
开发者ID:7799,项目名称:linux,代码行数:101,


示例17: usb_parse_ss_endpoint_companion

static void usb_parse_ss_endpoint_companion(struct device *ddev, int cfgno,		int inum, int asnum, struct usb_host_endpoint *ep,		unsigned char *buffer, int size){	struct usb_ss_ep_comp_descriptor *desc;	int max_tx;	/* The SuperSpeed endpoint companion descriptor is supposed to	 * be the first thing immediately following the endpoint descriptor.	 */	desc = (struct usb_ss_ep_comp_descriptor *) buffer;	if (desc->bDescriptorType != USB_DT_SS_ENDPOINT_COMP ||			size < USB_DT_SS_EP_COMP_SIZE) {		dev_warn(ddev, "No SuperSpeed endpoint companion for config %d "				" interface %d altsetting %d ep %d: "				"using minimum values/n",				cfgno, inum, asnum, ep->desc.bEndpointAddress);		/* Fill in some default values.		 * Leave bmAttributes as zero, which will mean no streams for		 * bulk, and isoc won't support multiple bursts of packets.		 * With bursts of only one packet, and a Mult of 1, the max		 * amount of data moved per endpoint service interval is one		 * packet.		 */		ep->ss_ep_comp.bLength = USB_DT_SS_EP_COMP_SIZE;		ep->ss_ep_comp.bDescriptorType = USB_DT_SS_ENDPOINT_COMP;		if (usb_endpoint_xfer_isoc(&ep->desc) ||				usb_endpoint_xfer_int(&ep->desc))			ep->ss_ep_comp.wBytesPerInterval =					ep->desc.wMaxPacketSize;		return;	}	memcpy(&ep->ss_ep_comp, desc, USB_DT_SS_EP_COMP_SIZE);	/* Check the various values */	if (usb_endpoint_xfer_control(&ep->desc) && desc->bMaxBurst != 0) {		dev_warn(ddev, "Control endpoint with bMaxBurst = %d in "				"config %d interface %d altsetting %d ep %d: "				"setting to zero/n", desc->bMaxBurst,				cfgno, inum, asnum, ep->desc.bEndpointAddress);		ep->ss_ep_comp.bMaxBurst = 0;	} else if (desc->bMaxBurst > 15) {		dev_warn(ddev, "Endpoint with bMaxBurst = %d in "				"config %d interface %d altsetting %d ep %d: "				"setting to 15/n", desc->bMaxBurst,				cfgno, inum, asnum, ep->desc.bEndpointAddress);		ep->ss_ep_comp.bMaxBurst = 15;	}	if ((usb_endpoint_xfer_control(&ep->desc) ||			usb_endpoint_xfer_int(&ep->desc)) &&				desc->bmAttributes != 0) {		dev_warn(ddev, "%s endpoint with bmAttributes = %d in "				"config %d interface %d altsetting %d ep %d: "				"setting to zero/n",				usb_endpoint_xfer_control(&ep->desc) ? "Control" : "Bulk",				desc->bmAttributes,				cfgno, inum, asnum, ep->desc.bEndpointAddress);		ep->ss_ep_comp.bmAttributes = 0;	} else if (usb_endpoint_xfer_bulk(&ep->desc) &&			desc->bmAttributes > 16) {		dev_warn(ddev, "Bulk endpoint with more than 65536 streams in "				"config %d interface %d altsetting %d ep %d: "				"setting to max/n",				cfgno, inum, asnum, ep->desc.bEndpointAddress);		ep->ss_ep_comp.bmAttributes = 16;	} else if (usb_endpoint_xfer_isoc(&ep->desc) &&			desc->bmAttributes > 2) {		dev_warn(ddev, "Isoc endpoint has Mult of %d in "				"config %d interface %d altsetting %d ep %d: "				"setting to 3/n", desc->bmAttributes + 1,				cfgno, inum, asnum, ep->desc.bEndpointAddress);		ep->ss_ep_comp.bmAttributes = 2;	}	if (usb_endpoint_xfer_isoc(&ep->desc))		max_tx = (desc->bMaxBurst + 1) * (desc->bmAttributes + 1) *			usb_endpoint_maxp(&ep->desc);	else if (usb_endpoint_xfer_int(&ep->desc))		max_tx = usb_endpoint_maxp(&ep->desc) *			(desc->bMaxBurst + 1);	else		max_tx = 999999;	if (le16_to_cpu(desc->wBytesPerInterval) > max_tx) {		dev_warn(ddev, "%s endpoint with wBytesPerInterval of %d in "				"config %d interface %d altsetting %d ep %d: "				"setting to %d/n",				usb_endpoint_xfer_isoc(&ep->desc) ? "Isoc" : "Int",				le16_to_cpu(desc->wBytesPerInterval),				cfgno, inum, asnum, ep->desc.bEndpointAddress,				max_tx);		ep->ss_ep_comp.wBytesPerInterval = cpu_to_le16(max_tx);	}}
开发者ID:7799,项目名称:linux,代码行数:96,


示例18: usbtmc_ioctl_clear

static int usbtmc_ioctl_clear(struct usbtmc_device_data *data){	struct usb_host_interface *current_setting;	struct usb_endpoint_descriptor *desc;	struct device *dev;	u8 *buffer;	int rv;	int n;	int actual = 0;	int max_size;	dev = &data->intf->dev;	dev_dbg(dev, "Sending INITIATE_CLEAR request/n");	buffer = kmalloc(USBTMC_SIZE_IOBUFFER, GFP_KERNEL);	if (!buffer)		return -ENOMEM;	rv = usb_control_msg(data->usb_dev,			     usb_rcvctrlpipe(data->usb_dev, 0),			     USBTMC_REQUEST_INITIATE_CLEAR,			     USB_DIR_IN | USB_TYPE_CLASS | USB_RECIP_INTERFACE,			     0, 0, buffer, 1, USBTMC_TIMEOUT);	if (rv < 0) {		dev_err(dev, "usb_control_msg returned %d/n", rv);		goto exit;	}	dev_dbg(dev, "INITIATE_CLEAR returned %x/n", buffer[0]);	if (buffer[0] != USBTMC_STATUS_SUCCESS) {		dev_err(dev, "INITIATE_CLEAR returned %x/n", buffer[0]);		rv = -EPERM;		goto exit;	}	max_size = 0;	current_setting = data->intf->cur_altsetting;	for (n = 0; n < current_setting->desc.bNumEndpoints; n++) {		desc = &current_setting->endpoint[n].desc;		if (desc->bEndpointAddress == data->bulk_in)			max_size = usb_endpoint_maxp(desc);	}	if (max_size == 0) {		dev_err(dev, "Couldn't get wMaxPacketSize/n");		rv = -EPERM;		goto exit;	}	dev_dbg(dev, "wMaxPacketSize is %d/n", max_size);	n = 0;usbtmc_clear_check_status:	dev_dbg(dev, "Sending CHECK_CLEAR_STATUS request/n");	rv = usb_control_msg(data->usb_dev,			     usb_rcvctrlpipe(data->usb_dev, 0),			     USBTMC_REQUEST_CHECK_CLEAR_STATUS,			     USB_DIR_IN | USB_TYPE_CLASS | USB_RECIP_INTERFACE,			     0, 0, buffer, 2, USBTMC_TIMEOUT);	if (rv < 0) {		dev_err(dev, "usb_control_msg returned %d/n", rv);		goto exit;	}	dev_dbg(dev, "CHECK_CLEAR_STATUS returned %x/n", buffer[0]);	if (buffer[0] == USBTMC_STATUS_SUCCESS)		goto usbtmc_clear_bulk_out_halt;	if (buffer[0] != USBTMC_STATUS_PENDING) {		dev_err(dev, "CHECK_CLEAR_STATUS returned %x/n", buffer[0]);		rv = -EPERM;		goto exit;	}	if (buffer[1] == 1)		do {			dev_dbg(dev, "Reading from bulk in EP/n");			rv = usb_bulk_msg(data->usb_dev,					  usb_rcvbulkpipe(data->usb_dev,							  data->bulk_in),					  buffer, USBTMC_SIZE_IOBUFFER,					  &actual, USBTMC_TIMEOUT);			n++;			if (rv < 0) {				dev_err(dev, "usb_control_msg returned %d/n",					rv);				goto exit;			}		} while ((actual == max_size) &&			  (n < USBTMC_MAX_READS_TO_CLEAR_BULK_IN));	if (actual == max_size) {//.........这里部分代码省略.........
开发者ID:acton393,项目名称:linux,代码行数:101,


示例19: usbtmc_ioctl_abort_bulk_in

static int usbtmc_ioctl_abort_bulk_in(struct usbtmc_device_data *data){	u8 *buffer;	struct device *dev;	int rv;	int n;	int actual;	struct usb_host_interface *current_setting;	int max_size;	dev = &data->intf->dev;	buffer = kmalloc(USBTMC_SIZE_IOBUFFER, GFP_KERNEL);	if (!buffer)		return -ENOMEM;	rv = usb_control_msg(data->usb_dev,			     usb_rcvctrlpipe(data->usb_dev, 0),			     USBTMC_REQUEST_INITIATE_ABORT_BULK_IN,			     USB_DIR_IN | USB_TYPE_CLASS | USB_RECIP_ENDPOINT,			     data->bTag_last_read, data->bulk_in,			     buffer, 2, USBTMC_TIMEOUT);	if (rv < 0) {		dev_err(dev, "usb_control_msg returned %d/n", rv);		goto exit;	}	dev_dbg(dev, "INITIATE_ABORT_BULK_IN returned %x/n", buffer[0]);	if (buffer[0] == USBTMC_STATUS_FAILED) {		rv = 0;		goto exit;	}	if (buffer[0] != USBTMC_STATUS_SUCCESS) {		dev_err(dev, "INITIATE_ABORT_BULK_IN returned %x/n",			buffer[0]);		rv = -EPERM;		goto exit;	}	max_size = 0;	current_setting = data->intf->cur_altsetting;	for (n = 0; n < current_setting->desc.bNumEndpoints; n++)		if (current_setting->endpoint[n].desc.bEndpointAddress ==			data->bulk_in)			max_size = usb_endpoint_maxp(&current_setting->endpoint[n].desc);	if (max_size == 0) {		dev_err(dev, "Couldn't get wMaxPacketSize/n");		rv = -EPERM;		goto exit;	}	dev_dbg(&data->intf->dev, "wMaxPacketSize is %d/n", max_size);	n = 0;	do {		dev_dbg(dev, "Reading from bulk in EP/n");		rv = usb_bulk_msg(data->usb_dev,				  usb_rcvbulkpipe(data->usb_dev,						  data->bulk_in),				  buffer, USBTMC_SIZE_IOBUFFER,				  &actual, USBTMC_TIMEOUT);		n++;		if (rv < 0) {			dev_err(dev, "usb_bulk_msg returned %d/n", rv);			goto exit;		}	} while ((actual == max_size) &&		 (n < USBTMC_MAX_READS_TO_CLEAR_BULK_IN));	if (actual == max_size) {		dev_err(dev, "Couldn't clear device buffer within %d cycles/n",			USBTMC_MAX_READS_TO_CLEAR_BULK_IN);		rv = -EPERM;		goto exit;	}	n = 0;usbtmc_abort_bulk_in_status:	rv = usb_control_msg(data->usb_dev,			     usb_rcvctrlpipe(data->usb_dev, 0),			     USBTMC_REQUEST_CHECK_ABORT_BULK_IN_STATUS,			     USB_DIR_IN | USB_TYPE_CLASS | USB_RECIP_ENDPOINT,			     0, data->bulk_in, buffer, 0x08,			     USBTMC_TIMEOUT);	if (rv < 0) {		dev_err(dev, "usb_control_msg returned %d/n", rv);		goto exit;	}	dev_dbg(dev, "INITIATE_ABORT_BULK_IN returned %x/n", buffer[0]);//.........这里部分代码省略.........
开发者ID:acton393,项目名称:linux,代码行数:101,


示例20: usbtmc_probe

static int usbtmc_probe(struct usb_interface *intf,			const struct usb_device_id *id){	struct usbtmc_device_data *data;	struct usb_host_interface *iface_desc;	struct usb_endpoint_descriptor *endpoint;	int n;	int retcode;	dev_dbg(&intf->dev, "%s called/n", __func__);	data = kmalloc(sizeof(*data), GFP_KERNEL);	if (!data)		return -ENOMEM;	data->intf = intf;	data->id = id;	data->usb_dev = usb_get_dev(interface_to_usbdev(intf));	usb_set_intfdata(intf, data);	kref_init(&data->kref);	mutex_init(&data->io_mutex);	init_waitqueue_head(&data->waitq);	atomic_set(&data->iin_data_valid, 0);	atomic_set(&data->srq_asserted, 0);	data->zombie = 0;	/* Determine if it is a Rigol or not */	data->rigol_quirk = 0;	dev_dbg(&intf->dev, "Trying to find if device Vendor 0x%04X Product 0x%04X has the RIGOL quirk/n",		le16_to_cpu(data->usb_dev->descriptor.idVendor),		le16_to_cpu(data->usb_dev->descriptor.idProduct));	for(n = 0; usbtmc_id_quirk[n].idVendor > 0; n++) {		if ((usbtmc_id_quirk[n].idVendor == le16_to_cpu(data->usb_dev->descriptor.idVendor)) &&		    (usbtmc_id_quirk[n].idProduct == le16_to_cpu(data->usb_dev->descriptor.idProduct))) {			dev_dbg(&intf->dev, "Setting this device as having the RIGOL quirk/n");			data->rigol_quirk = 1;			break;		}	}	/* Initialize USBTMC bTag and other fields */	data->bTag	= 1;	data->TermCharEnabled = 0;	data->TermChar = '/n';	/*  2 <= bTag <= 127   USBTMC-USB488 subclass specification 4.3.1 */	data->iin_bTag = 2;	/* USBTMC devices have only one setting, so use that */	iface_desc = data->intf->cur_altsetting;	data->ifnum = iface_desc->desc.bInterfaceNumber;	/* Find bulk in endpoint */	for (n = 0; n < iface_desc->desc.bNumEndpoints; n++) {		endpoint = &iface_desc->endpoint[n].desc;		if (usb_endpoint_is_bulk_in(endpoint)) {			data->bulk_in = endpoint->bEndpointAddress;			dev_dbg(&intf->dev, "Found bulk in endpoint at %u/n",				data->bulk_in);			break;		}	}	/* Find bulk out endpoint */	for (n = 0; n < iface_desc->desc.bNumEndpoints; n++) {		endpoint = &iface_desc->endpoint[n].desc;		if (usb_endpoint_is_bulk_out(endpoint)) {			data->bulk_out = endpoint->bEndpointAddress;			dev_dbg(&intf->dev, "Found Bulk out endpoint at %u/n",				data->bulk_out);			break;		}	}	/* Find int endpoint */	for (n = 0; n < iface_desc->desc.bNumEndpoints; n++) {		endpoint = &iface_desc->endpoint[n].desc;		if (usb_endpoint_is_int_in(endpoint)) {			data->iin_ep_present = 1;			data->iin_ep = endpoint->bEndpointAddress;			data->iin_wMaxPacketSize = usb_endpoint_maxp(endpoint);			data->iin_interval = endpoint->bInterval;			dev_dbg(&intf->dev, "Found Int in endpoint at %u/n",				data->iin_ep);			break;		}	}	retcode = get_capabilities(data);	if (retcode)		dev_err(&intf->dev, "can't read capabilities/n");	else		retcode = sysfs_create_group(&intf->dev.kobj,					     &capability_attr_grp);	if (data->iin_ep_present) {		/* allocate int urb */		data->iin_urb = usb_alloc_urb(0, GFP_KERNEL);		if (!data->iin_urb)//.........这里部分代码省略.........
开发者ID:acton393,项目名称:linux,代码行数:101,


示例21: usb_parse_endpoint

//.........这里部分代码省略.........		}	} 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) {		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 (usb_endpoint_maxp(&endpoint->desc) > 8)			endpoint->desc.wMaxPacketSize = cpu_to_le16(8);	}	/* Validate the wMaxPacketSize field */	maxp = usb_endpoint_maxp(&endpoint->desc);	/* Find the highest legal maxpacket size for this endpoint */	i = 0;		/* additional transactions per microframe */	switch (to_usb_device(ddev)->speed) {	case USB_SPEED_LOW:		maxpacket_maxes = low_speed_maxpacket_maxes;		break;	case USB_SPEED_FULL:		maxpacket_maxes = full_speed_maxpacket_maxes;		break;	case USB_SPEED_HIGH:		/* Bits 12..11 are allowed only for HS periodic endpoints */		if (usb_endpoint_xfer_int(d) || usb_endpoint_xfer_isoc(d)) {			i = maxp & (BIT(12) | BIT(11));			maxp &= ~i;		}		/* fallthrough */	default:		maxpacket_maxes = high_speed_maxpacket_maxes;		break;	case USB_SPEED_SUPER:	case USB_SPEED_SUPER_PLUS:		maxpacket_maxes = super_speed_maxpacket_maxes;		break;	}	j = maxpacket_maxes[usb_endpoint_type(&endpoint->desc)];
开发者ID:acton393,项目名称:linux,代码行数:66,


示例22: xhci_check_maxpacket

/* * Full speed devices may have a max packet size greater than 8 bytes, but the * USB core doesn't know that until it reads the first 8 bytes of the * descriptor.  If the usb_device's max packet size changes after that point, * we need to issue an evaluate context command and wait on it. */static int xhci_check_maxpacket(struct xhci_hcd *xhci, unsigned int slot_id,		unsigned int ep_index, struct urb *urb){	struct xhci_container_ctx *out_ctx;	struct xhci_input_control_ctx *ctrl_ctx;	struct xhci_ep_ctx *ep_ctx;	struct xhci_command *command;	int max_packet_size;	int hw_max_packet_size;	int ret = 0;	out_ctx = xhci->devs[slot_id]->out_ctx;	ep_ctx = xhci_get_ep_ctx(xhci, out_ctx, ep_index);	hw_max_packet_size = MAX_PACKET_DECODED(le32_to_cpu(ep_ctx->ep_info2));	max_packet_size = usb_endpoint_maxp(&urb->dev->ep0.desc);	if (hw_max_packet_size != max_packet_size) {		xhci_dbg_trace(xhci,  trace_xhci_dbg_context_change,				"Max Packet Size for ep 0 changed.");		xhci_dbg_trace(xhci,  trace_xhci_dbg_context_change,				"Max packet size in usb_device = %d",				max_packet_size);		xhci_dbg_trace(xhci,  trace_xhci_dbg_context_change,				"Max packet size in xHCI HW = %d",				hw_max_packet_size);		xhci_dbg_trace(xhci,  trace_xhci_dbg_context_change,				"Issuing evaluate context command.");		/* Set up the input context flags for the command */		/* FIXME: This won't work if a non-default control endpoint		 * changes max packet sizes.		 */		command = xhci_alloc_command(xhci, false, true, GFP_KERNEL);		if (!command)			return -ENOMEM;		command->in_ctx = xhci->devs[slot_id]->in_ctx;		ctrl_ctx = xhci_get_input_control_ctx(command->in_ctx);		if (!ctrl_ctx) {			xhci_warn(xhci, "%s: Could not get input context, bad type./n",					__func__);			ret = -ENOMEM;			goto command_cleanup;		}		/* Set up the modified control endpoint 0 */		xhci_endpoint_copy(xhci, xhci->devs[slot_id]->in_ctx,				xhci->devs[slot_id]->out_ctx, ep_index);		ep_ctx = xhci_get_ep_ctx(xhci, command->in_ctx, ep_index);		ep_ctx->ep_info2 &= cpu_to_le32(~MAX_PACKET_MASK);		ep_ctx->ep_info2 |= cpu_to_le32(MAX_PACKET(max_packet_size));		ctrl_ctx->add_flags = cpu_to_le32(EP0_FLAG);		ctrl_ctx->drop_flags = 0;		xhci_dbg(xhci, "Slot %d input context/n", slot_id);		xhci_dbg_ctx(xhci, command->in_ctx, ep_index);		xhci_dbg(xhci, "Slot %d output context/n", slot_id);		xhci_dbg_ctx(xhci, out_ctx, ep_index);		ret = xhci_configure_endpoint(xhci, urb->dev, command,				true, false);		/* Clean up the input context for later use by bandwidth		 * functions.		 */		ctrl_ctx->add_flags = cpu_to_le32(SLOT_FLAG);command_cleanup:		kfree(command->completion);		kfree(command);	}	return ret;}
开发者ID:redareda9,项目名称:linux,代码行数:79,


示例23: wdm_probe

static int wdm_probe(struct usb_interface *intf, const struct usb_device_id *id){	int rv = -EINVAL;	struct usb_device *udev = interface_to_usbdev(intf);	struct wdm_device *desc;	struct usb_host_interface *iface;	struct usb_endpoint_descriptor *ep;	struct usb_cdc_dmm_desc *dmhd;	u8 *buffer = intf->altsetting->extra;	int buflen = intf->altsetting->extralen;	u16 maxcom = 0;	if (!buffer)		goto out;	while (buflen > 2) {		if (buffer [1] != USB_DT_CS_INTERFACE) {			dev_err(&intf->dev, "skipping garbage/n");			goto next_desc;		}		switch (buffer [2]) {		case USB_CDC_HEADER_TYPE:			break;		case USB_CDC_DMM_TYPE:			dmhd = (struct usb_cdc_dmm_desc *)buffer;			maxcom = le16_to_cpu(dmhd->wMaxCommand);			dev_dbg(&intf->dev,				"Finding maximum buffer length: %d", maxcom);			break;		default:			dev_err(&intf->dev,				"Ignoring extra header, type %d, length %d/n",				buffer[2], buffer[0]);			break;		}next_desc:		buflen -= buffer[0];		buffer += buffer[0];	}	rv = -ENOMEM;	desc = kzalloc(sizeof(struct wdm_device), GFP_KERNEL);	if (!desc)		goto out;	mutex_init(&desc->lock);	spin_lock_init(&desc->iuspin);	init_waitqueue_head(&desc->wait);	desc->wMaxCommand = maxcom;	/* this will be expanded and needed in hardware endianness */	desc->inum = cpu_to_le16((u16)intf->cur_altsetting->desc.bInterfaceNumber);	desc->intf = intf;	INIT_WORK(&desc->rxwork, wdm_rxwork);	rv = -EINVAL;	iface = intf->cur_altsetting;	if (iface->desc.bNumEndpoints != 1)		goto err;	ep = &iface->endpoint[0].desc;	if (!ep || !usb_endpoint_is_int_in(ep))		goto err;	desc->wMaxPacketSize = usb_endpoint_maxp(ep);	desc->bMaxPacketSize0 = udev->descriptor.bMaxPacketSize0;	desc->orq = kmalloc(sizeof(struct usb_ctrlrequest), GFP_KERNEL);	if (!desc->orq)		goto err;	desc->irq = kmalloc(sizeof(struct usb_ctrlrequest), GFP_KERNEL);	if (!desc->irq)		goto err;	desc->validity = usb_alloc_urb(0, GFP_KERNEL);	if (!desc->validity)		goto err;	desc->response = usb_alloc_urb(0, GFP_KERNEL);	if (!desc->response)		goto err;	desc->command = usb_alloc_urb(0, GFP_KERNEL);	if (!desc->command)		goto err;	desc->ubuf = kmalloc(desc->wMaxCommand, GFP_KERNEL);	if (!desc->ubuf)		goto err;	desc->sbuf = usb_alloc_coherent(interface_to_usbdev(intf),					desc->wMaxPacketSize,					GFP_KERNEL,					&desc->validity->transfer_dma);	if (!desc->sbuf)		goto err;	desc->inbuf = usb_alloc_coherent(interface_to_usbdev(intf),					 desc->bMaxPacketSize0,					 GFP_KERNEL,					 &desc->response->transfer_dma);	if (!desc->inbuf)//.........这里部分代码省略.........
开发者ID:454053205,项目名称:linux,代码行数:101,


示例24: adu_probe

/** * adu_probe * * Called by the usb core when a new device is connected that it thinks * this driver might be interested in. */static int adu_probe(struct usb_interface *interface,		     const struct usb_device_id *id){	struct usb_device *udev = interface_to_usbdev(interface);	struct adu_device *dev = NULL;	struct usb_host_interface *iface_desc;	struct usb_endpoint_descriptor *endpoint;	int retval = -ENODEV;	int in_end_size;	int out_end_size;	int i;	dbg(2," %s : enter", __func__);	if (udev == NULL) {		dev_err(&interface->dev, "udev is NULL./n");		goto exit;	}	/* allocate memory for our device state and initialize it */	dev = kzalloc(sizeof(struct adu_device), GFP_KERNEL);	if (dev == NULL) {		dev_err(&interface->dev, "Out of memory/n");		retval = -ENOMEM;		goto exit;	}	mutex_init(&dev->mtx);	spin_lock_init(&dev->buflock);	dev->udev = udev;	init_waitqueue_head(&dev->read_wait);	init_waitqueue_head(&dev->write_wait);	iface_desc = &interface->altsetting[0];	/* set up the endpoint information */	for (i = 0; i < iface_desc->desc.bNumEndpoints; ++i) {		endpoint = &iface_desc->endpoint[i].desc;		if (usb_endpoint_is_int_in(endpoint))			dev->interrupt_in_endpoint = endpoint;		if (usb_endpoint_is_int_out(endpoint))			dev->interrupt_out_endpoint = endpoint;	}	if (dev->interrupt_in_endpoint == NULL) {		dev_err(&interface->dev, "interrupt in endpoint not found/n");		goto error;	}	if (dev->interrupt_out_endpoint == NULL) {		dev_err(&interface->dev, "interrupt out endpoint not found/n");		goto error;	}	in_end_size = usb_endpoint_maxp(dev->interrupt_in_endpoint);	out_end_size = usb_endpoint_maxp(dev->interrupt_out_endpoint);	dev->read_buffer_primary = kmalloc((4 * in_end_size), GFP_KERNEL);	if (!dev->read_buffer_primary) {		dev_err(&interface->dev, "Couldn't allocate read_buffer_primary/n");		retval = -ENOMEM;		goto error;	}	/* debug code prime the buffer */	memset(dev->read_buffer_primary, 'a', in_end_size);	memset(dev->read_buffer_primary + in_end_size, 'b', in_end_size);	memset(dev->read_buffer_primary + (2 * in_end_size), 'c', in_end_size);	memset(dev->read_buffer_primary + (3 * in_end_size), 'd', in_end_size);	dev->read_buffer_secondary = kmalloc((4 * in_end_size), GFP_KERNEL);	if (!dev->read_buffer_secondary) {		dev_err(&interface->dev, "Couldn't allocate read_buffer_secondary/n");		retval = -ENOMEM;		goto error;	}	/* debug code prime the buffer */	memset(dev->read_buffer_secondary, 'e', in_end_size);	memset(dev->read_buffer_secondary + in_end_size, 'f', in_end_size);	memset(dev->read_buffer_secondary + (2 * in_end_size), 'g', in_end_size);	memset(dev->read_buffer_secondary + (3 * in_end_size), 'h', in_end_size);	dev->interrupt_in_buffer = kmalloc(in_end_size, GFP_KERNEL);	if (!dev->interrupt_in_buffer) {		dev_err(&interface->dev, "Couldn't allocate interrupt_in_buffer/n");		goto error;	}	/* debug code prime the buffer */	memset(dev->interrupt_in_buffer, 'i', in_end_size);	dev->interrupt_in_urb = usb_alloc_urb(0, GFP_KERNEL);	if (!dev->interrupt_in_urb) {//.........这里部分代码省略.........
开发者ID:AbdulrahmanAmir,项目名称:Dorimanx-LG-G2-D802-Kernel,代码行数:101,


示例25: adu_write

static ssize_t adu_write(struct file *file, const __user char *buffer,			 size_t count, loff_t *ppos){	DECLARE_WAITQUEUE(waita, current);	struct adu_device *dev;	size_t bytes_written = 0;	size_t bytes_to_write;	size_t buffer_size;	unsigned long flags;	int retval;	dbg(2," %s : enter, count = %Zd", __func__, count);	dev = file->private_data;	retval = mutex_lock_interruptible(&dev->mtx);	if (retval)		goto exit_nolock;	/* verify that the device wasn't unplugged */	if (dev->udev == NULL) {		retval = -ENODEV;		printk(KERN_ERR "adutux: No device or device unplugged %d/n",		       retval);		goto exit;	}	/* verify that we actually have some data to write */	if (count == 0) {		dbg(1," %s : write request of 0 bytes", __func__);		goto exit;	}	while (count > 0) {		add_wait_queue(&dev->write_wait, &waita);		set_current_state(TASK_INTERRUPTIBLE);		spin_lock_irqsave(&dev->buflock, flags);		if (!dev->out_urb_finished) {			spin_unlock_irqrestore(&dev->buflock, flags);			mutex_unlock(&dev->mtx);			if (signal_pending(current)) {				dbg(1," %s : interrupted", __func__);				set_current_state(TASK_RUNNING);				retval = -EINTR;				goto exit_onqueue;			}			if (schedule_timeout(COMMAND_TIMEOUT) == 0) {				dbg(1, "%s - command timed out.", __func__);				retval = -ETIMEDOUT;				goto exit_onqueue;			}			remove_wait_queue(&dev->write_wait, &waita);			retval = mutex_lock_interruptible(&dev->mtx);			if (retval) {				retval = bytes_written ? bytes_written : retval;				goto exit_nolock;			}			dbg(4," %s : in progress, count = %Zd", __func__, count);		} else {			spin_unlock_irqrestore(&dev->buflock, flags);			set_current_state(TASK_RUNNING);			remove_wait_queue(&dev->write_wait, &waita);			dbg(4," %s : sending, count = %Zd", __func__, count);			/* write the data into interrupt_out_buffer from userspace */			buffer_size = usb_endpoint_maxp(dev->interrupt_out_endpoint);			bytes_to_write = count > buffer_size ? buffer_size : count;			dbg(4," %s : buffer_size = %Zd, count = %Zd, bytes_to_write = %Zd",			    __func__, buffer_size, count, bytes_to_write);			if (copy_from_user(dev->interrupt_out_buffer, buffer, bytes_to_write) != 0) {				retval = -EFAULT;				goto exit;			}			/* send off the urb */			usb_fill_int_urb(				dev->interrupt_out_urb,				dev->udev,				usb_sndintpipe(dev->udev, dev->interrupt_out_endpoint->bEndpointAddress),				dev->interrupt_out_buffer,				bytes_to_write,				adu_interrupt_out_callback,				dev,				dev->interrupt_out_endpoint->bInterval);			dev->interrupt_out_urb->actual_length = bytes_to_write;			dev->out_urb_finished = 0;			retval = usb_submit_urb(dev->interrupt_out_urb, GFP_KERNEL);			if (retval < 0) {				dev->out_urb_finished = 1;				dev_err(&dev->udev->dev, "Couldn't submit "					"interrupt_out_urb %d/n", retval);				goto exit;			}			buffer += bytes_to_write;			count -= bytes_to_write;//.........这里部分代码省略.........
开发者ID:AbdulrahmanAmir,项目名称:Dorimanx-LG-G2-D802-Kernel,代码行数:101,


示例26: adu_read

static ssize_t adu_read(struct file *file, __user char *buffer, size_t count,			loff_t *ppos){	struct adu_device *dev;	size_t bytes_read = 0;	size_t bytes_to_read = count;	int i;	int retval = 0;	int timeout = 0;	int should_submit = 0;	unsigned long flags;	DECLARE_WAITQUEUE(wait, current);	dbg(2," %s : enter, count = %Zd, file=%p", __func__, count, file);	dev = file->private_data;	dbg(2," %s : dev=%p", __func__, dev);	if (mutex_lock_interruptible(&dev->mtx))		return -ERESTARTSYS;	/* verify that the device wasn't unplugged */	if (dev->udev == NULL) {		retval = -ENODEV;		printk(KERN_ERR "adutux: No device or device unplugged %d/n",		       retval);		goto exit;	}	/* verify that some data was requested */	if (count == 0) {		dbg(1," %s : read request of 0 bytes", __func__);		goto exit;	}	timeout = COMMAND_TIMEOUT;	dbg(2," %s : about to start looping", __func__);	while (bytes_to_read) {		int data_in_secondary = dev->secondary_tail - dev->secondary_head;		dbg(2," %s : while, data_in_secondary=%d, status=%d",		    __func__, data_in_secondary,		    dev->interrupt_in_urb->status);		if (data_in_secondary) {			/* drain secondary buffer */			int amount = bytes_to_read < data_in_secondary ? bytes_to_read : data_in_secondary;			i = copy_to_user(buffer, dev->read_buffer_secondary+dev->secondary_head, amount);			if (i) {				retval = -EFAULT;				goto exit;			}			dev->secondary_head += (amount - i);			bytes_read += (amount - i);			bytes_to_read -= (amount - i);			if (i) {				retval = bytes_read ? bytes_read : -EFAULT;				goto exit;			}		} else {			/* we check the primary buffer */			spin_lock_irqsave (&dev->buflock, flags);			if (dev->read_buffer_length) {				/* we secure access to the primary */				char *tmp;				dbg(2," %s : swap, read_buffer_length = %d",				    __func__, dev->read_buffer_length);				tmp = dev->read_buffer_secondary;				dev->read_buffer_secondary = dev->read_buffer_primary;				dev->read_buffer_primary = tmp;				dev->secondary_head = 0;				dev->secondary_tail = dev->read_buffer_length;				dev->read_buffer_length = 0;				spin_unlock_irqrestore(&dev->buflock, flags);				/* we have a free buffer so use it */				should_submit = 1;			} else {				/* even the primary was empty - we may need to do IO */				if (!dev->read_urb_finished) {					/* somebody is doing IO */					spin_unlock_irqrestore(&dev->buflock, flags);					dbg(2," %s : submitted already", __func__);				} else {					/* we must initiate input */					dbg(2," %s : initiate input", __func__);					dev->read_urb_finished = 0;					spin_unlock_irqrestore(&dev->buflock, flags);					usb_fill_int_urb(dev->interrupt_in_urb,dev->udev,							 usb_rcvintpipe(dev->udev,							 		dev->interrupt_in_endpoint->bEndpointAddress),							 dev->interrupt_in_buffer,							 usb_endpoint_maxp(dev->interrupt_in_endpoint),							 adu_interrupt_in_callback,							 dev,							 dev->interrupt_in_endpoint->bInterval);					retval = usb_submit_urb(dev->interrupt_in_urb, GFP_KERNEL);					if (retval) {						dev->read_urb_finished = 1;						if (retval == -ENOMEM) {							retval = bytes_read ? bytes_read : -ENOMEM;//.........这里部分代码省略.........
开发者ID:AbdulrahmanAmir,项目名称:Dorimanx-LG-G2-D802-Kernel,代码行数:101,


示例27: adu_open

static int adu_open(struct inode *inode, struct file *file){	struct adu_device *dev = NULL;	struct usb_interface *interface;	int subminor;	int retval;	dbg(2,"%s : enter", __func__);	subminor = iminor(inode);	if ((retval = mutex_lock_interruptible(&adutux_mutex))) {		dbg(2, "%s : mutex lock failed", __func__);		goto exit_no_lock;	}	interface = usb_find_interface(&adu_driver, subminor);	if (!interface) {		printk(KERN_ERR "adutux: %s - error, can't find device for "		       "minor %d/n", __func__, subminor);		retval = -ENODEV;		goto exit_no_device;	}	dev = usb_get_intfdata(interface);	if (!dev || !dev->udev) {		retval = -ENODEV;		goto exit_no_device;	}	/* check that nobody else is using the device */	if (dev->open_count) {		retval = -EBUSY;		goto exit_no_device;	}	++dev->open_count;	dbg(2,"%s : open count %d", __func__, dev->open_count);	/* save device in the file's private structure */	file->private_data = dev;	/* initialize in direction */	dev->read_buffer_length = 0;	/* fixup first read by having urb waiting for it */	usb_fill_int_urb(dev->interrupt_in_urb,dev->udev,			 usb_rcvintpipe(dev->udev,					dev->interrupt_in_endpoint->bEndpointAddress),			 dev->interrupt_in_buffer,			 usb_endpoint_maxp(dev->interrupt_in_endpoint),			 adu_interrupt_in_callback, dev,			 dev->interrupt_in_endpoint->bInterval);	dev->read_urb_finished = 0;	if (usb_submit_urb(dev->interrupt_in_urb, GFP_KERNEL))		dev->read_urb_finished = 1;	/* we ignore failure */	/* end of fixup for first read */	/* initialize out direction */	dev->out_urb_finished = 1;	retval = 0;exit_no_device:	mutex_unlock(&adutux_mutex);exit_no_lock:	dbg(2,"%s : leave, return value %d ", __func__, retval);	return retval;}
开发者ID:AbdulrahmanAmir,项目名称:Dorimanx-LG-G2-D802-Kernel,代码行数:70,


示例28: lcd_probe

static int lcd_probe(struct usb_interface *interface,		     const struct usb_device_id *id){	struct usb_lcd *dev = NULL;	struct usb_endpoint_descriptor *bulk_in, *bulk_out;	int i;	int retval;	/* allocate memory for our device state and initialize it */	dev = kzalloc(sizeof(*dev), GFP_KERNEL);	if (!dev)		return -ENOMEM;	kref_init(&dev->kref);	sema_init(&dev->limit_sem, USB_LCD_CONCURRENT_WRITES);	init_usb_anchor(&dev->submitted);	dev->udev = usb_get_dev(interface_to_usbdev(interface));	dev->interface = interface;	if (le16_to_cpu(dev->udev->descriptor.idProduct) != 0x0001) {		dev_warn(&interface->dev, "USBLCD model not supported./n");		retval = -ENODEV;		goto error;	}	/* set up the endpoint information */	/* use only the first bulk-in and bulk-out endpoints */	retval = usb_find_common_endpoints(interface->cur_altsetting,			&bulk_in, &bulk_out, NULL, NULL);	if (retval) {		dev_err(&interface->dev,			"Could not find both bulk-in and bulk-out endpoints/n");		goto error;	}	dev->bulk_in_size = usb_endpoint_maxp(bulk_in);	dev->bulk_in_endpointAddr = bulk_in->bEndpointAddress;	dev->bulk_in_buffer = kmalloc(dev->bulk_in_size, GFP_KERNEL);	if (!dev->bulk_in_buffer) {		retval = -ENOMEM;		goto error;	}	dev->bulk_out_endpointAddr = bulk_out->bEndpointAddress;	/* save our data pointer in this interface device */	usb_set_intfdata(interface, dev);	/* we can register the device now, as it is ready */	retval = usb_register_dev(interface, &lcd_class);	if (retval) {		/* something prevented us from registering this driver */		dev_err(&interface->dev,			"Not able to get a minor for this device./n");		usb_set_intfdata(interface, NULL);		goto error;	}	i = le16_to_cpu(dev->udev->descriptor.bcdDevice);	dev_info(&interface->dev, "USBLCD Version %1d%1d.%1d%1d found "		 "at address %d/n", (i & 0xF000)>>12, (i & 0xF00)>>8,		 (i & 0xF0)>>4, (i & 0xF), dev->udev->devnum);	/* let the user know what node this device is now attached to */	dev_info(&interface->dev, "USB LCD device now attached to USBLCD-%d/n",		 interface->minor);	return 0;error:	kref_put(&dev->kref, lcd_delete);	return retval;}
开发者ID:asmalldev,项目名称:linux,代码行数:74,



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


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