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

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

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

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

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

示例1: gl861_probe

static int gl861_probe(struct usb_interface *intf,		       const struct usb_device_id *id){	struct dvb_usb_device *d;	struct usb_host_interface *alt;	int ret;	if (intf->num_altsetting < 2)		return -ENODEV;	ret = dvb_usb_device_init(intf, &gl861_properties, THIS_MODULE, &d,				  adapter_nr);	if (ret == 0) {		alt = usb_altnum_to_altsetting(intf, 0);		if (alt == NULL) {			deb_rc("not alt found!/n");			return -ENODEV;		}		ret = usb_set_interface(d->udev, alt->desc.bInterfaceNumber,					alt->desc.bAlternateSetting);	}	return ret;}
开发者ID:71eh,项目名称:open80211s,代码行数:26,


示例2: cdc_ncm_select_altsetting

/* Select the MBIM altsetting iff it is preferred and available, * returning the number of the corresponding data interface altsetting */u8 cdc_ncm_select_altsetting(struct usbnet *dev, struct usb_interface *intf){	struct usb_host_interface *alt;	/* The MBIM spec defines a NCM compatible default altsetting,	 * which we may have matched:	 *	 *  "Functions that implement both NCM 1.0 and MBIM (an	 *   “NCM/MBIM function”) according to this recommendation	 *   shall provide two alternate settings for the	 *   Communication Interface.  Alternate setting 0, and the	 *   associated class and endpoint descriptors, shall be	 *   constructed according to the rules given for the	 *   Communication Interface in section 5 of [USBNCM10].	 *   Alternate setting 1, and the associated class and	 *   endpoint descriptors, shall be constructed according to	 *   the rules given in section 6 (USB Device Model) of this	 *   specification."	 */	if (prefer_mbim && intf->num_altsetting == 2) {		alt = usb_altnum_to_altsetting(intf, CDC_NCM_COMM_ALTSETTING_MBIM);		if (alt && cdc_ncm_comm_intf_is_mbim(alt) &&		    !usb_set_interface(dev->udev,				       intf->cur_altsetting->desc.bInterfaceNumber,				       CDC_NCM_COMM_ALTSETTING_MBIM))			return CDC_NCM_DATA_ALTSETTING_MBIM;	}	return CDC_NCM_DATA_ALTSETTING_NCM;}
开发者ID:smx-smx,项目名称:dsl-n55u,代码行数:32,


示例3: st5481_setup_d_out

static int st5481_setup_d_out(struct st5481_adapter *adapter){	struct usb_device *dev = adapter->usb_dev;	struct usb_interface *intf;	struct usb_host_interface *altsetting = NULL;	struct usb_host_endpoint *endpoint;	struct st5481_d_out *d_out = &adapter->d_out;	DBG(2,"");	intf = usb_ifnum_to_if(dev, 0);	if (intf)		altsetting = usb_altnum_to_altsetting(intf, 3);	if (!altsetting)		return -ENXIO;	// Allocate URBs and buffers for the D channel out	endpoint = &altsetting->endpoint[EP_D_OUT-1];	DBG(2,"endpoint address=%02x,packet size=%d",	    endpoint->desc.bEndpointAddress, le16_to_cpu(endpoint->desc.wMaxPacketSize));	return st5481_setup_isocpipes(d_out->urb, dev, 				      usb_sndisocpipe(dev, endpoint->desc.bEndpointAddress),				      NUM_ISO_PACKETS_D, SIZE_ISO_PACKETS_D_OUT,				      NUM_ISO_PACKETS_D * SIZE_ISO_PACKETS_D_OUT,				      usb_d_out_complete, adapter);}
开发者ID:Antonio-Zhou,项目名称:Linux-2.6.11,代码行数:28,


示例4: st5481_setup_b_out

static int st5481_setup_b_out(struct st5481_bcs *bcs){	struct usb_device *dev = bcs->adapter->usb_dev;	struct usb_interface *intf;	struct usb_host_interface *altsetting = NULL;	struct usb_host_endpoint *endpoint;  	struct st5481_b_out *b_out = &bcs->b_out;	DBG(4,"");	intf = usb_ifnum_to_if(dev, 0);	if (intf)		altsetting = usb_altnum_to_altsetting(intf, 3);	if (!altsetting)		return -ENXIO;	// Allocate URBs and buffers for the B channel out	endpoint = &altsetting->endpoint[EP_B1_OUT - 1 + bcs->channel * 2];	DBG(4,"endpoint address=%02x,packet size=%d",	    endpoint->desc.bEndpointAddress, le16_to_cpu(endpoint->desc.wMaxPacketSize));	// Allocate memory for 8000bytes/sec + extra bytes if underrun	return st5481_setup_isocpipes(b_out->urb, dev, 				      usb_sndisocpipe(dev, endpoint->desc.bEndpointAddress),				      NUM_ISO_PACKETS_B, SIZE_ISO_PACKETS_B_OUT,				      NUM_ISO_PACKETS_B * SIZE_ISO_PACKETS_B_OUT + B_FLOW_ADJUST,				      usb_b_out_complete, bcs);}
开发者ID:ena30,项目名称:snake-os,代码行数:29,


示例5: friio_probe

static int friio_probe(struct usb_interface *intf,		       const struct usb_device_id *id){	struct dvb_usb_device *d;	struct usb_host_interface *alt;	int ret;	if (intf->num_altsetting < GL861_ALTSETTING_COUNT)		return -ENODEV;	alt = usb_altnum_to_altsetting(intf, FRIIO_BULK_ALTSETTING);	if (alt == NULL) {		deb_rc("not alt found!/n");		return -ENODEV;	}	ret = usb_set_interface(interface_to_usbdev(intf),				alt->desc.bInterfaceNumber,				alt->desc.bAlternateSetting);	if (ret != 0) {		deb_rc("failed to set alt-setting!/n");		return ret;	}	ret = dvb_usb_device_init(intf, &friio_properties,				  THIS_MODULE, &d, adapter_nr);	if (ret == 0)		friio_streaming_ctrl(&d->adapter[0], 1);	return ret;}
开发者ID:OpenStbV4l-dvb,项目名称:v4l-dvb,代码行数:30,


示例6: anysee_probe

static int anysee_probe(struct usb_interface *intf,			const struct usb_device_id *id){	struct dvb_usb_device *d;	struct usb_host_interface *alt;	int ret;	/* There is one interface with two alternate settings.	   Alternate setting 0 is for bulk transfer.	   Alternate setting 1 is for isochronous transfer.	   We use bulk transfer (alternate setting 0). */	if (intf->num_altsetting < 1)		return -ENODEV;	ret = dvb_usb_device_init(intf, &anysee_properties, THIS_MODULE, &d,		adapter_nr);	if (ret)		return ret;	alt = usb_altnum_to_altsetting(intf, 0);	if (alt == NULL) {		deb_info("%s: no alt found!/n", __func__);		return -ENODEV;	}	ret = usb_set_interface(d->udev, alt->desc.bInterfaceNumber,		alt->desc.bAlternateSetting);	if (ret)		return ret;	if (d)		ret = anysee_init(d);	return ret;}
开发者ID:E-LLP,项目名称:n900,代码行数:35,


示例7: m920x_probe

static int m920x_probe(struct usb_interface *intf,		       const struct usb_device_id *id){	struct dvb_usb_device *d;	struct usb_host_interface *alt;	int ret;	if ((ret = dvb_usb_device_init(intf, &megasky_properties, THIS_MODULE, &d)) == 0) {		deb_rc("probed!/n");		alt = usb_altnum_to_altsetting(intf, 1);		if (alt == NULL) {			deb_rc("not alt found!/n");			return -ENODEV;		}		ret = usb_set_interface(d->udev, alt->desc.bInterfaceNumber,					alt->desc.bAlternateSetting);		if (ret < 0)			return ret;		deb_rc("Changed to alternate setting!/n");		if ((ret = m9206_rc_init(d->udev)) != 0)			return ret;	}	return ret;}
开发者ID:ManiacTwister,项目名称:linux-hnd,代码行数:28,


示例8: au6610_probe

static int au6610_probe(struct usb_interface *intf,			const struct usb_device_id *id){	struct dvb_usb_device *d;	struct usb_host_interface *alt;	int ret;	if (intf->num_altsetting < AU6610_ALTSETTING_COUNT)		return -ENODEV;	ret = dvb_usb_device_init(intf, &au6610_properties, THIS_MODULE, &d,				  adapter_nr);	if (ret == 0) {		alt = usb_altnum_to_altsetting(intf, AU6610_ALTSETTING);		if (alt == NULL) {			deb_info("%s: no alt found!/n", __func__);			return -ENODEV;		}		ret = usb_set_interface(d->udev, alt->desc.bInterfaceNumber,					alt->desc.bAlternateSetting);	}	return ret;}
开发者ID:beam,项目名称:linux-tbs-drivers,代码行数:25,


示例9: usb_reset_configuration

/** * usb_reset_configuration - lightweight device reset * @dev: the device whose configuration is being reset * * This issues a standard SET_CONFIGURATION request to the device using * the current configuration.  The effect is to reset most USB-related * state in the device, including interface altsettings (reset to zero), * endpoint halts (cleared), and data toggle (only for bulk and interrupt * endpoints).  Other usbcore state is unchanged, including bindings of * usb device drivers to interfaces. * * Because this affects multiple interfaces, avoid using this with composite * (multi-interface) devices.  Instead, the driver for each interface may * use usb_set_interface() on the interfaces it claims.  Be careful though; * some devices don't support the SET_INTERFACE request, and others won't * reset all the interface state (notably data toggles).  Resetting the whole * configuration would affect other drivers' interfaces. * * The caller must own the device lock. * * Returns zero on success, else a negative error code. */int usb_reset_configuration(struct usb_device *dev){	int			i, retval;	struct usb_host_config	*config;	if (dev->state == USB_STATE_SUSPENDED)		return -EHOSTUNREACH;	/* caller must have locked the device and must own	 * the usb bus readlock (so driver bindings are stable);	 * calls during probe() are fine	 */	for (i = 1; i < 16; ++i) {		usb_disable_endpoint(dev, i);		usb_disable_endpoint(dev, i + USB_DIR_IN);	}	config = dev->actconfig;	retval = usb_control_msg(dev, usb_sndctrlpipe(dev, 0),			USB_REQ_SET_CONFIGURATION, 0,			config->desc.bConfigurationValue, 0,			NULL, 0, USB_CTRL_SET_TIMEOUT);	if (retval < 0)		return retval;	dev->toggle[0] = dev->toggle[1] = 0;	/* re-init hc/hcd interface/endpoint state */	for (i = 0; i < config->desc.bNumInterfaces; i++) {		struct usb_interface *intf = config->interface[i];		struct usb_host_interface *alt;		if (device_is_registered(&intf->dev))			usb_remove_sysfs_intf_files(intf);		alt = usb_altnum_to_altsetting(intf, 0);		/* No altsetting 0?  We'll assume the first altsetting.		 * We could use a GetInterface call, but if a device is		 * so non-compliant that it doesn't have altsetting 0		 * then I wouldn't trust its reply anyway.		 */		if (!alt)			alt = &intf->altsetting[0];		intf->cur_altsetting = alt;		usb_enable_interface(dev, intf);		if (device_is_registered(&intf->dev))			usb_create_sysfs_intf_files(intf);	}	return 0;}
开发者ID:maliyu,项目名称:SOM2416,代码行数:74,


示例10:

static struct usb_interface *xusbatm_find_intf(struct usb_device *usb_dev, int altsetting, u8 ep){	struct usb_host_interface *alt;	struct usb_interface *intf;	int i, j;	for (i = 0; i < usb_dev->actconfig->desc.bNumInterfaces; i++)		if ((intf = usb_dev->actconfig->interface[i]) && (alt = usb_altnum_to_altsetting(intf, altsetting)))			for (j = 0; j < alt->desc.bNumEndpoints; j++)				if (alt->endpoint[j].desc.bEndpointAddress == ep)					return intf;	return NULL;}
开发者ID:020gzh,项目名称:linux,代码行数:13,


示例11: st6422_start

static int st6422_start(struct sd *sd){	int err, packet_size;	struct cam *cam = &sd->gspca_dev.cam;	s32 *sensor_settings = sd->sensor_priv;	struct usb_host_interface *alt;	struct usb_interface *intf;	intf = usb_ifnum_to_if(sd->gspca_dev.dev, sd->gspca_dev.iface);	alt = usb_altnum_to_altsetting(intf, sd->gspca_dev.alt);	if (!alt) {		PDEBUG(D_ERR, "Couldn't get altsetting");		return -EIO;	}	packet_size = le16_to_cpu(alt->endpoint[0].desc.wMaxPacketSize);	err = stv06xx_write_bridge(sd, 0x15c1, packet_size);	if (err < 0)		return err;	if (cam->cam_mode[sd->gspca_dev.curr_mode].priv)		err = stv06xx_write_bridge(sd, 0x1505, 0x0f);	else		err = stv06xx_write_bridge(sd, 0x1505, 0x02);	if (err < 0)		return err;	err = st6422_set_brightness(&sd->gspca_dev,				    sensor_settings[BRIGHTNESS_IDX]);	if (err < 0)		return err;	err = st6422_set_contrast(&sd->gspca_dev,				  sensor_settings[CONTRAST_IDX]);	if (err < 0)		return err;	err = st6422_set_exposure(&sd->gspca_dev,				  sensor_settings[EXPOSURE_IDX]);	if (err < 0)		return err;	err = st6422_set_gain(&sd->gspca_dev,			      sensor_settings[GAIN_IDX]);	if (err < 0)		return err;	PDEBUG(D_STREAM, "Starting stream");	return 0;}
开发者ID:mikuhatsune001,项目名称:linux2.6.32,代码行数:51,


示例12: usb_reset_configuration

/** * usb_reset_configuration - lightweight device reset * @dev: the device whose configuration is being reset * * This issues a standard SET_CONFIGURATION request to the device using * the current configuration.  The effect is to reset most USB-related * state in the device, including interface altsettings (reset to zero), * endpoint halts (cleared), and data toggle (only for bulk and interrupt * endpoints).  Other usbcore state is unchanged, including bindings of * usb device drivers to interfaces. * * Because this affects multiple interfaces, avoid using this with composite * (multi-interface) devices.  Instead, the driver for each interface may * use usb_set_interface() on the interfaces it claims.  Resetting the whole * configuration would affect other drivers' interfaces. * * Returns zero on success, else a negative error code. */int usb_reset_configuration(struct usb_device *dev){	int			i, retval;	struct usb_host_config	*config;	/* caller must own dev->serialize (config won't change)	 * and the usb bus readlock (so driver bindings are stable);	 * so calls during probe() are fine	 */	for (i = 1; i < 16; ++i) {		usb_disable_endpoint(dev, i);		usb_disable_endpoint(dev, i + USB_DIR_IN);	}	config = dev->actconfig;	retval = usb_control_msg(dev, usb_sndctrlpipe(dev, 0),			USB_REQ_SET_CONFIGURATION, 0,			config->desc.bConfigurationValue, 0,			NULL, 0, HZ * USB_CTRL_SET_TIMEOUT);	if (retval < 0) {		usb_set_device_state(dev, USB_STATE_ADDRESS);		return retval;	}	dev->toggle[0] = dev->toggle[1] = 0;	dev->halted[0] = dev->halted[1] = 0;	/* re-init hc/hcd interface/endpoint state */	for (i = 0; i < config->desc.bNumInterfaces; i++) {		struct usb_interface *intf = config->interface[i];		struct usb_host_interface *alt;		alt = usb_altnum_to_altsetting(intf, 0);		/* No altsetting 0?  We'll assume the first altsetting.		 * We could use a GetInterface call, but if a device is		 * so non-compliant that it doesn't have altsetting 0		 * then I wouldn't trust its reply anyway.		 */		if (!alt)			alt = &intf->altsetting[0];		intf->cur_altsetting = alt;		usb_enable_interface(dev, intf);	}	return 0;}
开发者ID:earthGavinLee,项目名称:hg556a_source,代码行数:66,


示例13: lme2510_identify_state

static int lme2510_identify_state(struct usb_device *dev,				 struct dvb_usb_device_properties *props,				 struct dvb_usb_device_description **desc,				 int *cold){	struct usb_host_interface *alt;	struct usb_host_endpoint  *e;	printk("%s/n",__func__);	alt = usb_altnum_to_altsetting(usb_ifnum_to_if(dev, 0), 1);	e = alt->endpoint + 4;	if (e->desc.bmAttributes == USB_ENDPOINT_XFER_BULK)		*cold = 0;	else		*cold = 1;	mdelay(1000); return 0;}
开发者ID:gentooo,项目名称:s2-liplianin,代码行数:22,


示例14: anysee_probe

static int anysee_probe(struct usb_interface *intf,			const struct usb_device_id *id){	struct dvb_usb_device *d;	struct usb_host_interface *alt;	int ret;	/* There is one interface with two alternate settings.	   Alternate setting 0 is for bulk transfer.	   Alternate setting 1 is for isochronous transfer.	   We use bulk transfer (alternate setting 0). */	if (intf->num_altsetting < 1)		return -ENODEV;	/*	 * Anysee is always warm (its USB-bridge, Cypress FX2, uploads	 * firmware from eeprom).  If dvb_usb_device_init() succeeds that	 * means d is a valid pointer.	 */	ret = dvb_usb_device_init(intf, &anysee_properties, THIS_MODULE, &d,		adapter_nr);	if (ret)		return ret;	alt = usb_altnum_to_altsetting(intf, 0);	if (alt == NULL) {		deb_info("%s: no alt found!/n", __func__);		return -ENODEV;	}	ret = usb_set_interface(d->udev, alt->desc.bInterfaceNumber,		alt->desc.bAlternateSetting);	if (ret)		return ret;	return anysee_init(d);}
开发者ID:3null,项目名称:fastsocket,代码行数:37,


示例15: usb_set_configuration

//.........这里部分代码省略.........					"limit by %dmA/n",					configuration, -i);	}	/* Wake up the device so we can send it the Set-Config request */	ret = usb_autoresume_device(dev);	if (ret)		goto free_interfaces;	/* if it's already configured, clear out old state first.	 * getting rid of old interfaces means unbinding their drivers.	 */	if (dev->state != USB_STATE_ADDRESS)		usb_disable_device (dev, 1);	// Skip ep0	if ((ret = usb_control_msg(dev, usb_sndctrlpipe(dev, 0),			USB_REQ_SET_CONFIGURATION, 0, configuration, 0,			NULL, 0, USB_CTRL_SET_TIMEOUT)) < 0) {		/* All the old state is gone, so what else can we do?		 * The device is probably useless now anyway.		 */		cp = NULL;	}	dev->actconfig = cp;	if (!cp) {		usb_set_device_state(dev, USB_STATE_ADDRESS);		usb_autosuspend_device(dev);		goto free_interfaces;	}	usb_set_device_state(dev, USB_STATE_CONFIGURED);	/* Initialize the new interface structures and the	 * hc/hcd/usbcore interface/endpoint state.	 */	for (i = 0; i < nintf; ++i) {		struct usb_interface_cache *intfc;		struct usb_interface *intf;		struct usb_host_interface *alt;		cp->interface[i] = intf = new_interfaces[i];		intfc = cp->intf_cache[i];		intf->altsetting = intfc->altsetting;		intf->num_altsetting = intfc->num_altsetting;		kref_get(&intfc->ref);		alt = usb_altnum_to_altsetting(intf, 0);		/* No altsetting 0?  We'll assume the first altsetting.		 * We could use a GetInterface call, but if a device is		 * so non-compliant that it doesn't have altsetting 0		 * then I wouldn't trust its reply anyway.		 */		if (!alt)			alt = &intf->altsetting[0];		intf->cur_altsetting = alt;		usb_enable_interface(dev, intf);		intf->dev.parent = &dev->dev;		intf->dev.driver = NULL;		intf->dev.bus = &usb_bus_type;		intf->dev.dma_mask = dev->dev.dma_mask;		intf->dev.release = release_interface;		device_initialize (&intf->dev);		mark_quiesced(intf);		sprintf (&intf->dev.bus_id[0], "%d-%s:%d.%d",			 dev->bus->busnum, dev->devpath,			 configuration, alt->desc.bInterfaceNumber);	}	kfree(new_interfaces);	if (cp->string == NULL)		cp->string = usb_cache_string(dev, cp->desc.iConfiguration);	/* Now that all the interfaces are set up, register them	 * to trigger binding of drivers to interfaces.  probe()	 * routines may install different altsettings and may	 * claim() any interfaces not yet bound.  Many class drivers	 * need that: CDC, audio, video, etc.	 */	for (i = 0; i < nintf; ++i) {		struct usb_interface *intf = cp->interface[i];		dev_dbg (&dev->dev,			"adding %s (config #%d, interface %d)/n",			intf->dev.bus_id, configuration,			intf->cur_altsetting->desc.bInterfaceNumber);		ret = device_add (&intf->dev);		if (ret != 0) {			dev_err(&dev->dev, "device_add(%s) --> %d/n",				intf->dev.bus_id, ret);			continue;		}		usb_create_sysfs_intf_files (intf);	}	usb_autosuspend_device(dev);	return 0;}
开发者ID:maliyu,项目名称:SOM2416,代码行数:101,


示例16: usb_set_configuration

//.........这里部分代码省略.........	}	/* if it's already configured, clear out old state first.	 * getting rid of old interfaces means unbinding their drivers.	 */	if (dev->state != USB_STATE_ADDRESS)		usb_disable_device (dev, 1);	// Skip ep0	//设置配置编号	if ((ret = usb_control_msg(dev, usb_sndctrlpipe(dev, 0),			USB_REQ_SET_CONFIGURATION, 0, configuration, 0,			NULL, 0, USB_CTRL_SET_TIMEOUT)) < 0) {		/* All the old state is gone, so what else can we do?		 * The device is probably useless now anyway.		 */		cp = NULL;	}	//当前的配置对象	dev->actconfig = cp;	if (!cp) {		usb_set_device_state(dev, USB_STATE_ADDRESS);		goto free_interfaces;	}	usb_set_device_state(dev, USB_STATE_CONFIGURED);	/* Initialize the new interface structures and the	 * hc/hcd/usbcore interface/endpoint state.	 */	//对interface对象赋值	for (i = 0; i < nintf; ++i) {		struct usb_interface_cache *intfc;		struct usb_interface *intf;		struct usb_host_interface *alt;		cp->interface[i] = intf = new_interfaces[i];		intfc = cp->intf_cache[i];		intf->altsetting = intfc->altsetting;		intf->num_altsetting = intfc->num_altsetting;		kref_get(&intfc->ref);		alt = usb_altnum_to_altsetting(intf, 0);		/* No altsetting 0?  We'll assume the first altsetting.		 * We could use a GetInterface call, but if a device is		 * so non-compliant that it doesn't have altsetting 0		 * then I wouldn't trust its reply anyway.		 */		if (!alt)			alt = &intf->altsetting[0];		intf->cur_altsetting = alt;		usb_enable_interface(dev, intf);		intf->dev.parent = &dev->dev;		intf->dev.driver = NULL;		/*总线驱动模型中,interface作为设备,如果interface是一个usb hub(bInterfaceClass=9),则按总线驱动模型,就会匹配hub_driver驱动,调用device_add后,		  最后调用hub_probe,去 分配usb_hub对象,并为每个hub关联中断处理函数,当hub端口中有设备插入时,hub产生		  一中断hub_irq,最终唤醒线程hub_thread,然后为usb设备分配设备号(hub_port_connect_change)		  ;如果interface是一个usb设备(bInterfaceClass=x),比如:usbmouse,此时会去匹配usb_mouse_driver。			*/		intf->dev.bus = &usb_bus_type;		intf->dev.dma_mask = dev->dev.dma_mask;		intf->dev.release = release_interface;		device_initialize (&intf->dev);		mark_quiesced(intf);		sprintf (&intf->dev.bus_id[0], "%d-%s:%d.%d",			 dev->bus->busnum, dev->devpath,			 configuration, alt->desc.bInterfaceNumber);	}	kfree(new_interfaces);	if (cp->string == NULL)		cp->string = usb_cache_string(dev, cp->desc.iConfiguration);	/* Now that all the interfaces are set up, register them	 * to trigger binding of drivers to interfaces.  probe()	 * routines may install different altsettings and may	 * claim() any interfaces not yet bound.  Many class drivers	 * need that: CDC, audio, video, etc.	 */	/*每个接口代表一个功能,每个接口都有一个驱动程序,载之*/	for (i = 0; i < nintf; ++i) {		struct usb_interface *intf = cp->interface[i];		dev_dbg (&dev->dev,			"adding %s (config #%d, interface %d)/n",			intf->dev.bus_id, configuration,			intf->cur_altsetting->desc.bInterfaceNumber);		//执行后,设备驱动将执行探针接口:hub_probe,storage_probe		ret = device_add (&intf->dev);		if (ret != 0) {			dev_err(&dev->dev, "device_add(%s) --> %d/n",				intf->dev.bus_id, ret);			continue;		}		usb_create_sysfs_intf_files (intf);	}	return 0;}
开发者ID:laitianli,项目名称:kernel-analyze_linux-2.6.18,代码行数:101,


示例17: raidb0mb_probe

static int raidb0mb_probe(struct usb_interface *intf,      const struct usb_device_id *id){  raidb0mb_device *dev;  struct usb_device * udev;  struct usb_host_interface * hintf;  struct usb_endpoint_descriptor * endp;  struct net_device * netdev;  raidb0mb_bullet * bull;  int i, retval, t;  udev = interface_to_usbdev(intf);  netdev = alloc_etherdev(sizeof(raidb0mb_device));  if (!netdev) {    return -ENOMEM;  }  netdev->netdev_ops = &raidb0mb_netdev_ops;  netdev->watchdog_timeo = IPHETH_TX_TIMEOUT;  strcpy(netdev->name, "eth%d");  dev = netdev_priv(netdev);  dev->udev = udev;  dev->net = netdev;  dev->intf = intf;  /* Set up endpoints */  hintf = usb_altnum_to_altsetting(intf, IPHETH_ALT_INTFNUM);  if (hintf == NULL) {    retval = -ENODEV;    dev_err(&intf->dev, "Unable to find alternate settings interface/n");    goto err_endpoints;  }  for (i=0;i<hintf->desc.bNumEndpoints;i++) {    endp = &hintf->endpoint[i].desc;    if (usb_endpoint_is_bulk_in(endp)) {      dev->bulk_in = endp->bEndpointAddress;    } else if (usb_endpoint_is_bulk_out(endp)) {      dev->bulk_out = endp->bEndpointAddress;    }  }  if (!(dev->bulk_in && dev->bulk_out)) {    retval = -ENODEV;    dev_err(&intf->dev, "Unable to find endpoints/n");    goto err_endpoints;  }  dev->ctrl_buf = kmalloc(IPHETH_CTRL_BUF_SIZE, GFP_KERNEL);  if (dev->ctrl_buf == NULL) {    retval = -ENOMEM;    goto err_alloc_ctrl_buf;  }  retval = raidb0mb_get_macaddr(dev);  if (retval) {    goto err_get_macaddr;  }  bull = kmalloc(sizeof(raidb0mb_bullet), GFP_KERNEL);  for (t=0;t<=255;t++)  {    bull->req = t;    dev_info(&intf->dev, "Round %d/n", t);    bull->req_type = 0xc0;    bull->val = 0x00;    bull->index = 0x02;    retval = raidb0mb_send_command(dev, bull);      }  INIT_DELAYED_WORK(&dev->carrier_work, raidb0mb_carrier_check_work);  retval = raidb0mb_alloc_urbs(dev);    if (retval) {    dev_err(&intf->dev, "error allocating urbs: %d/n", retval);    goto err_alloc_urbs;  }  /*  usb_set_intfdata(intf, dev);  SET_NETDEV_DEV(netdev, &intf->dev);  SET_ETHTOOL_OPS(netdev, &ops);  retval = register_netdev(netdev);  if (retval) {    dev_err(&intf->dev, "error registering netdev: %d/n", retval);    retval = -EIO;    goto err_register_netdev;  }  */  dev_info(&intf->dev, "Apple iPhone USB Ethernet device attached/n");//.........这里部分代码省略.........
开发者ID:dancipher,项目名称:iphone_raidb0mb,代码行数:101,


示例18: ipheth_probe

static int ipheth_probe(struct usb_interface *intf,			const struct usb_device_id *id){	struct usb_device *udev = interface_to_usbdev(intf);	struct usb_host_interface *hintf;	struct usb_endpoint_descriptor *endp;	struct ipheth_device *dev;	struct net_device *netdev;	int i;	int retval;	netdev = alloc_etherdev(sizeof(struct ipheth_device));	if (!netdev)		return -ENOMEM;	netdev->netdev_ops = &ipheth_netdev_ops;	netdev->watchdog_timeo = IPHETH_TX_TIMEOUT;	strcpy(netdev->name, "eth%d");	dev = netdev_priv(netdev);	dev->udev = udev;	dev->net = netdev;	dev->intf = intf;	dev->confirmed_pairing = false;	/* Set up endpoints */	hintf = usb_altnum_to_altsetting(intf, IPHETH_ALT_INTFNUM);	if (hintf == NULL) {		retval = -ENODEV;		dev_err(&intf->dev, "Unable to find alternate settings interface/n");		goto err_endpoints;	}	for (i = 0; i < hintf->desc.bNumEndpoints; i++) {		endp = &hintf->endpoint[i].desc;		if (usb_endpoint_is_bulk_in(endp))			dev->bulk_in = endp->bEndpointAddress;		else if (usb_endpoint_is_bulk_out(endp))			dev->bulk_out = endp->bEndpointAddress;	}	if (!(dev->bulk_in && dev->bulk_out)) {		retval = -ENODEV;		dev_err(&intf->dev, "Unable to find endpoints/n");		goto err_endpoints;	}	dev->ctrl_buf = kmalloc(IPHETH_CTRL_BUF_SIZE, GFP_KERNEL);	if (dev->ctrl_buf == NULL) {		retval = -ENOMEM;		goto err_alloc_ctrl_buf;	}	retval = ipheth_get_macaddr(dev);	if (retval)		goto err_get_macaddr;	INIT_DELAYED_WORK(&dev->carrier_work, ipheth_carrier_check_work);	retval = ipheth_alloc_urbs(dev);	if (retval) {		dev_err(&intf->dev, "error allocating urbs: %d/n", retval);		goto err_alloc_urbs;	}	usb_set_intfdata(intf, dev);	SET_NETDEV_DEV(netdev, &intf->dev);	netdev->ethtool_ops = &ops;	retval = register_netdev(netdev);	if (retval) {		dev_err(&intf->dev, "error registering netdev: %d/n", retval);		retval = -EIO;		goto err_register_netdev;	}	// carrier down and transmit queues stopped until packet from device	netif_carrier_off(netdev);	netif_tx_stop_all_queues(netdev);	dev_info(&intf->dev, "Apple iPhone USB Ethernet device attached/n");	return 0;err_register_netdev:	ipheth_free_urbs(dev);err_alloc_urbs:err_get_macaddr:err_alloc_ctrl_buf:	kfree(dev->ctrl_buf);err_endpoints:	free_netdev(netdev);	return retval;}
开发者ID:Lyude,项目名称:linux,代码行数:90,


示例19: ipheth_probe

static int ipheth_probe (struct usb_interface *intf,			 const struct usb_device_id *id){	struct usb_device *udev = interface_to_usbdev(intf);	struct usb_host_interface *hintf;	struct usb_endpoint_descriptor *endp;	struct ipheth_device *dev;	struct net_device *netdev;	int i;	int retval;	/* Ensure we are probing the right interface */	if (intf->cur_altsetting->desc.bInterfaceClass != IPHETH_USBINTF_CLASS ||	    intf->cur_altsetting->desc.bInterfaceSubClass != IPHETH_USBINTF_SUBCLASS)		return -ENODEV;	netdev = alloc_etherdev(sizeof(struct ipheth_device));	if (!netdev)		return -ENOMEM;#ifdef HAVE_NET_DEVICE_OPS	netdev->netdev_ops = &ipheth_netdev_ops;#else /* CONFIG_COMPAT_NET_DEV_OPS */	netdev->open = &ipheth_open;	netdev->stop = &ipheth_close;	netdev->hard_start_xmit = &ipheth_tx;	netdev->tx_timeout = &ipheth_tx_timeout;	netdev->get_stats = &ipheth_stats;#endif	netdev->watchdog_timeo = IPHETH_TX_TIMEOUT;	dev = netdev_priv(netdev);	dev->udev = udev;	dev->net = netdev;	dev->intf = intf;	/* Set up endpoints */	hintf = usb_altnum_to_altsetting (intf, IPHETH_ALT_INTFNUM);	if (hintf == NULL) {		retval = -ENODEV;		err("Unable to find alternate settings interface");		goto err_endpoints;	}	for (i = 0; i < hintf->desc.bNumEndpoints; i++) {		endp = &hintf->endpoint[i].desc;		if (usb_endpoint_is_bulk_in(endp))			dev->bulk_in = endp->bEndpointAddress;		else if (usb_endpoint_is_bulk_out(endp))			dev->bulk_out = endp->bEndpointAddress;	}	if (!(dev->bulk_in && dev->bulk_out)) {		retval = -ENODEV;		err("Unable to find endpoints");		goto err_endpoints;	}	dev->ctrl_buf = kmalloc(IPHETH_CTRL_BUF_SIZE, GFP_KERNEL);	if (dev->ctrl_buf == NULL) {		retval = -ENOMEM;		goto err_alloc_ctrl_buf;	}	if ((retval = ipheth_get_macaddr(dev)))		goto err_get_macaddr;	INIT_DELAYED_WORK(&dev->carrier_work, ipheth_carrier_check_work);	if ((retval = ipheth_alloc_urbs(dev))) {		err("error allocating urbs: %d", retval);		goto err_alloc_urbs;	}	usb_set_intfdata(intf, dev);	SET_NETDEV_DEV(netdev, &intf->dev);	SET_ETHTOOL_OPS(netdev, &ops);	if ((retval = register_netdev(netdev))) {		err("error registering netdev: %d", retval);		retval = -EIO;		goto err_register_netdev;	}	dev_info(&intf->dev, "Apple iPhone USB Ethernet device attached/n");	return 0;err_register_netdev:	ipheth_free_urbs(dev);err_alloc_urbs:err_get_macaddr:err_alloc_ctrl_buf:	kfree(dev->ctrl_buf);err_endpoints:	free_netdev(netdev);	return retval;}
开发者ID:aircross,项目名称:ray,代码行数:97,


示例20: st5481_setup_usb

int st5481_setup_usb(struct st5481_adapter *adapter){	struct usb_device *dev = adapter->usb_dev;	struct st5481_ctrl *ctrl = &adapter->ctrl;	struct st5481_intr *intr = &adapter->intr;	struct usb_interface *intf;	struct usb_host_interface *altsetting = NULL;	struct usb_host_endpoint *endpoint;	int status;	struct urb *urb;	u8 *buf;		DBG(2,"");		if ((status = usb_reset_configuration (dev)) < 0) {		WARNING("reset_configuration failed,status=%d",status);		return status;	}	intf = usb_ifnum_to_if(dev, 0);	if (intf)		altsetting = usb_altnum_to_altsetting(intf, 3);	if (!altsetting)		return -ENXIO;	// Check if the config is sane	if ( altsetting->desc.bNumEndpoints != 7 ) {		WARNING("expecting 7 got %d endpoints!", altsetting->desc.bNumEndpoints);		return -EINVAL;	}	// The descriptor is wrong for some early samples of the ST5481 chip	altsetting->endpoint[3].desc.wMaxPacketSize = __constant_cpu_to_le16(32);	altsetting->endpoint[4].desc.wMaxPacketSize = __constant_cpu_to_le16(32);	// Use alternative setting 3 on interface 0 to have 2B+D	if ((status = usb_set_interface (dev, 0, 3)) < 0) {		WARNING("usb_set_interface failed,status=%d",status);		return status;	}	// Allocate URB for control endpoint	urb = usb_alloc_urb(0, GFP_KERNEL);	if (!urb) {		return -ENOMEM;	}	ctrl->urb = urb;		// Fill the control URB	usb_fill_control_urb (urb, dev, 			  usb_sndctrlpipe(dev, 0),			  NULL, NULL, 0, usb_ctrl_complete, adapter);			fifo_init(&ctrl->msg_fifo.f, ARRAY_SIZE(ctrl->msg_fifo.data));	// Allocate URBs and buffers for interrupt endpoint	urb = usb_alloc_urb(0, GFP_KERNEL);	if (!urb) { 		return -ENOMEM;	}	intr->urb = urb;		buf = kmalloc(INT_PKT_SIZE, GFP_KERNEL);	if (!buf) {		return -ENOMEM;	}	endpoint = &altsetting->endpoint[EP_INT-1];					// Fill the interrupt URB	usb_fill_int_urb(urb, dev,		     usb_rcvintpipe(dev, endpoint->desc.bEndpointAddress),		     buf, INT_PKT_SIZE,		     usb_int_complete, adapter,		     endpoint->desc.bInterval);			return 0;}
开发者ID:119-org,项目名称:hi3518-osdrv,代码行数:79,


示例21: usb_set_configuration

//.........这里部分代码省略.........				kfree(new_interfaces);				return ret;			}		}	}	/* if it's already configured, clear out old state first.	 * getting rid of old interfaces means unbinding their drivers.	 */	if (dev->state != USB_STATE_ADDRESS)		usb_disable_device (dev, 1);	// Skip ep0	if ((ret = usb_control_msg(dev, usb_sndctrlpipe(dev, 0),			USB_REQ_SET_CONFIGURATION, 0, configuration, 0,			NULL, 0, HZ * USB_CTRL_SET_TIMEOUT)) < 0)		goto free_interfaces;	dev->actconfig = cp;	if (!cp)		usb_set_device_state(dev, USB_STATE_ADDRESS);	else {		usb_set_device_state(dev, USB_STATE_CONFIGURED);		/*
C++ usb_anchor_urb函数代码示例
C++ usb_alloc_urb函数代码示例
万事OK自学网:51自学网_软件自学网_CAD自学网自学excel、自学PS、自学CAD、自学C语言、自学css3实例,是一个通过网络自主学习工作技能的自学平台,网友喜欢的软件自学网站。