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

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

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

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

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

示例1: UMAS_BulkTransport

int  UMAS_BulkTransport(SCSI_CMD_T *srb, UMAS_DATA_T *umas){    int     result, status = 0;    int     pipe;    uint32_t    partial;    struct bulk_cb_wrap  bcb;    struct bulk_cs_wrap  bcs;    /* if the device was removed, then we're already reset */    if(!umas->pusb_dev)        return SUCCESS;    /* set up the command wrapper */    bcb.Signature = UMAS_BULK_CB_SIGN;    bcb.DataTransferLength = usb_stor_transfer_length(srb);    bcb.Flags = srb->sc_data_direction == SCSI_DATA_READ ? 1 << 7 : 0;    bcb.Tag = srb->serial_number;    bcb.Lun = srb->cmnd[1] >> 5;    if(umas->flags & UMAS_FL_SCM_MULT_TARG)        bcb.Lun |= srb->target << 4;    bcb.Length = srb->cmd_len;    /* construct the pipe handle */    pipe = usb_sndbulkpipe(umas->pusb_dev, umas->ep_out);    /* copy the command payload */    memset(bcb.CDB, 0, sizeof(bcb.CDB));    memcpy(bcb.CDB, srb->cmnd, bcb.Length);    /* send it to out endpoint */    UMAS_VDEBUG("Bulk command S 0x%x T 0x%x Trg %d LUN %d L %d F %d CL %d/n",                bcb.Signature, bcb.Tag, (bcb.Lun >> 4), (bcb.Lun & 0x0F),                bcb.DataTransferLength, bcb.Flags, bcb.Length);    result = usb_stor_bulk_msg(umas, &bcb, pipe, UMAS_BULK_CB_WRAP_LEN, &partial);    UMAS_VDEBUG("Bulk command transfer result=%d/n", result);    /* if the command was aborted, indicate that */    if(result == USB_ERR_NOENT)        return USB_STOR_TRANSPORT_ABORTED;    /* if we stall, we need to clear it before we go on */    if(result == USB_ERR_PIPE)    {        UMAS_DEBUG("UMAS_BulkTransport - 1 clearing endpoint halt for pipe 0x%x/n", pipe);        clear_halt(umas->pusb_dev, pipe);    }    else if(result)    {        /* unknown error -- we've got a problem */        status = USB_STOR_TRANSPORT_ERROR;        goto bulk_error;    }    /* if the command transferred well, then we go to the data stage */    if(result == 0)    {        /* send/receive data payload, if there is any */        if(bcb.DataTransferLength)        {            us_transfer(srb, umas);            /* if it was aborted, we need to indicate that */            if(srb->result == USB_STOR_TRANSPORT_ABORTED)            {                status = USB_STOR_TRANSPORT_ABORTED;                goto bulk_error;            }        }    }    /*     *  See flow chart on pg 15 of the Bulk Only Transport spec for     *  an explanation of how this code works.     */    /* construct the pipe handle */    pipe = usb_rcvbulkpipe(umas->pusb_dev, umas->ep_in);    /* get CSW for device status */    UMAS_VDEBUG("Attempting to get CSW.../n");    result = usb_stor_bulk_msg(umas, (char *)&bcs, pipe, UMAS_BULK_CS_WRAP_LEN, &partial);    /* if the command was aborted, indicate that */    if(result == USB_ERR_NOENT)    {        status = USB_STOR_TRANSPORT_ABORTED;        goto bulk_error;    }    /* did the attempt to read the CSW fail? */    if(result == USB_ERR_PIPE)    {        UMAS_DEBUG("get CSW failed - clearing endpoint halt for pipe 0x%x/n", pipe);        clear_halt(umas->pusb_dev, pipe);        /* get the status again */        UMAS_DEBUG("Attempting to get CSW (2nd try).../n");        result = usb_stor_bulk_msg(umas, &bcs, pipe, UMAS_BULK_CS_WRAP_LEN, &partial);//.........这里部分代码省略.........
开发者ID:brucetsao,项目名称:Nuvoton,代码行数:101,


示例2: cnxthwusb_probe

static int __devinit cnxthwusb_probe(struct usb_interface *intf,	const struct usb_device_id *id)#endif{    int i;    struct usb_interface *pUsbDataInterface, *pUsbCommInterface;    POS_DEVNODE pDevNode = NULL;    PUSBOSHAL pUsbOsHal = NULL;#if ( LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,0) )    struct usb_device *pUsbDevice = interface_to_usbdev(intf);    __u8 ifnum = intf->altsetting->desc.bInterfaceNumber;#endif#if TARGET_HCF_FAMILY    dbg("%s: pUsbDevice=%p ifnum=%d id=%p bConfigurationValue=%d", __FUNCTION__, pUsbDevice, ifnum, id, pUsbDevice->config[0].CFGDESC(bConfigurationValue));    if (((USB_BYTEORDER16(pUsbDevice->descriptor.idVendor) != USB_AAPL_VENDOR_ID) &&		(USB_BYTEORDER16(pUsbDevice->descriptor.idVendor) != USB_CNXT_VENDOR_ID)) ||	    ((USB_BYTEORDER16(pUsbDevice->descriptor.idProduct) != USB_AAPL_PRODUCT_ID) &&	     (USB_BYTEORDER16(pUsbDevice->descriptor.idProduct) != USB_CNXT_PRODUCT_ID))) {	err("Not the one we are interested about");	goto exit;    }#else    dbg("%s: pUsbDevice=%p ifnum=%d id=%p", __FUNCTION__, pUsbDevice, ifnum, id);#endif    if(pUsbDevice->descriptor.bNumConfigurations != 1) {	err("Wrong number of device configurations (%d)", pUsbDevice->descriptor.bNumConfigurations);	goto exit;    }    if(pUsbDevice->actconfig->CFGDESC(bNumInterfaces) != 2) {	err("Wrong number of device interfaces (%d)", pUsbDevice->actconfig->CFGDESC(bNumInterfaces));	goto exit;    }#if ( LINUX_VERSION_CODE < KERNEL_VERSION(2,6,0) )    pUsbDataInterface = pUsbDevice->actconfig->interface + 0;#else    pUsbDataInterface = pUsbDevice->actconfig->interface[0];#endif    if(pUsbDataInterface->num_altsetting != 1) {	warn("DataInterface has more than one alternate setting (%d)", pUsbDataInterface->num_altsetting);    }    if(pUsbDataInterface->altsetting->CFGDESC(bNumEndpoints) != DATA_PIPE_NUM) {	err("Wrong number of endpoints (%d) for DataInterface", pUsbDataInterface->altsetting->CFGDESC(bNumEndpoints));	goto exit;    }#if ( LINUX_VERSION_CODE < KERNEL_VERSION(2,6,0) )    pUsbCommInterface = pUsbDevice->actconfig->interface + 1;#else    pUsbCommInterface = pUsbDevice->actconfig->interface[1];#endif    if(pUsbCommInterface->num_altsetting != 1) {	warn("CommInterface has more than one alternate setting (%d)", pUsbCommInterface->num_altsetting);    }    if(pUsbCommInterface->altsetting->CFGDESC(bNumEndpoints) != INT_PIPE_NUM) {	err("Wrong number of endpoints (%d) for CommInterface", pUsbCommInterface->altsetting->CFGDESC(bNumEndpoints));	goto exit;    }	if(usb_interface_claimed(pUsbCommInterface)) {		err("CommInterface already claimed");		goto exit;	}    pUsbOsHal = kmalloc(sizeof(USBOSHAL), GFP_KERNEL);    if (!pUsbOsHal) {	err ("Out of memory");	goto exit;    }    memset(pUsbOsHal, 0, sizeof(USBOSHAL));    for(i=0; i < pUsbDataInterface->altsetting->CFGDESC(bNumEndpoints); i++) {#if ( LINUX_VERSION_CODE < KERNEL_VERSION(2,6,0) )	dbg("%s: pUsbDataInterface endpoint=%d len=%d type=0x%02x addr=0x%02x attr=0x%02x maxsize=%d interval=%d",		__FUNCTION__,		i,		pUsbDataInterface->altsetting->endpoint[i].CFGDESC(bLength),		pUsbDataInterface->altsetting->endpoint[i].CFGDESC(bDescriptorType),		pUsbDataInterface->altsetting->endpoint[i].CFGDESC(bEndpointAddress),		pUsbDataInterface->altsetting->endpoint[i].CFGDESC(bmAttributes),		USB_BYTEORDER16(pUsbDataInterface->altsetting->endpoint[i].CFGDESC(wMaxPacketSize))&0x7ff,		pUsbDataInterface->altsetting->endpoint[i].CFGDESC(bInterval)	   );#endif	if (pUsbDataInterface->altsetting->endpoint[i].CFGDESC(bEndpointAddress) == 0x81) {	    pUsbOsHal->DataInPipe = usb_rcvbulkpipe (pUsbDevice, pUsbDataInterface->altsetting->endpoint[i].CFGDESC(bEndpointAddress) & USB_ENDPOINT_NUMBER_MASK);	} else if (pUsbDataInterface->altsetting->endpoint[i].CFGDESC(bEndpointAddress) == 0x01) {	    pUsbOsHal->DataOutPipe = usb_sndbulkpipe (pUsbDevice, pUsbDataInterface->altsetting->endpoint[i].CFGDESC(bEndpointAddress) & USB_ENDPOINT_NUMBER_MASK);	} else if (pUsbDataInterface->altsetting->endpoint[i].CFGDESC(bEndpointAddress) == 0x83) {	    pUsbOsHal->DcpInPipe = usb_rcvbulkpipe (pUsbDevice, pUsbDataInterface->altsetting->endpoint[i].CFGDESC(bEndpointAddress) & USB_ENDPOINT_NUMBER_MASK);#if TARGET_HCF_FAMILY	} else if (pUsbDataInterface->altsetting->endpoint[i].CFGDESC(bEndpointAddress) == 0x03) {	    pUsbOsHal->DownloadPipe = usb_sndbulkpipe (pUsbDevice, pUsbDataInterface->altsetting->endpoint[i].CFGDESC(bEndpointAddress) & USB_ENDPOINT_NUMBER_MASK);	    if((USB_BYTEORDER16(pUsbDataInterface->altsetting->endpoint[i].CFGDESC(wMaxPacketSize))&0x7ff) == 64)		pUsbOsHal->UpdateEEPROM = TRUE;#endif//.........这里部分代码省略.........
开发者ID:jordiclariana,项目名称:hsfmodem,代码行数:101,


示例3: acm_probe

//.........这里部分代码省略.........	acm = kzalloc(sizeof(struct acm), GFP_KERNEL);	if (acm == NULL) {		dev_err(&intf->dev, "out of memory (acm kzalloc)/n");		goto alloc_fail;	}	minor = acm_alloc_minor(acm);	if (minor == ACM_TTY_MINORS) {		dev_err(&intf->dev, "no more free acm devices/n");		kfree(acm);		return -ENODEV;	}	ctrlsize = usb_endpoint_maxp(epctrl);	readsize = usb_endpoint_maxp(epread) *				(quirks == SINGLE_RX_URB ? 1 : 2);	acm->combined_interfaces = combined_interfaces;	acm->writesize = usb_endpoint_maxp(epwrite) * 20;	acm->control = control_interface;	acm->data = data_interface;	acm->minor = minor;	acm->dev = usb_dev;	acm->ctrl_caps = ac_management_function;	if (quirks & NO_CAP_LINE)		acm->ctrl_caps &= ~USB_CDC_CAP_LINE;	acm->ctrlsize = ctrlsize;	acm->readsize = readsize;	acm->rx_buflimit = num_rx_buf;	INIT_WORK(&acm->work, acm_softint);	spin_lock_init(&acm->write_lock);	spin_lock_init(&acm->read_lock);	mutex_init(&acm->mutex);	acm->rx_endpoint = usb_rcvbulkpipe(usb_dev, epread->bEndpointAddress);	acm->is_int_ep = usb_endpoint_xfer_int(epread);	if (acm->is_int_ep)		acm->bInterval = epread->bInterval;	tty_port_init(&acm->port);	acm->port.ops = &acm_port_ops;	init_usb_anchor(&acm->delayed);	buf = usb_alloc_coherent(usb_dev, ctrlsize, GFP_KERNEL, &acm->ctrl_dma);	if (!buf) {		dev_err(&intf->dev, "out of memory (ctrl buffer alloc)/n");		goto alloc_fail2;	}	acm->ctrl_buffer = buf;	if (acm_write_buffers_alloc(acm) < 0) {		dev_err(&intf->dev, "out of memory (write buffer alloc)/n");		goto alloc_fail4;	}	acm->ctrlurb = usb_alloc_urb(0, GFP_KERNEL);	if (!acm->ctrlurb) {		dev_err(&intf->dev, "out of memory (ctrlurb kmalloc)/n");		goto alloc_fail5;	}	for (i = 0; i < num_rx_buf; i++) {		struct acm_rb *rb = &(acm->read_buffers[i]);		struct urb *urb;		rb->base = usb_alloc_coherent(acm->dev, readsize, GFP_KERNEL,								&rb->dma);		if (!rb->base) {			dev_err(&intf->dev, "out of memory "
开发者ID:Emineminero,项目名称:DORIMANX_LG_STOCK_LP_KERNEL,代码行数:67,


示例4: usbnet_probe

//.........这里部分代码省略.........	 * bind() should set rx_urb_size in that case.	 */	dev->hard_mtu = net->mtu + net->hard_header_len;#if 0// dma_supported() is deeply broken on almost all architectures	// possible with some EHCI controllers	if (dma_supported (&udev->dev, DMA_BIT_MASK(64)))		net->features |= NETIF_F_HIGHDMA;#endif	net->netdev_ops = &usbnet_netdev_ops;	net->watchdog_timeo = TX_TIMEOUT_JIFFIES;	net->ethtool_ops = &usbnet_ethtool_ops;	// allow device-specific bind/init procedures	// NOTE net->name still not usable ...	if (info->bind) {		status = info->bind (dev, udev);		if (status < 0)			goto out1;		// heuristic:  "usb%d" for links we know are two-host,		// else "eth%d" when there's reasonable doubt.  userspace		// can rename the link if it knows better.		if ((dev->driver_info->flags & FLAG_ETHER) != 0 &&		    ((dev->driver_info->flags & FLAG_POINTTOPOINT) == 0 ||		     (net->dev_addr [0] & 0x02) == 0))			strcpy (net->name, "eth%d");		/* WLAN devices should always be named "wlan%d" */		if ((dev->driver_info->flags & FLAG_WLAN) != 0)			strcpy(net->name, "wlan%d");		/* WWAN devices should always be named "wwan%d" */		if ((dev->driver_info->flags & FLAG_WWAN) != 0)			strcpy(net->name, "wwan%d");		/* maybe the remote can't receive an Ethernet MTU */		if (net->mtu > (dev->hard_mtu - net->hard_header_len))			net->mtu = dev->hard_mtu - net->hard_header_len;	} else if (!info->in || !info->out)		status = usbnet_get_endpoints (dev, udev);	else {		dev->in = usb_rcvbulkpipe (xdev, info->in);		dev->out = usb_sndbulkpipe (xdev, info->out);		if (!(info->flags & FLAG_NO_SETINT))			status = usb_set_interface (xdev,				interface->desc.bInterfaceNumber,				interface->desc.bAlternateSetting);		else			status = 0;	}	if (status >= 0 && dev->status)		status = init_status (dev, udev);	if (status < 0)		goto out3;	/* urb size is equal to hard_mtu value unless the size was set in bind() */	if (!dev->rx_urb_size) {		dev->custom_rx_urb_size = false;		dev->rx_urb_size = dev->hard_mtu;	} else {		dev->custom_rx_urb_size = true;	}	dev->maxpacket = usb_maxpacket (dev->udev, dev->out, 1);	if ((dev->driver_info->flags & FLAG_WLAN) != 0)		SET_NETDEV_DEVTYPE(net, &wlan_type);	if ((dev->driver_info->flags & FLAG_WWAN) != 0)		SET_NETDEV_DEVTYPE(net, &wwan_type);	status = register_netdev (net);	if (status)		goto out3;	netif_info(dev, probe, dev->net,		   "register '%s' at usb-%s-%s, %s, %pM/n",		   udev->dev.driver->name,		   xdev->bus->bus_name, xdev->devpath,		   dev->driver_info->description,		   net->dev_addr);	// ok, it's ready to go.	usb_set_intfdata (udev, dev);	netif_device_attach (net);	if (dev->driver_info->flags & FLAG_LINK_INTR)		netif_carrier_off(net);	return 0;out3:	if (info->unbind)		info->unbind (dev, udev);out1:	free_netdev(net);out:	usb_put_dev(xdev);	return status;}
开发者ID:ferradinho,项目名称:xoom-ElementalX,代码行数:101,


示例5: usbpn_probe

int usbpn_probe(struct usb_interface *intf, const struct usb_device_id *id){	static const char ifname[] = "usbpn%d";	const struct usb_cdc_union_desc *union_header = NULL;	const struct usb_cdc_header_desc *phonet_header = NULL;	const struct usb_host_interface *data_desc;	struct usb_interface *data_intf;	struct usb_device *usbdev = interface_to_usbdev(intf);	struct net_device *dev;	struct usbpn_dev *pnd;	u8 *data;	int len, err;	data = intf->altsetting->extra;	len = intf->altsetting->extralen;	while (len >= 3) {		u8 dlen = data[0];		if (dlen < 3)			return -EINVAL;		/* bDescriptorType */		if (data[1] == USB_DT_CS_INTERFACE) {			/* bDescriptorSubType */			switch (data[2]) {			case USB_CDC_UNION_TYPE:				if (union_header || dlen < 5)					break;				union_header =					(struct usb_cdc_union_desc *)data;				break;			case 0xAB:				if (phonet_header || dlen < 5)					break;				phonet_header =					(struct usb_cdc_header_desc *)data;				break;			}		}		data += dlen;		len -= dlen;	}	if (!union_header || !phonet_header)		return -EINVAL;	data_intf = usb_ifnum_to_if(usbdev, union_header->bSlaveInterface0);	if (data_intf == NULL)		return -ENODEV;	/* Data interface has one inactive and one active setting */	if (data_intf->num_altsetting != 2)		return -EINVAL;	if (data_intf->altsetting[0].desc.bNumEndpoints == 0	 && data_intf->altsetting[1].desc.bNumEndpoints == 2)		data_desc = data_intf->altsetting + 1;	else	if (data_intf->altsetting[0].desc.bNumEndpoints == 2	 && data_intf->altsetting[1].desc.bNumEndpoints == 0)		data_desc = data_intf->altsetting;	else		return -EINVAL;	dev = alloc_netdev(sizeof(*pnd) + sizeof(pnd->urbs[0]) * rxq_size,				ifname, usbpn_setup);	if (!dev)		return -ENOMEM;	pnd = netdev_priv(dev);	SET_NETDEV_DEV(dev, &intf->dev);	netif_stop_queue(dev);	pnd->dev = dev;	pnd->usb = usb_get_dev(usbdev);	pnd->intf = intf;	pnd->data_intf = data_intf;	spin_lock_init(&pnd->tx_lock);	spin_lock_init(&pnd->rx_lock);	/* Endpoints */	if (usb_pipein(data_desc->endpoint[0].desc.bEndpointAddress)) {		pnd->rx_pipe = usb_rcvbulkpipe(usbdev,			data_desc->endpoint[0].desc.bEndpointAddress);		pnd->tx_pipe = usb_sndbulkpipe(usbdev,			data_desc->endpoint[1].desc.bEndpointAddress);	} else {		pnd->rx_pipe = usb_rcvbulkpipe(usbdev,			data_desc->endpoint[1].desc.bEndpointAddress);		pnd->tx_pipe = usb_sndbulkpipe(usbdev,			data_desc->endpoint[0].desc.bEndpointAddress);	}	pnd->active_setting = data_desc - data_intf->altsetting;	err = usb_driver_claim_interface(&usbpn_driver, data_intf, pnd);	if (err)		goto out;	/* Force inactive mode until the network device is brought UP */	usb_set_interface(usbdev, union_header->bSlaveInterface0,				!pnd->active_setting);	usb_set_intfdata(intf, pnd);	err = register_netdev(dev);//.........这里部分代码省略.........
开发者ID:3null,项目名称:fastsocket,代码行数:101,


示例6: rtl2832u_power_ctrl

static int rtl2832u_power_ctrl(struct dvb_usb_device *d, int onoff){	int ret;	dev_dbg(&d->udev->dev, "%s: onoff=%d/n", __func__, onoff);	if (onoff) {		/* GPIO3=1, GPIO4=0 */		ret = rtl28xx_wr_reg_mask(d, SYS_GPIO_OUT_VAL, 0x08, 0x18);		if (ret)			goto err;		/* suspend? */		ret = rtl28xx_wr_reg_mask(d, SYS_DEMOD_CTL1, 0x00, 0x10);		if (ret)			goto err;		/* enable PLL */		ret = rtl28xx_wr_reg_mask(d, SYS_DEMOD_CTL, 0x80, 0x80);		if (ret)			goto err;		/* disable reset */		ret = rtl28xx_wr_reg_mask(d, SYS_DEMOD_CTL, 0x20, 0x20);		if (ret)			goto err;		mdelay(5);		/* enable ADC */		ret = rtl28xx_wr_reg_mask(d, SYS_DEMOD_CTL, 0x48, 0x48);		if (ret)			goto err;		/* streaming EP: clear stall & reset */		ret = rtl28xx_wr_regs(d, USB_EPA_CTL, "/x00/x00", 2);		if (ret)			goto err;		ret = usb_clear_halt(d->udev, usb_rcvbulkpipe(d->udev, 0x81));		if (ret)			goto err;	} else {		/* GPIO4=1 */		ret = rtl28xx_wr_reg_mask(d, SYS_GPIO_OUT_VAL, 0x10, 0x10);		if (ret)			goto err;		/* disable ADC */		ret = rtl28xx_wr_reg_mask(d, SYS_DEMOD_CTL, 0x00, 0x48);		if (ret)			goto err;		/* disable PLL */		ret = rtl28xx_wr_reg_mask(d, SYS_DEMOD_CTL, 0x00, 0x80);		if (ret)			goto err;		/* streaming EP: set stall & reset */		ret = rtl28xx_wr_regs(d, USB_EPA_CTL, "/x10/x02", 2);		if (ret)			goto err;	}	return ret;err:	dev_dbg(&d->udev->dev, "%s: failed=%d/n", __func__, ret);	return ret;}
开发者ID:royceniu,项目名称:RP2_MPTCP,代码行数:69,


示例7: ems_usb_start

/* * Start interface */static int ems_usb_start(struct ems_usb *dev){	struct net_device *netdev = dev->netdev;	int err, i;	dev->intr_in_buffer[0] = 0;	dev->free_slots = 15; /* initial size */	for (i = 0; i < MAX_RX_URBS; i++) {		struct urb *urb = NULL;		u8 *buf = NULL;		/* create a URB, and a buffer for it */		urb = usb_alloc_urb(0, GFP_KERNEL);		if (!urb) {			netdev_err(netdev, "No memory left for URBs/n");			err = -ENOMEM;			break;		}		buf = usb_alloc_coherent(dev->udev, RX_BUFFER_SIZE, GFP_KERNEL,					 &urb->transfer_dma);		if (!buf) {			netdev_err(netdev, "No memory left for USB buffer/n");			usb_free_urb(urb);			err = -ENOMEM;			break;		}		usb_fill_bulk_urb(urb, dev->udev, usb_rcvbulkpipe(dev->udev, 2),				  buf, RX_BUFFER_SIZE,				  ems_usb_read_bulk_callback, dev);		urb->transfer_flags |= URB_NO_TRANSFER_DMA_MAP;		usb_anchor_urb(urb, &dev->rx_submitted);		err = usb_submit_urb(urb, GFP_KERNEL);		if (err) {			usb_unanchor_urb(urb);			usb_free_coherent(dev->udev, RX_BUFFER_SIZE, buf,					  urb->transfer_dma);			usb_free_urb(urb);			break;		}		/* Drop reference, USB core will take care of freeing it */		usb_free_urb(urb);	}	/* Did we submit any URBs */	if (i == 0) {		netdev_warn(netdev, "couldn't setup read URBs/n");		return err;	}	/* Warn if we've couldn't transmit all the URBs */	if (i < MAX_RX_URBS)		netdev_warn(netdev, "rx performance may be slow/n");	/* Setup and start interrupt URB */	usb_fill_int_urb(dev->intr_urb, dev->udev,			 usb_rcvintpipe(dev->udev, 1),			 dev->intr_in_buffer,			 INTR_IN_BUFFER_SIZE,			 ems_usb_read_interrupt_callback, dev, 1);	err = usb_submit_urb(dev->intr_urb, GFP_KERNEL);	if (err) {		netdev_warn(netdev, "intr URB submit failed: %d/n", err);		return err;	}	/* CPC-USB will transfer received message to host */	err = ems_usb_control_cmd(dev, CONTR_CAN_MESSAGE | CONTR_CONT_ON);	if (err)		goto failed;	/* CPC-USB will transfer CAN state changes to host */	err = ems_usb_control_cmd(dev, CONTR_CAN_STATE | CONTR_CONT_ON);	if (err)		goto failed;	/* CPC-USB will transfer bus errors to host */	err = ems_usb_control_cmd(dev, CONTR_BUS_ERROR | CONTR_CONT_ON);	if (err)		goto failed;	err = ems_usb_write_mode(dev, SJA1000_MOD_NORMAL);	if (err)		goto failed;	dev->can.state = CAN_STATE_ERROR_ACTIVE;	return 0;failed:	netdev_warn(netdev, "couldn't submit control: %d/n", err);//.........这里部分代码省略.........
开发者ID:3null,项目名称:linux,代码行数:101,


示例8: p54u_upload_firmware_3887

static int p54u_upload_firmware_3887(struct ieee80211_hw *dev){	static char start_string[] = "~~~~</r";	struct p54u_priv *priv = dev->priv;	const struct firmware *fw_entry = NULL;	int err, alen;	u8 carry = 0;	u8 *buf, *tmp, *data;	unsigned int left, remains, block_size;	struct x2_header *hdr;	unsigned long timeout;	tmp = buf = kmalloc(P54U_FW_BLOCK, GFP_KERNEL);	if (!buf) {		printk(KERN_ERR "p54usb: cannot allocate firmware upload buffer!/n");		err = -ENOMEM;		goto err_bufalloc;	}	memcpy(buf, start_string, 4);	err = p54u_bulk_msg(priv, P54U_PIPE_DATA, buf, 4);	if (err) {		printk(KERN_ERR "p54usb: reset failed! (%d)/n", err);		goto err_reset;	}	err = request_firmware(&fw_entry, "isl3887usb_bare", &priv->udev->dev);	if (err) {		printk(KERN_ERR "p54usb: cannot find firmware (isl3887usb_bare)!/n");		goto err_req_fw_failed;	}	p54_parse_firmware(dev, fw_entry);	left = block_size = min((size_t)P54U_FW_BLOCK, fw_entry->size);	strcpy(buf, start_string);	left -= strlen(start_string);	tmp += strlen(start_string);	data = fw_entry->data;	remains = fw_entry->size;	hdr = (struct x2_header *)(buf + strlen(start_string));	memcpy(hdr->signature, X2_SIGNATURE, X2_SIGNATURE_SIZE);	hdr->fw_load_addr = cpu_to_le32(ISL38XX_DEV_FIRMWARE_ADDR);	hdr->fw_length = cpu_to_le32(fw_entry->size);	hdr->crc = cpu_to_le32(~crc32_le(~0, (void *)&hdr->fw_load_addr,					 sizeof(u32)*2));	left -= sizeof(*hdr);	tmp += sizeof(*hdr);	while (remains) {		while (left--) {			if (carry) {				*tmp++ = carry;				carry = 0;				remains--;				continue;			}			switch (*data) {			case '~':				*tmp++ = '}';				carry = '^';				break;			case '}':				*tmp++ = '}';				carry = ']';				break;			default:				*tmp++ = *data;				remains--;				break;			}			data++;		}		err = p54u_bulk_msg(priv, P54U_PIPE_DATA, buf, block_size);		if (err) {			printk(KERN_ERR "prism54usb: firmware upload failed!/n");			goto err_upload_failed;		}		tmp = buf;		left = block_size = min((unsigned int)P54U_FW_BLOCK, remains);	}	*((__le32 *)buf) = cpu_to_le32(~crc32_le(~0, fw_entry->data, fw_entry->size));	err = p54u_bulk_msg(priv, P54U_PIPE_DATA, buf, sizeof(u32));	if (err) {		printk(KERN_ERR "prism54usb: firmware upload failed!/n");		goto err_upload_failed;	}	timeout = jiffies + msecs_to_jiffies(1000);	while (!(err = usb_bulk_msg(priv->udev,		usb_rcvbulkpipe(priv->udev, P54U_PIPE_DATA), buf, 128, &alen, 1000))) {		if (alen > 2 && !memcmp(buf, "OK", 2))			break;		if (alen > 5 && !memcmp(buf, "ERROR", 5)) {//.........这里部分代码省略.........
开发者ID:Tigrouzen,项目名称:k1099,代码行数:101,


示例9: p54u_upload_firmware_net2280

//.........这里部分代码省略.........		P54U_WRITE(NET2280_DEV_U32, &devreg->direct_mem_base,			   cpu_to_le32(0xc0000f00));		P54U_WRITE(NET2280_DEV_U32,			   0x0020 | (unsigned long)&devreg->direct_mem_win, 0);		P54U_WRITE(NET2280_DEV_U32,			   0x0020 | (unsigned long)&devreg->direct_mem_win,			   cpu_to_le32(1));		P54U_WRITE(NET2280_DEV_U32,			   0x0024 | (unsigned long)&devreg->direct_mem_win,			   cpu_to_le32(block_len));		P54U_WRITE(NET2280_DEV_U32,			   0x0028 | (unsigned long)&devreg->direct_mem_win,			   cpu_to_le32(offset));		P54U_WRITE(NET2280_DEV_U32, &devreg->dma_addr,			   cpu_to_le32(NET2280_EPA_FIFO_PCI_ADDR));		P54U_WRITE(NET2280_DEV_U32, &devreg->dma_len,			   cpu_to_le32(block_len >> 2));		P54U_WRITE(NET2280_DEV_U32, &devreg->dma_ctrl,			   cpu_to_le32(ISL38XX_DMA_MASTER_CONTROL_TRIGGER));		mdelay(10);		P54U_READ(NET2280_DEV_U32,			  0x002C | (unsigned long)&devreg->direct_mem_win);		if (!(reg & cpu_to_le32(ISL38XX_DMA_STATUS_DONE)) ||		    !(reg & cpu_to_le32(ISL38XX_DMA_STATUS_READY))) {			printk(KERN_ERR "prism54usb: firmware DMA transfer "			       "failed/n");			goto fail;		}		P54U_WRITE(NET2280_BRG_U32, NET2280_EPA_STAT,			   cpu_to_le32(NET2280_FIFO_FLUSH));		remains -= block_len;		data += block_len;		offset += block_len;	}	/* do ramboot */	P54U_READ(NET2280_DEV_U32, &devreg->ctrl_stat);	reg &= cpu_to_le32(~ISL38XX_CTRL_STAT_RESET);	reg &= cpu_to_le32(~ISL38XX_CTRL_STAT_CLKRUN);	reg |= cpu_to_le32(ISL38XX_CTRL_STAT_RAMBOOT);	P54U_WRITE(NET2280_DEV_U32, &devreg->ctrl_stat, reg);	mdelay(20);	reg |= cpu_to_le32(ISL38XX_CTRL_STAT_RESET);	P54U_WRITE(NET2280_DEV_U32, &devreg->ctrl_stat, reg);	reg &= cpu_to_le32(~ISL38XX_CTRL_STAT_RESET);	P54U_WRITE(NET2280_DEV_U32, &devreg->ctrl_stat, reg);	mdelay(100);	P54U_READ(NET2280_DEV_U32, &devreg->int_ident);	P54U_WRITE(NET2280_DEV_U32, &devreg->int_ack, reg);	/* start up the firmware */	P54U_WRITE(NET2280_DEV_U32, &devreg->int_enable,		   cpu_to_le32(ISL38XX_INT_IDENT_INIT));	P54U_WRITE(NET2280_BRG_U32, NET2280_IRQSTAT1,		   cpu_to_le32(NET2280_PCI_INTA_INTERRUPT));	P54U_WRITE(NET2280_BRG_U32, NET2280_USBIRQENB1,		   cpu_to_le32(NET2280_PCI_INTA_INTERRUPT_ENABLE |			       NET2280_USB_INTERRUPT_ENABLE));	P54U_WRITE(NET2280_DEV_U32, &devreg->dev_int,		   cpu_to_le32(ISL38XX_DEV_INT_RESET));	err = usb_interrupt_msg(priv->udev,				usb_rcvbulkpipe(priv->udev, P54U_PIPE_INT),				buf, sizeof(__le32), &alen, 1000);	if (err || alen != sizeof(__le32))		goto fail;	P54U_READ(NET2280_DEV_U32, &devreg->int_ident);	P54U_WRITE(NET2280_DEV_U32, &devreg->int_ack, reg);	if (!(reg & cpu_to_le32(ISL38XX_INT_IDENT_INIT)))		err = -EINVAL;	P54U_WRITE(NET2280_BRG_U32, NET2280_USBIRQENB1, 0);	P54U_WRITE(NET2280_BRG_U32, NET2280_IRQSTAT1,		   cpu_to_le32(NET2280_PCI_INTA_INTERRUPT));#undef P54U_WRITE#undef P54U_READ fail:	release_firmware(fw_entry);	kfree(buf);	return err;}
开发者ID:Tigrouzen,项目名称:k1099,代码行数:101,


示例10: cdc_ncm_bind_common

//.........这里部分代码省略.........			break;		default:			break;		}advance:		/* advance to next descriptor */		temp = buf[0];		buf += temp;		len -= temp;	}	/* some buggy devices have an IAD but no CDC Union */	if (!ctx->union_desc && intf->intf_assoc && intf->intf_assoc->bInterfaceCount == 2) {		ctx->control = intf;		ctx->data = usb_ifnum_to_if(dev->udev, intf->cur_altsetting->desc.bInterfaceNumber + 1);		dev_dbg(&intf->dev, "CDC Union missing - got slave from IAD/n");	}	/* check if we got everything */	if ((ctx->control == NULL) || (ctx->data == NULL) ||	    ((!ctx->mbim_desc) && ((ctx->ether_desc == NULL) || (ctx->control != intf))))		goto error;	/* claim data interface, if different from control */	if (ctx->data != ctx->control) {		temp = usb_driver_claim_interface(driver, ctx->data, dev);		if (temp)			goto error;	}	iface_no = ctx->data->cur_altsetting->desc.bInterfaceNumber;	/* Reset data interface. Some devices will not reset properly	 * unless they are configured first.  Toggle the altsetting to	 * force a reset	 */	usb_set_interface(dev->udev, iface_no, data_altsetting);	temp = usb_set_interface(dev->udev, iface_no, 0);	if (temp)		goto error2;	/* initialize data interface */	if (cdc_ncm_setup(ctx))		goto error2;	/* Some firmwares need a pause here or they will silently fail	 * to set up the interface properly.  This value was decided	 * empirically on a Sierra Wireless MC7455 running 02.08.02.00	 * firmware.	 */	usleep_range(10000, 20000);	/* configure data interface */	temp = usb_set_interface(dev->udev, iface_no, data_altsetting);	if (temp)		goto error2;	cdc_ncm_find_endpoints(ctx, ctx->data);	cdc_ncm_find_endpoints(ctx, ctx->control);	if ((ctx->in_ep == NULL) || (ctx->out_ep == NULL) ||	    (ctx->status_ep == NULL))		goto error2;	dev->net->ethtool_ops = &cdc_ncm_ethtool_ops;	usb_set_intfdata(ctx->data, dev);	usb_set_intfdata(ctx->control, dev);	usb_set_intfdata(ctx->intf, dev);	if (ctx->ether_desc) {		temp = usbnet_get_ethernet_addr(dev, ctx->ether_desc->iMACAddress);		if (temp)			goto error2;		dev_info(&dev->udev->dev, "MAC-Address: %pM/n", dev->net->dev_addr);	}	dev->in = usb_rcvbulkpipe(dev->udev,		ctx->in_ep->desc.bEndpointAddress & USB_ENDPOINT_NUMBER_MASK);	dev->out = usb_sndbulkpipe(dev->udev,		ctx->out_ep->desc.bEndpointAddress & USB_ENDPOINT_NUMBER_MASK);	dev->status = ctx->status_ep;	dev->rx_urb_size = ctx->rx_max;	ctx->tx_speed = ctx->rx_speed = 0;	return 0;error2:	usb_set_intfdata(ctx->control, NULL);	usb_set_intfdata(ctx->data, NULL);	if (ctx->data != ctx->control)		usb_driver_release_interface(driver, ctx->data);error:	cdc_ncm_free((struct cdc_ncm_ctx *)dev->data[0]);	dev->data[0] = 0;	dev_info(&dev->udev->dev, "bind() failure/n");	return -ENODEV;}
开发者ID:AICP,项目名称:kernel_moto_shamu,代码行数:101,


示例11: p54u_read_eeprom

static int p54u_read_eeprom(struct ieee80211_hw *dev){	struct p54u_priv *priv = dev->priv;	void *buf;	struct p54_control_hdr *hdr;	int err, alen;	size_t offset = priv->hw_type ? 0x10 : 0x20;	buf = kmalloc(0x2020, GFP_KERNEL);	if (!buf) {		printk(KERN_ERR "prism54usb: cannot allocate memory for "		       "eeprom readback!/n");		return -ENOMEM;	}	if (priv->hw_type) {		*((u32 *) buf) = priv->common.rx_start;		err = p54u_bulk_msg(priv, P54U_PIPE_DATA, buf, sizeof(u32));		if (err) {			printk(KERN_ERR "prism54usb: addr send failed/n");			goto fail;		}	} else {		struct net2280_reg_write *reg = buf;		reg->port = cpu_to_le16(NET2280_DEV_U32);		reg->addr = cpu_to_le32(P54U_DEV_BASE);		reg->val = cpu_to_le32(ISL38XX_DEV_INT_DATA);		err = p54u_bulk_msg(priv, P54U_PIPE_DEV, buf, sizeof(*reg));		if (err) {			printk(KERN_ERR "prism54usb: dev_int send failed/n");			goto fail;		}	}	hdr = buf + priv->common.tx_hdr_len;	p54_fill_eeprom_readback(hdr);	hdr->req_id = cpu_to_le32(priv->common.rx_start);	if (priv->common.tx_hdr_len) {		struct net2280_tx_hdr *tx_hdr = buf;		tx_hdr->device_addr = hdr->req_id;		tx_hdr->len = cpu_to_le16(EEPROM_READBACK_LEN);	}	/* we can just pretend to send 0x2000 bytes of nothing in the headers */	err = p54u_bulk_msg(priv, P54U_PIPE_DATA, buf,			    EEPROM_READBACK_LEN + priv->common.tx_hdr_len);	if (err) {		printk(KERN_ERR "prism54usb: eeprom req send failed/n");		goto fail;	}	err = usb_bulk_msg(priv->udev,			   usb_rcvbulkpipe(priv->udev, P54U_PIPE_DATA),			   buf, 0x2020, &alen, 1000);	if (!err && alen > offset) {		p54_parse_eeprom(dev, (u8 *)buf + offset, alen - offset);	} else {		printk(KERN_ERR "prism54usb: eeprom read failed!/n");		err = -EINVAL;		goto fail;	} fail:	kfree(buf);	return err;}
开发者ID:Tigrouzen,项目名称:k1099,代码行数:66,


示例12: if_usb_probe

static int __devinit if_usb_probe(struct usb_interface *intf,					const struct usb_device_id *id){	struct usb_host_interface *data_desc;	struct usb_link_device *usb_ld =			(struct usb_link_device *)id->driver_info;	struct link_device *ld = &usb_ld->ld;	struct usb_interface *data_intf;	struct usb_device *usbdev = interface_to_usbdev(intf);	struct device *dev, *ehci_dev, *root_hub;	struct if_usb_devdata *pipe;	struct urb *urb;	int i;	int j;	int dev_id;	int err;	/* To detect usb device order probed */	dev_id = intf->cur_altsetting->desc.bInterfaceNumber;	if (dev_id >= IF_USB_DEVNUM_MAX) {		dev_err(&intf->dev, "Device id %d cannot support/n",								dev_id);		return -EINVAL;	}	if (!usb_ld) {		dev_err(&intf->dev,		"if_usb device doesn't be allocated/n");		err = ENOMEM;		goto out;	}	mif_info("probe dev_id=%d usb_device_id(0x%p), usb_ld (0x%p)/n",				dev_id, id, usb_ld);	usb_ld->usbdev = usbdev;	usb_get_dev(usbdev);	for (i = 0; i < IF_USB_DEVNUM_MAX; i++) {		data_intf = usb_ifnum_to_if(usbdev, i);		/* remap endpoint of RAW to no.1 for LTE modem */		if (i == 0)			pipe = &usb_ld->devdata[1];		else if (i == 1)			pipe = &usb_ld->devdata[0];		else			pipe = &usb_ld->devdata[i];		pipe->disconnected = 0;		pipe->data_intf = data_intf;		data_desc = data_intf->cur_altsetting;		/* Endpoints */		if (usb_pipein(data_desc->endpoint[0].desc.bEndpointAddress)) {			pipe->rx_pipe = usb_rcvbulkpipe(usbdev,				data_desc->endpoint[0].desc.bEndpointAddress);			pipe->tx_pipe = usb_sndbulkpipe(usbdev,				data_desc->endpoint[1].desc.bEndpointAddress);			pipe->rx_buf_size = 1024*4;		} else {			pipe->rx_pipe = usb_rcvbulkpipe(usbdev,				data_desc->endpoint[1].desc.bEndpointAddress);			pipe->tx_pipe = usb_sndbulkpipe(usbdev,				data_desc->endpoint[0].desc.bEndpointAddress);			pipe->rx_buf_size = 1024*4;		}		if (i == 0) {			dev_info(&usbdev->dev, "USB IF USB device found/n");		} else {			err = usb_driver_claim_interface(&if_usb_driver,					data_intf, usb_ld);			if (err < 0) {				mif_err("failed to cliam usb interface/n");				goto out;			}		}		usb_set_intfdata(data_intf, usb_ld);		usb_ld->dev_count++;		pm_suspend_ignore_children(&data_intf->dev, true);		for (j = 0; j < URB_COUNT; j++) {			urb = usb_alloc_urb(0, GFP_KERNEL);			if (!urb) {				mif_err("alloc urb fail/n");				err = -ENOMEM;				goto out2;			}			urb->transfer_flags |= URB_NO_TRANSFER_DMA_MAP;			urb->transfer_buffer = usb_alloc_coherent(usbdev,				pipe->rx_buf_size, GFP_KERNEL,				&urb->transfer_dma);			if (!urb->transfer_buffer) {				mif_err(				"Failed to allocate transfer buffer/n");				usb_free_urb(urb);//.........这里部分代码省略.........
开发者ID:Forest1971,项目名称:legacy_android_kernel_exynos4210,代码行数:101,


示例13: read_rio

static ssize_tread_rio(struct file *file, char __user *buffer, size_t count, loff_t * ppos){	DEFINE_WAIT(wait);	struct rio_usb_data *rio = &rio_instance;	ssize_t read_count;	unsigned int partial;	int this_read;	int result;	int maxretry = 10;	char *ibuf;	int intr;	intr = mutex_lock_interruptible(&(rio->lock));	if (intr)		return -EINTR;	/* Sanity check to make sure rio is connected, powered, etc */        if (rio->present == 0 || rio->rio_dev == NULL) {		mutex_unlock(&(rio->lock));		return -ENODEV;	}	ibuf = rio->ibuf;	read_count = 0;	while (count > 0) {		if (signal_pending(current)) {			mutex_unlock(&(rio->lock));			return read_count ? read_count : -EINTR;		}		if (!rio->rio_dev) {			mutex_unlock(&(rio->lock));			return -ENODEV;		}		this_read = (count >= IBUF_SIZE) ? IBUF_SIZE : count;		result = usb_bulk_msg(rio->rio_dev,				      usb_rcvbulkpipe(rio->rio_dev, 1),				      ibuf, this_read, &partial,				      8000);		dbg("read stats: result:%d this_read:%u partial:%u",		       result, this_read, partial);		if (partial) {			count = this_read = partial;		} else if (result == -ETIMEDOUT || result == 15) {	/* FIXME: 15 ??? */			if (!maxretry--) {				mutex_unlock(&(rio->lock));				err("read_rio: maxretry timeout");				return -ETIME;			}			prepare_to_wait(&rio->wait_q, &wait, TASK_INTERRUPTIBLE);			schedule_timeout(NAK_TIMEOUT);			finish_wait(&rio->wait_q, &wait);			continue;		} else if (result != -EREMOTEIO) {			mutex_unlock(&(rio->lock));			err("Read Whoops - result:%u partial:%u this_read:%u",			     result, partial, this_read);			return -EIO;		} else {			mutex_unlock(&(rio->lock));			return (0);		}		if (this_read) {			if (copy_to_user(buffer, ibuf, this_read)) {				mutex_unlock(&(rio->lock));				return -EFAULT;			}			count -= this_read;			read_count += this_read;			buffer += this_read;		}	}	mutex_unlock(&(rio->lock));	return read_count;}
开发者ID:12rafael,项目名称:jellytimekernel,代码行数:81,


示例14: ir_read_bulk_callback

static void ir_read_bulk_callback (struct urb *urb){    struct usb_serial_port *port = (struct usb_serial_port *)urb->context;    struct usb_serial *serial = get_usb_serial (port, __FUNCTION__);    struct tty_struct *tty;    unsigned char *data = urb->transfer_buffer;    int result;    if (port_paranoia_check (port, __FUNCTION__))        return;    dbg("%s - port %d", __FUNCTION__, port->number);    if (!serial) {        dbg("%s - bad serial pointer, exiting", __FUNCTION__);        return;    }    if (!port->active) {        dbg("%s - port closed.", __FUNCTION__);        return;    }    switch (urb->status) {    case 0: /* Successful */        /*         * The first byte of the packet we get from the device         * contains a busy indicator and baud rate change.         * See section 5.4.1.2 of the USB IrDA spec.         */        if((*data & 0x0f) > 0) ir_baud = *data & 0x0f;        usb_serial_debug_data (            __FILE__,            __FUNCTION__,            urb->actual_length,            data);        /*         * Bypass flip-buffers, and feed the ldisc directly         * due to our potentally large buffer size.  Since we         * used to set low_latency, this is exactly what the         * tty layer did anyway :)         */        tty = port->tty;        tty->ldisc.receive_buf(            tty,            data+1,            NULL,            urb->actual_length-1);    /*     * No break here.     * We want to resubmit the urb so we can read     * again.     */    case -EPROTO: /* taking inspiration from pl2303.c */        /* Continue trying to always read */        usb_fill_bulk_urb (            port->read_urb,            serial->dev,            usb_rcvbulkpipe(serial->dev,                            port->bulk_in_endpointAddress),            port->read_urb->transfer_buffer,            port->read_urb->transfer_buffer_length,            ir_read_bulk_callback,            port);        port->read_urb->transfer_flags = USB_QUEUE_BULK;        result = usb_submit_urb(port->read_urb);        if (result)            err("%s - failed resubmitting read urb, error %d",                __FUNCTION__,                result);        break ;    default:        dbg("%s - nonzero read bulk status received: %d",            __FUNCTION__,            urb->status);        break ;    }    return;}
开发者ID:hugh712,项目名称:Jollen,代码行数:94,


示例15: mdc800_usb_probe

//.........这里部分代码省略.........	{		warn ("only one Mustek MDC800 is supported.");		return -ENODEV;	}	if (dev->descriptor.bNumConfigurations != 1)	{		err ("probe fails -> wrong Number of Configuration");		return -ENODEV;	}	intf_desc = intf->cur_altsetting;	if (			( intf_desc->desc.bInterfaceClass != 0xff )		||	( intf_desc->desc.bInterfaceSubClass != 0 )		|| ( intf_desc->desc.bInterfaceProtocol != 0 )		|| ( intf_desc->desc.bNumEndpoints != 4)	)	{		err ("probe fails -> wrong Interface");		return -ENODEV;	}	/* Check the Endpoints */	for (i=0; i<4; i++)	{		mdc800->endpoint[i]=-1;		for (j=0; j<4; j++)		{			if (mdc800_endpoint_equals (&intf_desc->endpoint [j].desc,&mdc800_ed [i]))			{				mdc800->endpoint[i]=intf_desc->endpoint [j].desc.bEndpointAddress ;				if (i==1)				{					irq_interval=intf_desc->endpoint [j].desc.bInterval;				}				continue;			}		}		if (mdc800->endpoint[i] == -1)		{			err ("probe fails -> Wrong Endpoints.");			return -ENODEV;		}	}	info ("Found Mustek MDC800 on USB.");	down (&mdc800->io_lock);	retval = usb_register_dev(intf, &mdc800_class);	if (retval) {		err ("Not able to get a minor for this device.");		return -ENODEV;	}	mdc800->dev=dev;	mdc800->open=0;	/* Setup URB Structs */	usb_fill_int_urb (		mdc800->irq_urb,		mdc800->dev,		usb_rcvintpipe (mdc800->dev,mdc800->endpoint [1]),		mdc800->irq_urb_buffer,		8,		mdc800_usb_irq,		mdc800,		irq_interval	);	usb_fill_bulk_urb (		mdc800->write_urb,		mdc800->dev,		usb_sndbulkpipe (mdc800->dev, mdc800->endpoint[0]),		mdc800->write_urb_buffer,		8,		mdc800_usb_write_notify,		mdc800	);	usb_fill_bulk_urb (		mdc800->download_urb,		mdc800->dev,		usb_rcvbulkpipe (mdc800->dev, mdc800->endpoint [3]),		mdc800->download_urb_buffer,		64,		mdc800_usb_download_notify,		mdc800	);	mdc800->state=READY;	up (&mdc800->io_lock);		usb_set_intfdata(intf, mdc800);	return 0;}
开发者ID:iPodLinux,项目名称:linux-2.6.7-ipod,代码行数:101,


示例16: rtl2831u_power_ctrl

static int rtl2831u_power_ctrl(struct dvb_usb_device *d, int onoff){	int ret;	u8 gpio, sys0, epa_ctl[2];	dev_dbg(&d->udev->dev, "%s: onoff=%d/n", __func__, onoff);	/* demod adc */	ret = rtl28xx_rd_reg(d, SYS_SYS0, &sys0);	if (ret)		goto err;	/* tuner power, read GPIOs */	ret = rtl28xx_rd_reg(d, SYS_GPIO_OUT_VAL, &gpio);	if (ret)		goto err;	dev_dbg(&d->udev->dev, "%s: RD SYS0=%02x GPIO_OUT_VAL=%02x/n", __func__,			sys0, gpio);	if (onoff) {		gpio |= 0x01; /* GPIO0 = 1 */		gpio &= (~0x10); /* GPIO4 = 0 */		gpio |= 0x04; /* GPIO2 = 1, LED on */		sys0 = sys0 & 0x0f;		sys0 |= 0xe0;		epa_ctl[0] = 0x00; /* clear stall */		epa_ctl[1] = 0x00; /* clear reset */	} else {		gpio &= (~0x01); /* GPIO0 = 0 */		gpio |= 0x10; /* GPIO4 = 1 */		gpio &= (~0x04); /* GPIO2 = 1, LED off */		sys0 = sys0 & (~0xc0);		epa_ctl[0] = 0x10; /* set stall */		epa_ctl[1] = 0x02; /* set reset */	}	dev_dbg(&d->udev->dev, "%s: WR SYS0=%02x GPIO_OUT_VAL=%02x/n", __func__,			sys0, gpio);	/* demod adc */	ret = rtl28xx_wr_reg(d, SYS_SYS0, sys0);	if (ret)		goto err;	/* tuner power, write GPIOs */	ret = rtl28xx_wr_reg(d, SYS_GPIO_OUT_VAL, gpio);	if (ret)		goto err;	/* streaming EP: stall & reset */	ret = rtl28xx_wr_regs(d, USB_EPA_CTL, epa_ctl, 2);	if (ret)		goto err;	if (onoff)		usb_clear_halt(d->udev, usb_rcvbulkpipe(d->udev, 0x81));	return ret;err:	dev_dbg(&d->udev->dev, "%s: failed=%d/n", __func__, ret);	return ret;}
开发者ID:royceniu,项目名称:RP2_MPTCP,代码行数:63,


示例17: init_card

static int init_card(struct snd_usb_caiaqdev *dev){	char *c;	struct usb_device *usb_dev = dev->chip.dev;	struct snd_card *card = dev->chip.card;	int err, len;		if (usb_set_interface(usb_dev, 0, 1) != 0) {		log("can't set alt interface./n");		return -EIO;	}	usb_init_urb(&dev->ep1_in_urb);	usb_init_urb(&dev->midi_out_urb);	usb_fill_bulk_urb(&dev->ep1_in_urb, usb_dev, 			  usb_rcvbulkpipe(usb_dev, 0x1),			  dev->ep1_in_buf, EP1_BUFSIZE, 			  usb_ep1_command_reply_dispatch, dev);	usb_fill_bulk_urb(&dev->midi_out_urb, usb_dev, 			  usb_sndbulkpipe(usb_dev, 0x1),			  dev->midi_out_buf, EP1_BUFSIZE, 			  snd_usb_caiaq_midi_output_done, dev);		init_waitqueue_head(&dev->ep1_wait_queue);	init_waitqueue_head(&dev->prepare_wait_queue);		if (usb_submit_urb(&dev->ep1_in_urb, GFP_KERNEL) != 0)		return -EIO;	err = send_command(dev, EP1_CMD_GET_DEVICE_INFO, NULL, 0);	if (err)		return err;	if (!wait_event_timeout(dev->ep1_wait_queue, dev->spec_received, HZ))		return -ENODEV;	usb_string(usb_dev, usb_dev->descriptor.iManufacturer,		   dev->vendor_name, CAIAQ_USB_STR_LEN);		usb_string(usb_dev, usb_dev->descriptor.iProduct,		   dev->product_name, CAIAQ_USB_STR_LEN);		usb_string(usb_dev, usb_dev->descriptor.iSerialNumber,		   dev->serial, CAIAQ_USB_STR_LEN);	/* terminate serial string at first white space occurence */	c = strchr(dev->serial, ' ');	if (c)		*c = '/0';		strcpy(card->driver, MODNAME);	strcpy(card->shortname, dev->product_name);	len = snprintf(card->longname, sizeof(card->longname),		       "%s %s (serial %s, ",		       dev->vendor_name, dev->product_name, dev->serial);	if (len < sizeof(card->longname) - 2)		len += usb_make_path(usb_dev, card->longname + len,				     sizeof(card->longname) - len);	card->longname[len++] = ')';	card->longname[len] = '/0';	setup_card(dev);	return 0;}
开发者ID:acassis,项目名称:emlinux-ssd1935,代码行数:68,


示例18: ems_usb_read_bulk_callback

/* * callback for bulk IN urb */static void ems_usb_read_bulk_callback(struct urb *urb){	struct ems_usb *dev = urb->context;	struct net_device *netdev;	int retval;	netdev = dev->netdev;	if (!netif_device_present(netdev))		return;	switch (urb->status) {	case 0: /* success */		break;	case -ENOENT:		return;	default:		netdev_info(netdev, "Rx URB aborted (%d)/n", urb->status);		goto resubmit_urb;	}	if (urb->actual_length > CPC_HEADER_SIZE) {		struct ems_cpc_msg *msg;		u8 *ibuf = urb->transfer_buffer;		u8 msg_count, again, start;		msg_count = ibuf[0] & ~0x80;		again = ibuf[0] & 0x80;		start = CPC_HEADER_SIZE;		while (msg_count) {			msg = (struct ems_cpc_msg *)&ibuf[start];			switch (msg->type) {			case CPC_MSG_TYPE_CAN_STATE:				/* Process CAN state changes */				ems_usb_rx_err(dev, msg);				break;			case CPC_MSG_TYPE_CAN_FRAME:			case CPC_MSG_TYPE_EXT_CAN_FRAME:			case CPC_MSG_TYPE_RTR_FRAME:			case CPC_MSG_TYPE_EXT_RTR_FRAME:				ems_usb_rx_can_msg(dev, msg);				break;			case CPC_MSG_TYPE_CAN_FRAME_ERROR:				/* Process errorframe */				ems_usb_rx_err(dev, msg);				break;			case CPC_MSG_TYPE_OVERRUN:				/* Message lost while receiving */				ems_usb_rx_err(dev, msg);				break;			}			start += CPC_MSG_HEADER_LEN + msg->length;			msg_count--;			if (start > urb->transfer_buffer_length) {				netdev_err(netdev, "format error/n");				break;			}		}	}resubmit_urb:	usb_fill_bulk_urb(urb, dev->udev, usb_rcvbulkpipe(dev->udev, 2),			  urb->transfer_buffer, RX_BUFFER_SIZE,			  ems_usb_read_bulk_callback, dev);	retval = usb_submit_urb(urb, GFP_ATOMIC);	if (retval == -ENODEV)		netif_device_detach(netdev);	else if (retval)		netdev_err(netdev,			   "failed resubmitting read bulk urb: %d/n", retval);}
开发者ID:3null,项目名称:linux,代码行数:86,


示例19: hdm_enqueue

/** * hdm_enqueue - receive a buffer to be used for data transfer * @iface: interface to enqueue to * @channel: ID of the channel * @mbo: pointer to the buffer object * * This allocates a new URB and fills it according to the channel * that is being used for transmission of data. Before the URB is * submitted it is stored in the private anchor list. * * Returns 0 on success. On any error the URB is freed and a error code * is returned. * * Context: Could in _some_ cases be interrupt! */static int hdm_enqueue(struct most_interface *iface, int channel,		       struct mbo *mbo){	struct most_dev *mdev;	struct most_channel_config *conf;	struct device *dev;	int retval = 0;	struct urb *urb;	unsigned long length;	void *virt_address;	if (unlikely(!iface || !mbo))		return -EIO;	if (unlikely(iface->num_channels <= channel || channel < 0))		return -ECHRNG;	mdev = to_mdev(iface);	conf = &mdev->conf[channel];	dev = &mdev->usb_device->dev;	if (!mdev->usb_device)		return -ENODEV;	urb = usb_alloc_urb(NO_ISOCHRONOUS_URB, GFP_ATOMIC);	if (!urb)		return -ENOMEM;	if ((conf->direction & MOST_CH_TX) && mdev->padding_active[channel] &&	    hdm_add_padding(mdev, channel, mbo)) {		retval = -EIO;		goto _error;	}	urb->transfer_dma = mbo->bus_address;	virt_address = mbo->virt_address;	length = mbo->buffer_length;	if (conf->direction & MOST_CH_TX) {		usb_fill_bulk_urb(urb, mdev->usb_device,				  usb_sndbulkpipe(mdev->usb_device,						  mdev->ep_address[channel]),				  virt_address,				  length,				  hdm_write_completion,				  mbo);		if (conf->data_type != MOST_CH_ISOC)			urb->transfer_flags |= URB_ZERO_PACKET;	} else {		usb_fill_bulk_urb(urb, mdev->usb_device,				  usb_rcvbulkpipe(mdev->usb_device,						  mdev->ep_address[channel]),				  virt_address,				  length + conf->extra_len,				  hdm_read_completion,				  mbo);	}	urb->transfer_flags |= URB_NO_TRANSFER_DMA_MAP;	usb_anchor_urb(urb, &mdev->busy_urbs[channel]);	retval = usb_submit_urb(urb, GFP_KERNEL);	if (retval) {		dev_err(dev, "URB submit failed with error %d./n", retval);		goto _error_1;	}	return 0;_error_1:	usb_unanchor_urb(urb);_error:	usb_free_urb(urb);	return retval;}
开发者ID:acton393,项目名称:linux,代码行数:88,


示例20: GobiNetDriverBind

/*===========================================================================METHOD:   GobiNetDriverBind (Public Method)DESCRIPTION:   Setup in and out pipesPARAMETERS   pDev           [ I ] - Pointer to usbnet device   pIntf          [ I ] - Pointer to interfaceRETURN VALUE:   int - 0 for success         Negative errno for error===========================================================================*/static int GobiNetDriverBind(    struct usbnet *         pDev,    struct usb_interface *  pIntf ){   int numEndpoints;   int endpointIndex;   struct usb_host_endpoint * pEndpoint = NULL;   struct usb_host_endpoint * pIn = NULL;   struct usb_host_endpoint * pOut = NULL;      // Verify one altsetting   if (pIntf->num_altsetting != 1)   {      DBG( "invalid num_altsetting %u/n", pIntf->num_altsetting );      return -ENODEV;   }   // Verify correct interface (0 or 5)   //if ( (pIntf->cur_altsetting->desc.bInterfaceNumber != 0)   //&&   (pIntf->cur_altsetting->desc.bInterfaceNumber != 5) )   if( !( (1 << pIntf->cur_altsetting->desc.bInterfaceNumber) & (int)pDev->driver_info->data ) )   {      DBG( "invalid interface %d/n",            pIntf->cur_altsetting->desc.bInterfaceNumber );      return -ENODEV;   }      // Collect In and Out endpoints   numEndpoints = pIntf->cur_altsetting->desc.bNumEndpoints;   for (endpointIndex = 0; endpointIndex < numEndpoints; endpointIndex++)   {      pEndpoint = pIntf->cur_altsetting->endpoint + endpointIndex;      if (pEndpoint == NULL)      {         DBG( "invalid endpoint %u/n", endpointIndex );         return -ENODEV;      }            if (usb_endpoint_dir_in( &pEndpoint->desc ) == true      &&  usb_endpoint_xfer_int( &pEndpoint->desc ) == false)      {         pIn = pEndpoint;      }      else if (usb_endpoint_dir_out( &pEndpoint->desc ) == true)      {         pOut = pEndpoint;      }   }      if (pIn == NULL || pOut == NULL)   {      DBG( "invalid endpoints/n" );      return -ENODEV;   }   if (usb_set_interface( pDev->udev,                           pIntf->cur_altsetting->desc.bInterfaceNumber,                          0 ) != 0)   {      DBG( "unable to set interface/n" );      return -ENODEV;   }   pDev->in = usb_rcvbulkpipe( pDev->udev,                   pIn->desc.bEndpointAddress & USB_ENDPOINT_NUMBER_MASK );   pDev->out = usb_sndbulkpipe( pDev->udev,                   pOut->desc.bEndpointAddress & USB_ENDPOINT_NUMBER_MASK );                      DBG( "in %x, out %x/n",         pIn->desc.bEndpointAddress,         pOut->desc.bEndpointAddress );   // In later versions of the kernel, usbnet helps with this#if (LINUX_VERSION_CODE <= KERNEL_VERSION( 2,6,23 ))   pIntf->dev.platform_data = (void *)pDev;#endif   return 0;}
开发者ID:tcdog001,项目名称:apv5sdk-v15,代码行数:94,


示例21: brcmf_usb_probe

static intbrcmf_usb_probe(struct usb_interface *intf, const struct usb_device_id *id){	struct usb_device *usb = interface_to_usbdev(intf);	struct brcmf_usbdev_info *devinfo;	struct usb_interface_descriptor	*desc;	struct usb_endpoint_descriptor *endpoint;	int ret = 0;	u32 num_of_eps;	u8 endpoint_num, ep;	brcmf_dbg(USB, "Enter 0x%04x:0x%04x/n", id->idVendor, id->idProduct);	devinfo = kzalloc(sizeof(*devinfo), GFP_ATOMIC);	if (devinfo == NULL)		return -ENOMEM;	devinfo->usbdev = usb;	devinfo->dev = &usb->dev;	/* Take an init lock, to protect for disconnect while still loading.	 * Necessary because of the asynchronous firmware load construction	 */	mutex_init(&devinfo->dev_init_lock);	mutex_lock(&devinfo->dev_init_lock);	usb_set_intfdata(intf, devinfo);	/* Check that the device supports only one configuration */	if (usb->descriptor.bNumConfigurations != 1) {		brcmf_err("Number of configurations: %d not supported/n",			  usb->descriptor.bNumConfigurations);		ret = -ENODEV;		goto fail;	}	if ((usb->descriptor.bDeviceClass != USB_CLASS_VENDOR_SPEC) &&	    (usb->descriptor.bDeviceClass != USB_CLASS_MISC) &&	    (usb->descriptor.bDeviceClass != USB_CLASS_WIRELESS_CONTROLLER)) {		brcmf_err("Device class: 0x%x not supported/n",			  usb->descriptor.bDeviceClass);		ret = -ENODEV;		goto fail;	}	desc = &intf->altsetting[0].desc;	if ((desc->bInterfaceClass != USB_CLASS_VENDOR_SPEC) ||	    (desc->bInterfaceSubClass != 2) ||	    (desc->bInterfaceProtocol != 0xff)) {		brcmf_err("non WLAN interface %d: 0x%x:0x%x:0x%x/n",			  desc->bInterfaceNumber, desc->bInterfaceClass,			  desc->bInterfaceSubClass, desc->bInterfaceProtocol);		ret = -ENODEV;		goto fail;	}	num_of_eps = desc->bNumEndpoints;	for (ep = 0; ep < num_of_eps; ep++) {		endpoint = &intf->altsetting[0].endpoint[ep].desc;		endpoint_num = usb_endpoint_num(endpoint);		if (!usb_endpoint_xfer_bulk(endpoint))			continue;		if (usb_endpoint_dir_in(endpoint)) {			if (!devinfo->rx_pipe)				devinfo->rx_pipe =					usb_rcvbulkpipe(usb, endpoint_num);		} else {			if (!devinfo->tx_pipe)				devinfo->tx_pipe =					usb_sndbulkpipe(usb, endpoint_num);		}	}	if (devinfo->rx_pipe == 0) {		brcmf_err("No RX (in) Bulk EP found/n");		ret = -ENODEV;		goto fail;	}	if (devinfo->tx_pipe == 0) {		brcmf_err("No TX (out) Bulk EP found/n");		ret = -ENODEV;		goto fail;	}	devinfo->ifnum = desc->bInterfaceNumber;	if (usb->speed == USB_SPEED_SUPER)		brcmf_dbg(USB, "Broadcom super speed USB WLAN interface detected/n");	else if (usb->speed == USB_SPEED_HIGH)		brcmf_dbg(USB, "Broadcom high speed USB WLAN interface detected/n");	else		brcmf_dbg(USB, "Broadcom full speed USB WLAN interface detected/n");	ret = brcmf_usb_probe_cb(devinfo);	if (ret)		goto fail;	/* Success */	return 0;fail:	mutex_unlock(&devinfo->dev_init_lock);//.........这里部分代码省略.........
开发者ID:PimsJay01,项目名称:myscripts,代码行数:101,


示例22: usbnet_get_endpoints

/* handles CDC Ethernet and many other network "bulk data" interfaces */int usbnet_get_endpoints(struct usbnet *dev, struct usb_interface *intf){	int				tmp;	struct usb_host_interface	*alt = NULL;	struct usb_host_endpoint	*in = NULL, *out = NULL;	struct usb_host_endpoint	*status = NULL;	for (tmp = 0; tmp < intf->num_altsetting; tmp++) {		unsigned	ep;		in = out = status = NULL;		alt = intf->altsetting + tmp;		/* take the first altsetting with in-bulk + out-bulk;		 * remember any status endpoint, just in case;		 * ignore other endpoints and altsetttings.		 */		for (ep = 0; ep < alt->desc.bNumEndpoints; ep++) {			struct usb_host_endpoint	*e;			int				intr = 0;			e = alt->endpoint + ep;			switch (e->desc.bmAttributes) {			case USB_ENDPOINT_XFER_INT:				if (!usb_endpoint_dir_in(&e->desc))					continue;				intr = 1;				/* FALLTHROUGH */			case USB_ENDPOINT_XFER_BULK:				break;			default:				continue;			}			if (usb_endpoint_dir_in(&e->desc)) {				if (!intr && !in)					in = e;				else if (intr && !status)					status = e;			} else {				if (!out)					out = e;			}		}		if (in && out)			break;	}	if (!alt || !in || !out)		return -EINVAL;	if (alt->desc.bAlternateSetting != 0 ||	    !(dev->driver_info->flags & FLAG_NO_SETINT)) {		tmp = usb_set_interface (dev->udev, alt->desc.bInterfaceNumber,				alt->desc.bAlternateSetting);		if (tmp < 0)			return tmp;	}	dev->in = usb_rcvbulkpipe (dev->udev,			in->desc.bEndpointAddress & USB_ENDPOINT_NUMBER_MASK);	dev->out = usb_sndbulkpipe (dev->udev,			out->desc.bEndpointAddress & USB_ENDPOINT_NUMBER_MASK);	dev->status = status;	return 0;}
开发者ID:ferradinho,项目名称:xoom-ElementalX,代码行数:65,


示例23: acm_probe

//.........这里部分代码省略.........	}	dbg("interfaces are valid");	for (minor = 0; minor < ACM_TTY_MINORS && acm_table[minor]; minor++);	if (minor == ACM_TTY_MINORS) {		err("no more free acm devices");		return -ENODEV;	}	if (!(acm = kzalloc(sizeof(struct acm), GFP_KERNEL))) {		dev_dbg(&intf->dev, "out of memory (acm kzalloc)/n");		goto alloc_fail;	}	ctrlsize = le16_to_cpu(epctrl->wMaxPacketSize);	readsize = le16_to_cpu(epread->wMaxPacketSize)* ( quirks == SINGLE_RX_URB ? 1 : 2);	acm->writesize = le16_to_cpu(epwrite->wMaxPacketSize);	acm->control = control_interface;	acm->data = data_interface;	acm->minor = minor;	acm->dev = usb_dev;	acm->ctrl_caps = ac_management_function;	acm->ctrlsize = ctrlsize;	acm->readsize = readsize;	acm->rx_buflimit = num_rx_buf;	acm->urb_task.func = acm_rx_tasklet;	acm->urb_task.data = (unsigned long) acm;	INIT_WORK(&acm->work, acm_softint);	spin_lock_init(&acm->throttle_lock);	spin_lock_init(&acm->write_lock);	spin_lock_init(&acm->read_lock);	mutex_init(&acm->mutex);	acm->write_ready = 1;	acm->rx_endpoint = usb_rcvbulkpipe(usb_dev, epread->bEndpointAddress);	buf = usb_buffer_alloc(usb_dev, ctrlsize, GFP_KERNEL, &acm->ctrl_dma);	if (!buf) {		dev_dbg(&intf->dev, "out of memory (ctrl buffer alloc)/n");		goto alloc_fail2;	}	acm->ctrl_buffer = buf;	if (acm_write_buffers_alloc(acm) < 0) {		dev_dbg(&intf->dev, "out of memory (write buffer alloc)/n");		goto alloc_fail4;	}	acm->ctrlurb = usb_alloc_urb(0, GFP_KERNEL);	if (!acm->ctrlurb) {		dev_dbg(&intf->dev, "out of memory (ctrlurb kmalloc)/n");		goto alloc_fail5;	}	for (i = 0; i < num_rx_buf; i++) {		struct acm_ru *rcv = &(acm->ru[i]);		if (!(rcv->urb = usb_alloc_urb(0, GFP_KERNEL))) {			dev_dbg(&intf->dev, "out of memory (read urbs usb_alloc_urb)/n");			goto alloc_fail7;		}		rcv->urb->transfer_flags |= URB_NO_TRANSFER_DMA_MAP;		rcv->instance = acm;	}	for (i = 0; i < num_rx_buf; i++) {		struct acm_rb *buf = &(acm->rb[i]);
开发者ID:Tigrouzen,项目名称:k1099,代码行数:66,


示例24: cx231xx_init_vbi_isoc

/* * Allocate URBs and start IRQ */int cx231xx_init_vbi_isoc(struct cx231xx *dev, int max_packets,			  int num_bufs, int max_pkt_size,			  int (*isoc_copy) (struct cx231xx *dev,					    struct urb *urb)){	struct cx231xx_dmaqueue *dma_q = &dev->vbi_mode.vidq;	int i;	int sb_size, pipe;	struct urb *urb;	int rc;	cx231xx_info(DRIVER_NAME "cx231xx: called cx231xx_prepare_isoc/n");	/* De-allocates all pending stuff */	cx231xx_uninit_vbi_isoc(dev);	/* clear if any halt */	usb_clear_halt(dev->udev,		       usb_rcvbulkpipe(dev->udev,				       dev->vbi_mode.end_point_addr));	dev->vbi_mode.isoc_ctl.isoc_copy = isoc_copy;	dev->vbi_mode.isoc_ctl.num_bufs = num_bufs;	dma_q->pos = 0;	dma_q->is_partial_line = 0;	dma_q->last_sav = 0;	dma_q->current_field = -1;	dma_q->bytes_left_in_line = dev->width << 1;	dma_q->lines_per_field = ((dev->norm & V4L2_STD_625_50) ?				  PAL_VBI_LINES : NTSC_VBI_LINES);	dma_q->lines_completed = 0;	for (i = 0; i < 8; i++)		dma_q->partial_buf[i] = 0;	dev->vbi_mode.isoc_ctl.urb = kzalloc(sizeof(void *) * num_bufs,					     GFP_KERNEL);	if (!dev->vbi_mode.isoc_ctl.urb) {		cx231xx_errdev("cannot alloc memory for usb buffers/n");		return -ENOMEM;	}	dev->vbi_mode.isoc_ctl.transfer_buffer =	    kzalloc(sizeof(void *) * num_bufs, GFP_KERNEL);	if (!dev->vbi_mode.isoc_ctl.transfer_buffer) {		cx231xx_errdev("cannot allocate memory for usbtransfer/n");		kfree(dev->vbi_mode.isoc_ctl.urb);		return -ENOMEM;	}	dev->vbi_mode.isoc_ctl.max_pkt_size = max_pkt_size;	dev->vbi_mode.isoc_ctl.buf = NULL;	sb_size = max_packets * dev->vbi_mode.isoc_ctl.max_pkt_size;	/* allocate urbs and transfer buffers */	for (i = 0; i < dev->vbi_mode.isoc_ctl.num_bufs; i++) {		urb = usb_alloc_urb(0, GFP_KERNEL);		if (!urb) {			cx231xx_err(DRIVER_NAME				    ": cannot alloc isoc_ctl.urb %i/n", i);			cx231xx_uninit_vbi_isoc(dev);			return -ENOMEM;		}		dev->vbi_mode.isoc_ctl.urb[i] = urb;		urb->transfer_flags = 0;		dev->vbi_mode.isoc_ctl.transfer_buffer[i] =		    kzalloc(sb_size, GFP_KERNEL);		if (!dev->vbi_mode.isoc_ctl.transfer_buffer[i]) {			cx231xx_err(DRIVER_NAME				    ": unable to allocate %i bytes for transfer"				    " buffer %i%s/n", sb_size, i,				    in_interrupt() ? " while in int" : "");			cx231xx_uninit_vbi_isoc(dev);			return -ENOMEM;		}		pipe = usb_rcvbulkpipe(dev->udev, dev->vbi_mode.end_point_addr);		usb_fill_bulk_urb(urb, dev->udev, pipe,				  dev->vbi_mode.isoc_ctl.transfer_buffer[i],				  sb_size, cx231xx_irq_vbi_callback, dma_q);	}	init_waitqueue_head(&dma_q->wq);	/* submit urbs and enables IRQ */	for (i = 0; i < dev->vbi_mode.isoc_ctl.num_bufs; i++) {		rc = usb_submit_urb(dev->vbi_mode.isoc_ctl.urb[i], GFP_ATOMIC);		if (rc) {			cx231xx_err(DRIVER_NAME				    ": submit of urb %i failed (error=%i)/n", i,				    rc);			cx231xx_uninit_vbi_isoc(dev);			return rc;		}	}//.........这里部分代码省略.........
开发者ID:12rafael,项目名称:jellytimekernel,代码行数:101,


示例25: ipaq_open

//.........这里部分代码省略.........	priv->free_len = 0;	INIT_LIST_HEAD(&priv->queue);	INIT_LIST_HEAD(&priv->freelist);	for (i = 0; i < URBDATA_QUEUE_MAX / PACKET_SIZE; i++) {		pkt = kmalloc(sizeof(struct ipaq_packet), GFP_KERNEL);		if (pkt == NULL) {			goto enomem;		}		pkt->data = kmalloc(PACKET_SIZE, GFP_KERNEL);		if (pkt->data == NULL) {			kfree(pkt);			goto enomem;		}		pkt->len = 0;		pkt->written = 0;		INIT_LIST_HEAD(&pkt->list);		list_add(&pkt->list, &priv->freelist);		priv->free_len += PACKET_SIZE;	}	/*	 * Force low latency on. This will immediately push data to the line	 * discipline instead of queueing.	 */	port->tty->low_latency = 1;	port->tty->raw = 1;	port->tty->real_raw = 1;	/*	 * Lose the small buffers usbserial provides. Make larger ones.	 */	kfree(port->bulk_in_buffer);	kfree(port->bulk_out_buffer);	port->bulk_in_buffer = kmalloc(URBDATA_SIZE, GFP_KERNEL);	if (port->bulk_in_buffer == NULL) {		port->bulk_out_buffer = NULL; /* prevent double free */		goto enomem;	}	port->bulk_out_buffer = kmalloc(URBDATA_SIZE, GFP_KERNEL);	if (port->bulk_out_buffer == NULL) {		kfree(port->bulk_in_buffer);		port->bulk_in_buffer = NULL;		goto enomem;	}	port->read_urb->transfer_buffer = port->bulk_in_buffer;	port->write_urb->transfer_buffer = port->bulk_out_buffer;	port->read_urb->transfer_buffer_length = URBDATA_SIZE;	port->bulk_out_size = port->write_urb->transfer_buffer_length = URBDATA_SIZE;		msleep(1000*initial_wait);	/*	 * Send out control message observed in win98 sniffs. Not sure what	 * it does, but from empirical observations, it seems that the device	 * will start the chat sequence once one of these messages gets	 * through. Since this has a reasonably high failure rate, we retry	 * several times.	 */	while (retries--) {		result = usb_control_msg(serial->dev,				usb_sndctrlpipe(serial->dev, 0), 0x22, 0x21,				0x1, 0, NULL, 0, 100);		if (!result)			break;		msleep(1000);	}	if (!retries && result) {		err("%s - failed doing control urb, error %d", __func__,		    result);		goto error;	}	/* Start reading from the device */	usb_fill_bulk_urb(port->read_urb, serial->dev,		      usb_rcvbulkpipe(serial->dev, port->bulk_in_endpointAddress),		      port->read_urb->transfer_buffer, port->read_urb->transfer_buffer_length,		      ipaq_read_bulk_callback, port);	result = usb_submit_urb(port->read_urb, GFP_KERNEL);	if (result) {		err("%s - failed submitting read urb, error %d", __func__, result);		goto error;	}	return 0;enomem:	result = -ENOMEM;	err("%s - Out of memory", __func__);error:	ipaq_destroy_lists(port);	kfree(priv);	return result;}
开发者ID:asmblur,项目名称:SynCE,代码行数:101,


示例26: ir_startup

//.........这里部分代码省略.........    ++port->open_count;    MOD_INC_USE_COUNT;    if (!port->active) {        port->active = 1;        if (buffer_size) {            /* override the default buffer sizes */            buffer = kmalloc (buffer_size, GFP_KERNEL);            if (!buffer) {                err ("%s - out of memory.", __FUNCTION__);                return -ENOMEM;            }            kfree (port->read_urb->transfer_buffer);            port->read_urb->transfer_buffer = buffer;            port->read_urb->transfer_buffer_length = buffer_size;            buffer = kmalloc (buffer_size, GFP_KERNEL);            if (!buffer) {                err ("%s - out of memory.", __FUNCTION__);                return -ENOMEM;            }            kfree (port->write_urb->transfer_buffer);            port->write_urb->transfer_buffer = buffer;            port->write_urb->transfer_buffer_length = buffer_size;            port->bulk_out_size = buffer_size;        }        /* Start reading from the device */        usb_fill_bulk_urb (            port->read_urb,            serial->dev,            usb_rcvbulkpipe(serial->dev, port->bulk_in_endpointAddress),            port->read_urb->transfer_buffer,            port->read_urb->transfer_buffer_length,            ir_read_bulk_callback,            port);        port->read_urb->transfer_flags = USB_QUEUE_BULK;        result = usb_submit_urb(port->read_urb);        if (result)            err("%s - failed submitting read urb, error %d", __FUNCTION__, result);    }    up (&port->sem);    return result;}static void ir_close (struct usb_serial_port *port, struct file * filp){    struct usb_serial *serial;    if (port_paranoia_check (port, __FUNCTION__))        return;    dbg("%s - port %d", __FUNCTION__, port->number);    serial = get_usb_serial (port, __FUNCTION__);    if (!serial)        return;    down (&port->sem);    --port->open_count;
开发者ID:hugh712,项目名称:Jollen,代码行数:66,


示例27: 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:artm1248,项目名称:linux,代码行数:69,


示例28: sddr55_raw_bulk

static int sddr55_raw_bulk(struct us_data *us, 		int direction,		unsigned char *data,		unsigned int len) {	int result;	int act_len;	int pipe;	if (direction == SCSI_DATA_READ)		pipe = usb_rcvbulkpipe(us->pusb_dev, us->ep_in);	else		pipe = usb_sndbulkpipe(us->pusb_dev, us->ep_out);	result = usb_stor_bulk_msg(us, data, pipe, len, &act_len);	/* if we stall, we need to clear it before we go on */	if (result == -EPIPE) {		US_DEBUGP("EPIPE: clearing endpoint halt for"			" pipe 0x%x, stalled at %d bytes/n",			pipe, act_len);		usb_clear_halt(us->pusb_dev, pipe);	}	if (result) {		/* NAK - that means we've retried a few times already */		if (result == -ETIMEDOUT) {			US_DEBUGP("usbat_raw_bulk():"				" device NAKed/n");			return US_BULK_TRANSFER_FAILED;		}		/* -ENOENT -- we canceled this transfer */		if (result == -ENOENT) {			US_DEBUGP("usbat_raw_bulk():"				" transfer aborted/n");			return US_BULK_TRANSFER_ABORTED;		}		if (result == -EPIPE) {			US_DEBUGP("usbat_raw_bulk():"				" output pipe stalled/n");			return US_BULK_TRANSFER_FAILED;		}		/* the catch-all case */		US_DEBUGP("us_transfer_partial(): unknown error/n");		return US_BULK_TRANSFER_FAILED;	}	if (act_len != len) {		US_DEBUGP("Warning: Transferred only %d bytes/n",			act_len);		return US_BULK_TRANSFER_SHORT;	}	US_DEBUGP("Transferred %d of %d bytes/n", act_len, len);	return US_BULK_TRANSFER_GOOD;}
开发者ID:muromec,项目名称:linux-ezxdev,代码行数:62,



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


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