INIT_WORK(&rp->tx_timeout_task, (void (*)(void *))rhine_tx_timeout_task, dev);  INIT_WORK(&rp->check_media_task, (void (*)(void *))rhine_check_media_task, dev);  
static int __devinit rhine_init_one(struct pci_dev *pdev,				    const struct pci_device_id *ent){	struct net_device *dev;	struct rhine_private *rp;	int i, rc;	u8 pci_rev;	u32 quirks;	long pioaddr;	long memaddr;	void __iomem *ioaddr;	int io_size, phy_id;	const char *name;#ifdef USE_MMIO	int bar = 1;#else	int bar = 0;#endif/* when built into the kernel, we only print version if device is found */#ifndef MODULE	static int printed_version;	if (!printed_version++)		printk(version);#endif	pci_read_config_byte(pdev, PCI_REVISION_ID, &pci_rev);	io_size = 256;	phy_id = 0;	quirks = 0;	name = "Rhine";	if (pci_rev < VTunknown0) {		quirks = rqRhineI;		io_size = 128;	}	else if (pci_rev >= VT6102) {		quirks = rqWOL | rqForceReset;		if (pci_rev < VT6105) {			name = "Rhine II";			quirks |= rqStatusWBRace;	/* Rhine-II exclusive */		}		else {			phy_id = 1;	/* Integrated PHY, phy_id fixed to 1 */			if (pci_rev >= VT6105_B0)				quirks |= rq6patterns;			if (pci_rev < VT6105M)				name = "Rhine III";			else				name = "Rhine III (Management Adapter)";		}	}	rc = pci_enable_device(pdev);	if (rc)		goto err_out;	/* this should always be supported */	rc = pci_set_dma_mask(pdev, DMA_32BIT_MASK);	if (rc) {		printk(KERN_ERR "32-bit PCI DMA addresses not supported by "		       "the card!?\n");		goto err_out;	}	/* sanity check */	if ((pci_resource_len(pdev, 0) < io_size) ||	    (pci_resource_len(pdev, 1) < io_size)) {		rc = -EIO;		printk(KERN_ERR "Insufficient PCI resources, aborting\n");		goto err_out;	}	pioaddr = pci_resource_start(pdev, 0);	memaddr = pci_resource_start(pdev, 1);	pci_set_master(pdev);	dev = alloc_etherdev(sizeof(struct rhine_private));	if (!dev) {		rc = -ENOMEM;		printk(KERN_ERR "alloc_etherdev failed\n");		goto err_out;	}	SET_MODULE_OWNER(dev);	SET_NETDEV_DEV(dev, &pdev->dev);	rp = netdev_priv(dev);	rp->quirks = quirks;	rp->pioaddr = pioaddr;	rp->pdev = pdev;	rc = pci_request_regions(pdev, DRV_NAME);	if (rc)		goto err_out_free_netdev;	ioaddr = pci_iomap(pdev, bar, io_size);	if (!ioaddr) {		rc = -EIO;		printk(KERN_ERR "ioremap failed for device %s, region 0x%X "		       "@ 0x%lX\n", pci_name(pdev), io_size, memaddr);		goto err_out_free_res;	}#ifdef USE_MMIO	enable_mmio(pioaddr, quirks);	/* Check that selected MMIO registers match the PIO ones */	i = 0;	while (mmio_verify_registers[i]) {		int reg = mmio_verify_registers[i++];		unsigned char a = inb(pioaddr+reg);		unsigned char b = readb(ioaddr+reg);		if (a != b) {			rc = -EIO;			printk(KERN_ERR "MMIO do not match PIO [%02x] "			       "(%02x != %02x)\n", reg, a, b);			goto err_out_unmap;		}	}#endif /* USE_MMIO */	dev->base_addr = (unsigned long)ioaddr;	rp->base = ioaddr;	/* Get chip registers into a sane state */	rhine_power_init(dev);	rhine_hw_init(dev, pioaddr);	for (i = 0; i < 6; i++)		dev->dev_addr[i] = ioread8(ioaddr + StationAddr + i);	memcpy(dev->perm_addr, dev->dev_addr, dev->addr_len);	if (!is_valid_ether_addr(dev->perm_addr)) {		rc = -EIO;		printk(KERN_ERR "Invalid MAC address\n");		goto err_out_unmap;	}	/* For Rhine-I/II, phy_id is loaded from EEPROM */	if (!phy_id)		phy_id = ioread8(ioaddr + 0x6C);	dev->irq = pdev->irq;	spin_lock_init(&rp->lock);	rp->mii_if.dev = dev;	rp->mii_if.mdio_read = mdio_read;	rp->mii_if.mdio_write = mdio_write;	rp->mii_if.phy_id_mask = 0x1f;	rp->mii_if.reg_num_mask = 0x1f;	/* The chip-specific entries in the device structure. */	dev->open = rhine_open;	dev->hard_start_xmit = rhine_start_tx;	dev->stop = rhine_close;	dev->get_stats = rhine_get_stats;	dev->set_multicast_list = rhine_set_rx_mode;	dev->do_ioctl = netdev_ioctl;	dev->ethtool_ops = &netdev_ethtool_ops;	dev->tx_timeout = rhine_tx_timeout;	dev->watchdog_timeo = TX_TIMEOUT;#ifdef CONFIG_NET_POLL_CONTROLLER	dev->poll_controller = rhine_poll;#endif	if (rp->quirks & rqRhineI)		dev->features |= NETIF_F_SG|NETIF_F_HW_CSUM;	/* dev->name not defined before register_netdev()! */	rc = register_netdev(dev);	if (rc)		goto err_out_unmap;	printk(KERN_INFO "%s: VIA %s at 0x%lx, ",	       dev->name, name,#ifdef USE_MMIO		memaddr#else		(long)ioaddr#endif		 );	for (i = 0; i < 5; i++)		printk("%2.2x:", dev->dev_addr[i]);	printk("%2.2x, IRQ %d.\n", dev->dev_addr[i], pdev->irq);	pci_set_drvdata(pdev, dev);	{		u16 mii_cmd;		int mii_status = mdio_read(dev, phy_id, 1);		mii_cmd = mdio_read(dev, phy_id, MII_BMCR) & ~BMCR_ISOLATE;		mdio_write(dev, phy_id, MII_BMCR, mii_cmd);		if (mii_status != 0xffff && mii_status != 0x0000) {			rp->mii_if.advertising = mdio_read(dev, phy_id, 4);			printk(KERN_INFO "%s: MII PHY found at address "			       "%d, status 0x%4.4x advertising %4.4x "			       "Link %4.4x.\n", dev->name, phy_id,			       mii_status, rp->mii_if.advertising,			       mdio_read(dev, phy_id, 5));			/* set IFF_RUNNING */			if (mii_status & BMSR_LSTATUS)				netif_carrier_on(dev);			else				netif_carrier_off(dev);		}	}	rp->mii_if.phy_id = phy_id;	return 0;err_out_unmap:	pci_iounmap(pdev, ioaddr);err_out_free_res:	pci_release_regions(pdev);err_out_free_netdev:	free_netdev(dev);err_out:	return rc;}
10457	/local/tlutelli/issta_data/temp/c/2005_temp/2005/10457/6ba98d311d0a4ff7dc36d8f435ce60174f4c30ec/via-rhine.c/clean/drivers/net/via-rhine.c