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

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

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

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

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

示例1: csvt_ctrl_attach

static int csvt_ctrl_attach(struct usb_serial *serial){	struct csvt_ctrl_dev	*dev;	dev = kzalloc(sizeof(*dev), GFP_KERNEL);	if (!dev)		return -ENOMEM;	mutex_init(&dev->dev_lock);	usb_set_serial_port_data(serial->port[0], dev);	return 0;}
开发者ID:AD5GB,项目名称:kernel_n5_3.10-experimental,代码行数:13,


示例2: ark3116_release

static void ark3116_release(struct usb_serial *serial){	struct usb_serial_port *port = serial->port[0];	struct ark3116_private *priv = usb_get_serial_port_data(port);	/* device is closed, so URBs and DMA should be down */	usb_set_serial_port_data(port, NULL);	mutex_destroy(&priv->hw_lock);	kfree(priv);}
开发者ID:sombree,项目名称:Hulk-Kernel-V2,代码行数:13,


示例3: f81232_startup

static int f81232_startup(struct usb_serial *serial){	struct f81232_private *priv;	int i;	for (i = 0; i < serial->num_ports; ++i) {		priv = kzalloc(sizeof(struct f81232_private), GFP_KERNEL);		if (!priv)			goto cleanup;		spin_lock_init(&priv->lock);		init_waitqueue_head(&priv->delta_msr_wait);		usb_set_serial_port_data(serial->port[i], priv);	}	return 0;cleanup:	for (--i; i >= 0; --i) {		priv = usb_get_serial_port_data(serial->port[i]);		kfree(priv);		usb_set_serial_port_data(serial->port[i], NULL);	}	return -ENOMEM;}
开发者ID:sombree,项目名称:Hulk-Kernel-V2,代码行数:23,


示例4: omninet_attach

static int omninet_attach(struct usb_serial *serial){	struct omninet_data *od;	struct usb_serial_port *port = serial->port[0];	od = kmalloc(sizeof(struct omninet_data), GFP_KERNEL);	if (!od) {		dev_err(&port->dev, "%s- kmalloc(%Zd) failed./n",			__func__, sizeof(struct omninet_data));		return -ENOMEM;	}	usb_set_serial_port_data(port, od);	return 0;}
开发者ID:openube,项目名称:android_kernel_sony_c2305,代码行数:14,


示例5: ssu100_port_probe

static int ssu100_port_probe(struct usb_serial_port *port){	struct ssu100_port_private *priv;	priv = kzalloc(sizeof(*priv), GFP_KERNEL);	if (!priv)		return -ENOMEM;	spin_lock_init(&priv->status_lock);	usb_set_serial_port_data(port, priv);	return 0;}
开发者ID:CoerWatt,项目名称:linux,代码行数:14,


示例6: metrousb_port_probe

static int metrousb_port_probe(struct usb_serial_port *port){	struct metrousb_private *metro_priv;	metro_priv = kzalloc(sizeof(*metro_priv), GFP_KERNEL);	if (!metro_priv)		return -ENOMEM;	spin_lock_init(&metro_priv->lock);	usb_set_serial_port_data(port, metro_priv);	return 0;}
开发者ID:oscardagrach,项目名称:linux,代码行数:14,


示例7: spcp8x5_shutdown

/* call when the device plug out. free all the memory alloced by probe */static void spcp8x5_shutdown(struct usb_serial *serial){	int i;	struct spcp8x5_private *priv;	for (i = 0; i < serial->num_ports; i++) {		priv = usb_get_serial_port_data(serial->port[i]);		if (priv) {			free_ringbuf(priv->buf);			kfree(priv);			usb_set_serial_port_data(serial->port[i] , NULL);		}	}}
开发者ID:maraz,项目名称:linux-2.6,代码行数:15,


示例8: f81232_port_probe

static int f81232_port_probe(struct usb_serial_port *port){	struct f81232_private *priv;	priv = kzalloc(sizeof(*priv), GFP_KERNEL);	if (!priv)		return -ENOMEM;	spin_lock_init(&priv->lock);	init_waitqueue_head(&priv->delta_msr_wait);	usb_set_serial_port_data(port, priv);	return 0;}
开发者ID:dgarnier,项目名称:linux,代码行数:15,


示例9: mxu1_port_probe

static int mxu1_port_probe(struct usb_serial_port *port){	struct mxu1_port *mxport;	struct mxu1_device *mxdev;	struct urb *urb;	mxport = kzalloc(sizeof(struct mxu1_port), GFP_KERNEL);	if (!mxport)		return -ENOMEM;	spin_lock_init(&mxport->mxp_lock);	mutex_init(&mxport->mxp_mutex);	mxport->mxp_port = port;	mxdev = usb_get_serial_data(port->serial);	urb = port->interrupt_in_urb;	if (!urb) {		dev_err(&port->dev, "%s - no interrupt urb/n", __func__);		return -EINVAL;	}	switch (mxdev->mxd_model) {	case MXU1_1110_PRODUCT_ID:		mxport->mxp_uart_types = MXU1_TYPE_RS232;		mxport->mxp_uart_mode = MXU1_UART_232;		break;	case MXU1_1130_PRODUCT_ID:	case MXU1_1131_PRODUCT_ID:		mxport->mxp_uart_types = MXU1_TYPE_RS422 | MXU1_TYPE_RS485;		mxport->mxp_uart_mode = MXU1_UART_485_RECEIVER_DISABLED;		break;	case MXU1_1150_PRODUCT_ID:	case MXU1_1151_PRODUCT_ID:		mxport->mxp_uart_types =			MXU1_TYPE_RS232 | MXU1_TYPE_RS422 | MXU1_TYPE_RS485;		mxport->mxp_uart_mode = MXU1_UART_232;		break;	}	usb_set_serial_port_data(port, mxport);	port->port.closing_wait =			msecs_to_jiffies(MXU1_DEFAULT_CLOSING_WAIT * 10);	port->port.drain_delay = 1;	return 0;}
开发者ID:efferre79,项目名称:mxu11x0,代码行数:48,


示例10: pl2303_port_probe

static int pl2303_port_probe(struct usb_serial_port *port){	struct pl2303_private *priv;	priv = kzalloc(sizeof(*priv), GFP_KERNEL);	if (!priv)		return -ENOMEM;	spin_lock_init(&priv->lock);	usb_set_serial_port_data(port, priv);	port->port.drain_delay = 256;	return 0;}
开发者ID:IIosTaJI,项目名称:linux-2.6,代码行数:16,


示例11: mct_u232_shutdown

static void mct_u232_shutdown (struct usb_serial *serial){	struct mct_u232_private *priv;	int i;		dbg("%s", __FUNCTION__);	for (i=0; i < serial->num_ports; ++i) {		/* My special items, the standard routines free my urbs */		priv = usb_get_serial_port_data(serial->port[i]);		if (priv) {			usb_set_serial_port_data(serial->port[i], NULL);			kfree(priv);		}	}} /* mct_u232_shutdown */
开发者ID:ena30,项目名称:snake-os,代码行数:16,


示例12: qt_release

static void qt_release(struct usb_serial *serial){	struct usb_serial_port *port;	struct quatech_port *qt_port;	int i;	for (i = 0; i < serial->num_ports; i++) {		port = serial->port[i];		if (!port)			continue;		qt_port = usb_get_serial_port_data(port);		kfree(qt_port);		usb_set_serial_port_data(port, NULL);	}}
开发者ID:AiWinters,项目名称:linux,代码行数:17,


示例13: sierra_startup

static int sierra_startup(struct usb_serial *serial){	struct usb_serial_port *port;	struct sierra_port_private *portdata;	struct urb *urb;	int i;	int j;	dbg("%s", __FUNCTION__);	/*Set Device mode to D0 */	sierra_set_power_state(serial->dev, 0x0000);	/* Now setup per port private data */	for (i = 0; i < serial->num_ports; i++) {		port = serial->port[i];		portdata = kzalloc(sizeof(*portdata), GFP_KERNEL);		if (!portdata) {			dbg("%s: kmalloc for sierra_port_private (%d) failed!.",					__FUNCTION__, i);			return -ENOMEM;		}		spin_lock_init(&portdata->lock);		usb_set_serial_port_data(port, portdata);		/* initialize the in urbs */		for (j = 0; j < N_IN_URB; ++j) {			urb = usb_alloc_urb(0, GFP_KERNEL);			if (urb == NULL) {				dbg("%s: alloc for in port failed.",				    __FUNCTION__);				continue;			}			/* Fill URB using supplied data. */			usb_fill_bulk_urb(urb, serial->dev,					  usb_rcvbulkpipe(serial->dev,						port->bulk_in_endpointAddress),					  portdata->in_buffer[j], IN_BUFLEN,					  sierra_indat_callback, port);			portdata->in_urbs[j] = urb;		}	}	return 0;}
开发者ID:PennPanda,项目名称:linux-repo,代码行数:46,


示例14: sierra_port_probe

static int sierra_port_probe(struct usb_serial_port *port){	struct usb_serial *serial = port->serial;	struct sierra_port_private *portdata;	const struct sierra_iface_info *himemoryp;	u8 ifnum;	portdata = kzalloc(sizeof(*portdata), GFP_KERNEL);	if (!portdata)		return -ENOMEM;	spin_lock_init(&portdata->lock);	init_usb_anchor(&portdata->active);	init_usb_anchor(&portdata->delayed);	/* Assume low memory requirements */	portdata->num_out_urbs = N_OUT_URB;	portdata->num_in_urbs  = N_IN_URB;	/* Determine actual memory requirements */	if (serial->num_ports == 1) {		/* Get interface number for composite device */		ifnum = sierra_interface_num(serial);		himemoryp = &typeB_interface_list;	} else {		/* This is really the usb-serial port number of the interface		 * rather than the interface number.		 */		ifnum = port->port_number;		himemoryp = &typeA_interface_list;	}	if (is_himemory(ifnum, himemoryp)) {		portdata->num_out_urbs = N_OUT_URB_HM;		portdata->num_in_urbs  = N_IN_URB_HM;	}	dev_dbg(&port->dev,			"Memory usage (urbs) interface #%d, in=%d, out=%d/n",			ifnum, portdata->num_in_urbs, portdata->num_out_urbs);	usb_set_serial_port_data(port, portdata);	return 0;}
开发者ID:asmalldev,项目名称:linux,代码行数:45,


示例15: ipaq_close

static void ipaq_close(struct usb_serial_port *port, struct file *filp){	struct ipaq_private	*priv = usb_get_serial_port_data(port);	dbg("%s - port %d", __FUNCTION__, port->number);			 	/*	 * shut down bulk read and write	 */	usb_unlink_urb(port->write_urb);	usb_unlink_urb(port->read_urb);	ipaq_destroy_lists(port);	kfree(priv);	usb_set_serial_port_data(port, NULL);	/* Uncomment the following line if you want to see some statistics in your syslog */	/* info ("Bytes In = %d  Bytes Out = %d", bytes_in, bytes_out); */}
开发者ID:FelipeFernandes1988,项目名称:Alice-1121-Modem,代码行数:18,


示例16: spcp8x5_port_probe

static int spcp8x5_port_probe(struct usb_serial_port *port){	const struct usb_device_id *id = usb_get_serial_data(port->serial);	struct spcp8x5_private *priv;	priv = kzalloc(sizeof(*priv), GFP_KERNEL);	if (!priv)		return -ENOMEM;	spin_lock_init(&priv->lock);	priv->quirks = id->driver_info;	usb_set_serial_port_data(port, priv);	port->port.drain_delay = 256;	return 0;}
开发者ID:kdave,项目名称:btrfs-devel,代码行数:18,


示例17: metrousb_shutdown

static void metrousb_shutdown(struct usb_serial *serial){	int i = 0;	dev_dbg(&serial->dev->dev, "%s/n", __func__);	/*                                        */	for (i = 0; i < serial->num_ports; ++i) {		/*                      */		metrousb_cleanup(serial->port[i]);		/*              */		kfree(usb_get_serial_port_data(serial->port[i]));		usb_set_serial_port_data(serial->port[i], NULL);		dev_dbg(&serial->dev->dev, "%s - freed port number=%d/n",			__func__, serial->port[i]->number);	}}
开发者ID:romanbb,项目名称:android_kernel_lge_d851,代码行数:19,


示例18: metrousb_shutdown

static void metrousb_shutdown(struct usb_serial *serial){	int i = 0;	dev_dbg(&serial->dev->dev, "%s/n", __func__);	/* Stop reading and writing on all ports. */	for (i = 0; i < serial->num_ports; ++i) {		/* Close any open urbs. */		metrousb_cleanup(serial->port[i]);		/* Free memory. */		kfree(usb_get_serial_port_data(serial->port[i]));		usb_set_serial_port_data(serial->port[i], NULL);		dev_dbg(&serial->dev->dev, "%s - freed port number=%d/n",			__func__, serial->port[i]->number);	}}
开发者ID:LITMUS-RT,项目名称:litmus-rt-odroidx,代码行数:19,


示例19: cyberjack_port_probe

static int cyberjack_port_probe(struct usb_serial_port *port){	struct cyberjack_private *priv;	int result;	priv = kmalloc(sizeof(struct cyberjack_private), GFP_KERNEL);	if (!priv)		return -ENOMEM;	spin_lock_init(&priv->lock);	priv->rdtodo = 0;	priv->wrfilled = 0;	priv->wrsent = 0;	usb_set_serial_port_data(port, priv);	result = usb_submit_urb(port->interrupt_in_urb, GFP_KERNEL);	if (result)		dev_err(&port->dev, "usb_submit_urb(read int) failed/n");	return 0;}
开发者ID:qiyunsheng5,项目名称:linux,代码行数:22,


示例20: qt2_port_probe

static int qt2_port_probe(struct usb_serial_port *port){	struct usb_serial *serial = port->serial;	struct qt2_port_private *port_priv;	u8 bEndpointAddress;	port_priv = kzalloc(sizeof(*port_priv), GFP_KERNEL);	if (!port_priv)		return -ENOMEM;	spin_lock_init(&port_priv->lock);	spin_lock_init(&port_priv->urb_lock);	port_priv->port = port;	port_priv->write_buffer = kmalloc(QT2_WRITE_BUFFER_SIZE, GFP_KERNEL);	if (!port_priv->write_buffer)		goto err_buf;	port_priv->write_urb = usb_alloc_urb(0, GFP_KERNEL);	if (!port_priv->write_urb)		goto err_urb;	bEndpointAddress = serial->port[0]->bulk_out_endpointAddress;	usb_fill_bulk_urb(port_priv->write_urb, serial->dev,				usb_sndbulkpipe(serial->dev, bEndpointAddress),				port_priv->write_buffer,				QT2_WRITE_BUFFER_SIZE,				qt2_write_bulk_callback, port);	usb_set_serial_port_data(port, port_priv);	return 0;err_urb:	kfree(port_priv->write_buffer);err_buf:	kfree(port_priv);	return -ENOMEM;}
开发者ID:asmalldev,项目名称:linux,代码行数:38,


示例21: belkin_sa_startup

/* do some startup allocations not currently performed by usb_serial_probe() */static int belkin_sa_startup (struct usb_serial *serial){	struct usb_device *dev = serial->dev;	struct belkin_sa_private *priv;	/* allocate the private data structure */	priv = kmalloc(sizeof(struct belkin_sa_private), GFP_KERNEL);	if (!priv)		return (-1); /* error */	/* set initial values for control structures */	spin_lock_init(&priv->lock);	priv->control_state = 0;	priv->last_lsr = 0;	priv->last_msr = 0;	/* see comments at top of file */	priv->bad_flow_control = (le16_to_cpu(dev->descriptor.bcdDevice) <= 0x0206) ? 1 : 0;	info("bcdDevice: %04x, bfc: %d", le16_to_cpu(dev->descriptor.bcdDevice), priv->bad_flow_control);	init_waitqueue_head(&serial->port[0]->write_wait);	usb_set_serial_port_data(serial->port[0], priv);		return (0);}
开发者ID:FatSunHYS,项目名称:OSCourseDesign,代码行数:24,


示例22: ch341_port_probe

static int ch341_port_probe(struct usb_serial_port *port){	struct ch341_private *priv;	int r;	priv = kzalloc(sizeof(struct ch341_private), GFP_KERNEL);	if (!priv)		return -ENOMEM;	spin_lock_init(&priv->lock);	priv->baud_rate = DEFAULT_BAUD_RATE;	priv->line_control = CH341_BIT_RTS | CH341_BIT_DTR;	r = ch341_configure(port->serial->dev, priv);	if (r < 0)		goto error;	usb_set_serial_port_data(port, priv);	return 0;error:	kfree(priv);	return r;}
开发者ID:19Dan01,项目名称:linux,代码行数:23,


示例23: ipw_disconnect

static void ipw_disconnect(struct usb_serial *serial){	struct usb_serial_port *port;	struct ipw_private *priv;	if (serial) {		port = &serial->port[0];		if (port->tty)			tty_hangup(port->tty);		priv = usb_get_serial_port_data(port);		kfree(priv);		usb_set_serial_port_data(port, NULL);		if (serial->dev) {                /* shutdown any bulk reads that might be going on */			if (serial->num_bulk_out)				usb_unlink_urb (port->write_urb);			if (serial->num_bulk_in)				usb_unlink_urb (port->read_urb);		}//2.6		usb_serial_generic_shutdown(serial);		kfree(serial);	}}
开发者ID:NieHao,项目名称:Tomato-RAF,代码行数:23,


示例24: mct_u232_startup

static int mct_u232_startup(struct usb_serial *serial){	struct mct_u232_private *priv;	struct usb_serial_port *port, *rport;	priv = kzalloc(sizeof(struct mct_u232_private), GFP_KERNEL);	if (!priv)		return -ENOMEM;	spin_lock_init(&priv->lock);	usb_set_serial_port_data(serial->port[0], priv);	init_waitqueue_head(&serial->port[0]->write_wait);	/* Puh, that's dirty */	port = serial->port[0];	rport = serial->port[1];	/* No unlinking, it wasn't submitted yet. */	usb_free_urb(port->read_urb);	port->read_urb = rport->interrupt_in_urb;	rport->interrupt_in_urb = NULL;	port->read_urb->context = port;	return 0;} /* mct_u232_startup */
开发者ID:flwh,项目名称:Alcatel_OT_985_kernel,代码行数:24,


示例25: ipaq_open

static int ipaq_open(struct usb_serial_port *port, struct file *filp){	struct usb_serial	*serial = port->serial;	struct ipaq_private	*priv;	struct ipaq_packet	*pkt;	int			i, result = 0;	int			retries = KP_RETRIES;	dbg("%s - port %d", __FUNCTION__, port->number);	bytes_in = 0;	bytes_out = 0;	priv = (struct ipaq_private *)kmalloc(sizeof(struct ipaq_private), GFP_KERNEL);	if (priv == NULL) {		err("%s - Out of memory", __FUNCTION__);		return -ENOMEM;	}	usb_set_serial_port_data(port, priv);	priv->active = 0;	priv->queue_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) {		goto enomem;	}	port->bulk_out_buffer = kmalloc(URBDATA_SIZE, GFP_KERNEL);	if (port->bulk_out_buffer == NULL) {		kfree(port->bulk_in_buffer);		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;		/* 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", __FUNCTION__, result);		goto error;	}	/*	 * 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, HZ / 10 + 1);		if (result == 0) {			return 0;		}	}	err("%s - failed doing control urb, error %d", __FUNCTION__, result);	goto error;enomem://.........这里部分代码省略.........
开发者ID:FelipeFernandes1988,项目名称:Alice-1121-Modem,代码行数:101,


示例26: hsictty_port_probe

static int hsictty_port_probe(struct usb_serial_port *port){	int i;	struct urb *urb;	struct hsictty_port_private *portdata;	struct usb_serial *serial = port->serial;#ifndef USE_READ_WORK	char task_name[50] = { 0 };#endif	portdata = kzalloc(sizeof(*portdata), GFP_KERNEL);	if (!portdata) {		hsictty_error("%s: alloc mem failed/n", __func__);		return -ENOMEM;	}	portdata->opened = 0;	portdata->lch_opened = 0;	portdata->channel = port->number;	INIT_LIST_HEAD(&portdata->pool);	spin_lock_init(&portdata->pool_lock);	sema_init(&portdata->ch_sem_w, 1);	sema_init(&portdata->ch_sem_r, 1);	init_completion(&portdata->tx_notifier);	init_completion(&portdata->rx_push_notifier);	init_usb_anchor(&portdata->delayed_urb);#ifdef USE_READ_WORK	INIT_WORK(&portdata->hsictty_read_work, hsictty_read_work);#else	sprintf(task_name, "hsictty_rx_task%d", portdata->channel);	portdata->thread_exit = 0;	portdata->rx_task = kthread_create(rx_threadfn, portdata, task_name);	init_completion(&portdata->rx_notifier);	if (portdata->rx_task)		wake_up_process(portdata->rx_task);#endif	for (i = 0; i < ARRAY_SIZE(portdata->in_urbs); ++i) {		urb = usb_alloc_urb(0, GFP_KERNEL);		if (urb == NULL) {			hsictty_dbg("%s: in urb alloc failed./n", __func__);			goto error;		}		portdata->in_urbs[i] = urb;		portdata->in_buffer[i] =		    usb_alloc_coherent(serial->dev, IN_BUFLEN, GFP_KERNEL,				       &urb->transfer_dma);		if (!portdata->in_buffer[i]) {			hsictty_dbg			    ("%s: in urb dma buffer alloc failed./n", __func__);			goto error;		}		/* Fill URB using supplied data. */		usb_fill_bulk_urb(urb, serial->dev,				  usb_sndbulkpipe(serial->dev,						  port->bulk_in_endpointAddress)				  | USB_DIR_IN, portdata->in_buffer[i],				  IN_BUFLEN, hsictty_read_callback, port);		urb->transfer_flags |= URB_NO_TRANSFER_DMA_MAP;	}	for (i = 0; i < ARRAY_SIZE(portdata->out_urbs); ++i) {		urb = usb_alloc_urb(0, GFP_KERNEL);		if (urb == NULL) {			hsictty_dbg("%s: in urb alloc failed./n", __func__);			goto error;		}		portdata->out_urbs[i] = urb;		portdata->out_buffer[i] =		    usb_alloc_coherent(serial->dev, OUT_BUFLEN, GFP_KERNEL,				       &urb->transfer_dma);		if (!portdata->out_buffer[i]) {			hsictty_dbg			    ("%s: in urb dma buffer alloc failed./n", __func__);			goto error;		}		/* Fill URB using supplied data. */		usb_fill_bulk_urb(urb, serial->dev,				  usb_sndbulkpipe(serial->dev,						  port->						  bulk_out_endpointAddress)				  | USB_DIR_OUT, portdata->out_buffer[i],				  OUT_BUFLEN, hsictty_write_callback, port);		urb->transfer_flags |= URB_NO_TRANSFER_DMA_MAP;	}	usb_set_serial_port_data(port, portdata);	return 0;error:	for (i = 0; i < ARRAY_SIZE(portdata->out_urbs); ++i) {		urb = portdata->out_urbs[i];		if (!urb)			continue;		if (portdata->out_buffer[i])			usb_free_coherent(serial->dev, OUT_BUFLEN,//.........这里部分代码省略.........
开发者ID:qkdang,项目名称:m462,代码行数:101,


示例27: whiteheat_attach

/***************************************************************************** * Connect Tech's White Heat serial driver functions *****************************************************************************/static int whiteheat_attach(struct usb_serial *serial){	struct usb_serial_port *command_port;	struct whiteheat_command_private *command_info;	struct whiteheat_hw_info *hw_info;	int pipe;	int ret;	int alen;	__u8 *command;	__u8 *result;	command_port = serial->port[COMMAND_PORT];	pipe = usb_sndbulkpipe(serial->dev,			command_port->bulk_out_endpointAddress);	command = kmalloc(2, GFP_KERNEL);	if (!command)		goto no_command_buffer;	command[0] = WHITEHEAT_GET_HW_INFO;	command[1] = 0;	result = kmalloc(sizeof(*hw_info) + 1, GFP_KERNEL);	if (!result)		goto no_result_buffer;	/*	 * When the module is reloaded the firmware is still there and	 * the endpoints are still in the usb core unchanged. This is the	 * unlinking bug in disguise. Same for the call below.	 */	usb_clear_halt(serial->dev, pipe);	ret = usb_bulk_msg(serial->dev, pipe, command, 2,						&alen, COMMAND_TIMEOUT_MS);	if (ret) {		dev_err(&serial->dev->dev, "%s: Couldn't send command [%d]/n",			serial->type->description, ret);		goto no_firmware;	} else if (alen != 2) {		dev_err(&serial->dev->dev, "%s: Send command incomplete [%d]/n",			serial->type->description, alen);		goto no_firmware;	}	pipe = usb_rcvbulkpipe(serial->dev,				command_port->bulk_in_endpointAddress);	/* See the comment on the usb_clear_halt() above */	usb_clear_halt(serial->dev, pipe);	ret = usb_bulk_msg(serial->dev, pipe, result,			sizeof(*hw_info) + 1, &alen, COMMAND_TIMEOUT_MS);	if (ret) {		dev_err(&serial->dev->dev, "%s: Couldn't get results [%d]/n",			serial->type->description, ret);		goto no_firmware;	} else if (alen != sizeof(*hw_info) + 1) {		dev_err(&serial->dev->dev, "%s: Get results incomplete [%d]/n",			serial->type->description, alen);		goto no_firmware;	} else if (result[0] != command[0]) {		dev_err(&serial->dev->dev, "%s: Command failed [%d]/n",			serial->type->description, result[0]);		goto no_firmware;	}	hw_info = (struct whiteheat_hw_info *)&result[1];	dev_info(&serial->dev->dev, "%s: Firmware v%d.%02d/n",		 serial->type->description,		 hw_info->sw_major_rev, hw_info->sw_minor_rev);	command_info = kmalloc(sizeof(struct whiteheat_command_private),								GFP_KERNEL);	if (command_info == NULL) {		dev_err(&serial->dev->dev,			"%s: Out of memory for port structures/n",			serial->type->description);		goto no_command_private;	}	mutex_init(&command_info->mutex);	command_info->port_running = 0;	init_waitqueue_head(&command_info->wait_command);	usb_set_serial_port_data(command_port, command_info);	command_port->write_urb->complete = command_port_write_callback;	command_port->read_urb->complete = command_port_read_callback;	kfree(result);	kfree(command);	return 0;no_firmware:	/* Firmware likely not running */	dev_err(&serial->dev->dev,		"%s: Unable to retrieve firmware version, try replugging/n",		serial->type->description);	dev_err(&serial->dev->dev,		"%s: If the firmware is not running (status led not blinking)/n",		serial->type->description);	dev_err(&serial->dev->dev,//.........这里部分代码省略.........
开发者ID:dgarnier,项目名称:linux,代码行数:101,



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


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