unsigned long mmio_start; int mmio_len; int pci_using_dac; int i; int err; 
int i, err, pci_using_dac; 
e1000_probe(struct pci_dev *pdev,            const struct pci_device_id *ent){	struct net_device *netdev;	struct e1000_adapter *adapter;	static int cards_found = 0;	unsigned long mmio_start;	int mmio_len;	int pci_using_dac;	int i;	int err;	uint16_t eeprom_data;	uint16_t eeprom_apme_mask = E1000_EEPROM_APME;	if((err = pci_enable_device(pdev)))		return err;	if(!(err = pci_set_dma_mask(pdev, DMA_64BIT_MASK))) {		pci_using_dac = 1;	} else {		if((err = pci_set_dma_mask(pdev, DMA_32BIT_MASK))) {			E1000_ERR("No usable DMA configuration, aborting\n");			return err;		}		pci_using_dac = 0;	}	if((err = pci_request_regions(pdev, e1000_driver_name)))		return err;	pci_set_master(pdev);	netdev = alloc_etherdev(sizeof(struct e1000_adapter));	if(!netdev) {		err = -ENOMEM;		goto err_alloc_etherdev;	}	SET_MODULE_OWNER(netdev);	SET_NETDEV_DEV(netdev, &pdev->dev);	pci_set_drvdata(pdev, netdev);	adapter = netdev->priv;	adapter->netdev = netdev;	adapter->pdev = pdev;	adapter->hw.back = adapter;	adapter->msg_enable = (1 << debug) - 1;	mmio_start = pci_resource_start(pdev, BAR_0);	mmio_len = pci_resource_len(pdev, BAR_0);	adapter->hw.hw_addr = ioremap(mmio_start, mmio_len);	if(!adapter->hw.hw_addr) {		err = -EIO;		goto err_ioremap;	}	for(i = BAR_1; i <= BAR_5; i++) {		if(pci_resource_len(pdev, i) == 0)			continue;		if(pci_resource_flags(pdev, i) & IORESOURCE_IO) {			adapter->hw.io_base = pci_resource_start(pdev, i);			break;		}	}	netdev->open = &e1000_open;	netdev->stop = &e1000_close;	netdev->hard_start_xmit = &e1000_xmit_frame;	netdev->get_stats = &e1000_get_stats;	netdev->set_multicast_list = &e1000_set_multi;	netdev->set_mac_address = &e1000_set_mac;	netdev->change_mtu = &e1000_change_mtu;	netdev->do_ioctl = &e1000_ioctl;	e1000_set_ethtool_ops(netdev);	netdev->tx_timeout = &e1000_tx_timeout;	netdev->watchdog_timeo = 5 * HZ;#ifdef CONFIG_E1000_NAPI	netdev->poll = &e1000_clean;	netdev->weight = 64;#endif	netdev->vlan_rx_register = e1000_vlan_rx_register;	netdev->vlan_rx_add_vid = e1000_vlan_rx_add_vid;	netdev->vlan_rx_kill_vid = e1000_vlan_rx_kill_vid;#ifdef CONFIG_NET_POLL_CONTROLLER	netdev->poll_controller = e1000_netpoll;#endif	strcpy(netdev->name, pci_name(pdev));	netdev->mem_start = mmio_start;	netdev->mem_end = mmio_start + mmio_len;	netdev->base_addr = adapter->hw.io_base;	adapter->bd_number = cards_found;	/* setup the private structure */	if((err = e1000_sw_init(adapter)))		goto err_sw_init;	if(adapter->hw.mac_type >= e1000_82543) {		netdev->features = NETIF_F_SG |				   NETIF_F_HW_CSUM |				   NETIF_F_HW_VLAN_TX |				   NETIF_F_HW_VLAN_RX |				   NETIF_F_HW_VLAN_FILTER;	}#ifdef NETIF_F_TSO	if((adapter->hw.mac_type >= e1000_82544) &&	   (adapter->hw.mac_type != e1000_82547))		netdev->features |= NETIF_F_TSO;#endif	if(pci_using_dac)		netdev->features |= NETIF_F_HIGHDMA; 	/* hard_start_xmit is safe against parallel locking */ 	netdev->features |= NETIF_F_LLTX;  	/* before reading the EEPROM, reset the controller to 	 * put the device in a known good starting state */		e1000_reset_hw(&adapter->hw);	/* make sure the EEPROM is good */	if(e1000_validate_eeprom_checksum(&adapter->hw) < 0) {		DPRINTK(PROBE, ERR, "The EEPROM Checksum Is Not Valid\n");		err = -EIO;		goto err_eeprom;	}	/* copy the MAC address out of the EEPROM */	if (e1000_read_mac_addr(&adapter->hw))		DPRINTK(PROBE, ERR, "EEPROM Read Error\n");	memcpy(netdev->dev_addr, adapter->hw.mac_addr, netdev->addr_len);	if(!is_valid_ether_addr(netdev->dev_addr)) {		DPRINTK(PROBE, ERR, "Invalid MAC Address\n");		err = -EIO;		goto err_eeprom;	}	e1000_read_part_num(&adapter->hw, &(adapter->part_num));	e1000_get_bus_info(&adapter->hw);	init_timer(&adapter->tx_fifo_stall_timer);	adapter->tx_fifo_stall_timer.function = &e1000_82547_tx_fifo_stall;	adapter->tx_fifo_stall_timer.data = (unsigned long) adapter;	init_timer(&adapter->watchdog_timer);	adapter->watchdog_timer.function = &e1000_watchdog;	adapter->watchdog_timer.data = (unsigned long) adapter;	INIT_WORK(&adapter->watchdog_task,		(void (*)(void *))e1000_watchdog_task, adapter);	init_timer(&adapter->phy_info_timer);	adapter->phy_info_timer.function = &e1000_update_phy_info;	adapter->phy_info_timer.data = (unsigned long) adapter;	INIT_WORK(&adapter->tx_timeout_task,		(void (*)(void *))e1000_tx_timeout_task, netdev);	/* we're going to reset, so assume we have no link for now */	netif_carrier_off(netdev);	netif_stop_queue(netdev);	e1000_check_options(adapter);	/* Initial Wake on LAN setting	 * If APM wake is enabled in the EEPROM,	 * enable the ACPI Magic Packet filter	 */	switch(adapter->hw.mac_type) {	case e1000_82542_rev2_0:	case e1000_82542_rev2_1:	case e1000_82543:		break;	case e1000_82544:		e1000_read_eeprom(&adapter->hw,			EEPROM_INIT_CONTROL2_REG, 1, &eeprom_data);		eeprom_apme_mask = E1000_EEPROM_82544_APM;		break;	case e1000_82546:	case e1000_82546_rev_3:		if((E1000_READ_REG(&adapter->hw, STATUS) & E1000_STATUS_FUNC_1)		   && (adapter->hw.media_type == e1000_media_type_copper)) {			e1000_read_eeprom(&adapter->hw,				EEPROM_INIT_CONTROL3_PORT_B, 1, &eeprom_data);			break;		}		/* Fall Through */	default:		e1000_read_eeprom(&adapter->hw,			EEPROM_INIT_CONTROL3_PORT_A, 1, &eeprom_data);		break;	}	if(eeprom_data & eeprom_apme_mask)		adapter->wol |= E1000_WUFC_MAG;	/* reset the hardware with the new settings */	e1000_reset(adapter);	strcpy(netdev->name, "eth%d");	if((err = register_netdev(netdev)))		goto err_register;	DPRINTK(PROBE, INFO, "Intel(R) PRO/1000 Network Connection\n");	cards_found++;	return 0;err_register:err_sw_init:err_eeprom:	iounmap(adapter->hw.hw_addr);err_ioremap:	free_netdev(netdev);err_alloc_etherdev:	pci_release_regions(pdev);	return err;}
10457	/local/tlutelli/issta_data/temp/c/2005_temp/2005/10457/2d7edb923a823660b081bd4c660300ee19adca8d/e1000_main.c/clean/drivers/net/e1000/e1000_main.c