&dev->stats)) 
&dev->stats, &dev->cdc_filter)) 
eth_bind (struct usb_gadget *gadget){	struct eth_dev		*dev;	struct net_device	*net;	u8			cdc = 1, zlp = 1, rndis = 1;	struct usb_ep		*in_ep, *out_ep, *status_ep = NULL;	int			status = -ENOMEM;	/* these flags are only ever cleared; compiler take note */#ifndef	DEV_CONFIG_CDC	cdc = 0;#endif#ifndef	CONFIG_USB_ETH_RNDIS	rndis = 0;#endif	/* Because most host side USB stacks handle CDC Ethernet, that	 * standard protocol is _strongly_ preferred for interop purposes.	 * (By everyone except Microsoft.)	 */	if (gadget_is_net2280 (gadget)) {		device_desc.bcdDevice = __constant_cpu_to_le16 (0x0201);	} else if (gadget_is_dummy (gadget)) {		device_desc.bcdDevice = __constant_cpu_to_le16 (0x0202);	} else if (gadget_is_pxa (gadget)) {		device_desc.bcdDevice = __constant_cpu_to_le16 (0x0203);		/* pxa doesn't support altsettings */		cdc = 0;	} else if (gadget_is_sh(gadget)) {		device_desc.bcdDevice = __constant_cpu_to_le16 (0x0204);		/* sh doesn't support multiple interfaces or configs */		cdc = 0;		rndis = 0;	} else if (gadget_is_sa1100 (gadget)) {		device_desc.bcdDevice = __constant_cpu_to_le16 (0x0205);		/* hardware can't write zlps */		zlp = 0;		/* sa1100 CAN do CDC, without status endpoint ... we use		 * non-CDC to be compatible with ARM Linux-2.4 "usb-eth".		 */		cdc = 0;	} else if (gadget_is_goku (gadget)) {		device_desc.bcdDevice = __constant_cpu_to_le16 (0x0206);	} else if (gadget_is_mq11xx (gadget)) {		device_desc.bcdDevice = __constant_cpu_to_le16 (0x0207);	} else if (gadget_is_omap (gadget)) {		device_desc.bcdDevice = __constant_cpu_to_le16 (0x0208);	} else if (gadget_is_lh7a40x(gadget)) {		device_desc.bcdDevice = __constant_cpu_to_le16 (0x0209);	} else if (gadget_is_n9604(gadget)) {		device_desc.bcdDevice = __constant_cpu_to_le16 (0x0210);	} else if (gadget_is_pxa27x(gadget)) {		device_desc.bcdDevice = __constant_cpu_to_le16 (0x0211);	} else if (gadget_is_s3c2410(gadget)) {		device_desc.bcdDevice = __constant_cpu_to_le16 (0x0212);	} else if (gadget_is_at91(gadget)) {		device_desc.bcdDevice = __constant_cpu_to_le16 (0x0213);	} else {		/* can't assume CDC works.  don't want to default to		 * anything less functional on CDC-capable hardware,		 * so we fail in this case.		 */		dev_err (&gadget->dev,			"controller '%s' not recognized\n",			gadget->name);		return -ENODEV;	}	snprintf (manufacturer, sizeof manufacturer, "%s %s/%s",		system_utsname.sysname, system_utsname.release,		gadget->name);	/* If there's an RNDIS configuration, that's what Windows wants to	 * be using ... so use these product IDs here and in the "linux.inf"	 * needed to install MSFT drivers.  Current Linux kernels will use	 * the second configuration if it's CDC Ethernet, and need some help	 * to choose the right configuration otherwise.	 */	if (rndis) {		device_desc.idVendor =			__constant_cpu_to_le16(RNDIS_VENDOR_NUM);		device_desc.idProduct =			__constant_cpu_to_le16(RNDIS_PRODUCT_NUM);		snprintf (product_desc, sizeof product_desc,			"RNDIS/%s", driver_desc);	/* CDC subset ... recognized by Linux since 2.4.10, but Windows	 * drivers aren't widely available.	 */	} else if (!cdc) {		device_desc.bDeviceClass = USB_CLASS_VENDOR_SPEC;		device_desc.idVendor =			__constant_cpu_to_le16(SIMPLE_VENDOR_NUM);		device_desc.idProduct =			__constant_cpu_to_le16(SIMPLE_PRODUCT_NUM);	}	/* support optional vendor/distro customization */	if (idVendor) {		if (!idProduct) {			dev_err (&gadget->dev, "idVendor needs idProduct!\n");			return -ENODEV;		}		device_desc.idVendor = cpu_to_le16(idVendor);		device_desc.idProduct = cpu_to_le16(idProduct);		if (bcdDevice)			device_desc.bcdDevice = cpu_to_le16(bcdDevice);	}	if (iManufacturer)		strlcpy (manufacturer, iManufacturer, sizeof manufacturer);	if (iProduct)		strlcpy (product_desc, iProduct, sizeof product_desc);	/* all we really need is bulk IN/OUT */	usb_ep_autoconfig_reset (gadget);	in_ep = usb_ep_autoconfig (gadget, &fs_source_desc);	if (!in_ep) {autoconf_fail:		dev_err (&gadget->dev,			"can't autoconfigure on %s\n",			gadget->name);		return -ENODEV;	}	EP_IN_NAME = in_ep->name;	in_ep->driver_data = in_ep;	/* claim */		out_ep = usb_ep_autoconfig (gadget, &fs_sink_desc);	if (!out_ep)		goto autoconf_fail;	EP_OUT_NAME = out_ep->name;	out_ep->driver_data = out_ep;	/* claim */#if defined(DEV_CONFIG_CDC) || defined(CONFIG_USB_ETH_RNDIS)	/* CDC Ethernet control interface doesn't require a status endpoint.	 * Since some hosts expect one, try to allocate one anyway.	 */	if (cdc || rndis) {		status_ep = usb_ep_autoconfig (gadget, &fs_status_desc);		if (status_ep) {			EP_STATUS_NAME = status_ep->name;			status_ep->driver_data = status_ep;	/* claim */		} else if (rndis) {			dev_err (&gadget->dev,				"can't run RNDIS on %s\n",				gadget->name);			return -ENODEV;#ifdef DEV_CONFIG_CDC		/* pxa25x only does CDC subset; often used with RNDIS */		} else if (cdc) {			control_intf.bNumEndpoints = 0;			/* FIXME remove endpoint from descriptor list */#endif		}	}#endif	/* one config:  cdc, else minimal subset */	if (!cdc) {		eth_config.bNumInterfaces = 1;		eth_config.iConfiguration = STRING_SUBSET;		fs_subset_descriptors();		hs_subset_descriptors();	}	/* For now RNDIS is always a second config */	if (rndis)		device_desc.bNumConfigurations = 2;#ifdef	CONFIG_USB_GADGET_DUALSPEED	if (rndis)		dev_qualifier.bNumConfigurations = 2;	else if (!cdc)		dev_qualifier.bDeviceClass = USB_CLASS_VENDOR_SPEC;	/* assumes ep0 uses the same value for both speeds ... */	dev_qualifier.bMaxPacketSize0 = device_desc.bMaxPacketSize0;	/* and that all endpoints are dual-speed */	hs_source_desc.bEndpointAddress = fs_source_desc.bEndpointAddress;	hs_sink_desc.bEndpointAddress = fs_sink_desc.bEndpointAddress;#if defined(DEV_CONFIG_CDC) || defined(CONFIG_USB_ETH_RNDIS)	if (EP_STATUS_NAME)		hs_status_desc.bEndpointAddress =				fs_status_desc.bEndpointAddress;#endif#endif	/* DUALSPEED */	device_desc.bMaxPacketSize0 = gadget->ep0->maxpacket;	usb_gadget_set_selfpowered (gadget);	if (gadget->is_otg) {		otg_descriptor.bmAttributes |= USB_OTG_HNP,		eth_config.bmAttributes |= USB_CONFIG_ATT_WAKEUP;		eth_config.bMaxPower = 4;#ifdef	CONFIG_USB_ETH_RNDIS		rndis_config.bmAttributes |= USB_CONFIG_ATT_WAKEUP;		rndis_config.bMaxPower = 4;#endif	} 	net = alloc_etherdev (sizeof *dev); 	if (!net)		return status;	dev = netdev_priv(net);	spin_lock_init (&dev->lock);	INIT_WORK (&dev->work, eth_work, dev);	INIT_LIST_HEAD (&dev->tx_reqs);	INIT_LIST_HEAD (&dev->rx_reqs);	/* network device setup */	dev->net = net;	SET_MODULE_OWNER (net);	strcpy (net->name, "usb%d");	dev->cdc = cdc;	dev->zlp = zlp;	dev->in_ep = in_ep;	dev->out_ep = out_ep;	dev->status_ep = status_ep;	/* Module params for these addresses should come from ID proms.	 * The host side address is used with CDC and RNDIS, and commonly	 * ends up in a persistent config database.	 */	get_ether_addr(dev_addr, net->dev_addr);	if (cdc || rndis) {		get_ether_addr(host_addr, dev->host_mac);#ifdef	DEV_CONFIG_CDC		snprintf (ethaddr, sizeof ethaddr, "%02X%02X%02X%02X%02X%02X",			dev->host_mac [0], dev->host_mac [1],			dev->host_mac [2], dev->host_mac [3],			dev->host_mac [4], dev->host_mac [5]);#endif	}	if (rndis) {		status = rndis_init();		if (status < 0) {			dev_err (&gadget->dev, "can't init RNDIS, %d\n",				status);			goto fail;		}	}	net->change_mtu = eth_change_mtu;	net->get_stats = eth_get_stats;	net->hard_start_xmit = eth_start_xmit;	net->open = eth_open;	net->stop = eth_stop;	// watchdog_timeo, tx_timeout ...	// set_multicast_list	SET_ETHTOOL_OPS(net, &ops);	/* preallocate control message data and buffer */	dev->req = eth_req_alloc (gadget->ep0, USB_BUFSIZ);	if (!dev->req)		goto fail;	dev->req->complete = eth_setup_complete;	/* ... and maybe likewise for status transfer */	if (dev->status_ep) {		dev->stat_req = eth_req_alloc (dev->status_ep,					STATUS_BYTECOUNT);		if (!dev->stat_req) {			eth_req_free (gadget->ep0, dev->req);			goto fail;		}	}	/* finish hookup to lower layer ... */	dev->gadget = gadget;	set_gadget_data (gadget, dev);	gadget->ep0->driver_data = dev;		/* two kinds of host-initiated state changes:	 *  - iff DATA transfer is active, carrier is "on"	 *  - tx queueing enabled if open *and* carrier is "on"	 */	netif_stop_queue (dev->net);	netif_carrier_off (dev->net); 	// SET_NETDEV_DEV (dev->net, &gadget->dev); 	status = register_netdev (dev->net);	if (status < 0)		goto fail1;	INFO (dev, "%s, version: " DRIVER_VERSION "\n", driver_desc);	INFO (dev, "using %s, OUT %s IN %s%s%s\n", gadget->name,		EP_OUT_NAME, EP_IN_NAME,		EP_STATUS_NAME ? " STATUS " : "",		EP_STATUS_NAME ? EP_STATUS_NAME : ""		);	INFO (dev, "MAC %02x:%02x:%02x:%02x:%02x:%02x\n",		net->dev_addr [0], net->dev_addr [1],		net->dev_addr [2], net->dev_addr [3],		net->dev_addr [4], net->dev_addr [5]);	if (cdc || rndis)		INFO (dev, "HOST MAC %02x:%02x:%02x:%02x:%02x:%02x\n",			dev->host_mac [0], dev->host_mac [1],			dev->host_mac [2], dev->host_mac [3],			dev->host_mac [4], dev->host_mac [5]);#ifdef	CONFIG_USB_ETH_RNDIS	if (rndis) {		u32	vendorID = 0;		/* FIXME RNDIS vendor id == "vendor NIC code" == ? */				dev->rndis_config = rndis_register (rndis_control_ack);		if (dev->rndis_config < 0) {fail0:			unregister_netdev (dev->net);			status = -ENODEV;			goto fail;		}				/* these set up a lot of the OIDs that RNDIS needs */		rndis_set_host_mac (dev->rndis_config, dev->host_mac);		if (rndis_set_param_dev (dev->rndis_config, dev->net,					 &dev->stats))			goto fail0;		if (rndis_set_param_vendor (dev->rndis_config, vendorID,					    manufacturer))			goto fail0;		if (rndis_set_param_medium (dev->rndis_config,					    NDIS_MEDIUM_802_3,					    0))			goto fail0;		INFO (dev, "RNDIS ready\n");	}#endif		return status;fail1:	dev_dbg(&gadget->dev, "register_netdev failed, %d\n", status);fail:	eth_unbind (gadget);	return status;}
4520	/local/tlutelli/issta_data/temp/c/2005_temp/2005/4520/340600ab4cf0cc41efd01a65af97ebb7d35a7f85/ether.c/clean/drivers/usb/gadget/ether.c