if (1) { int phy, phy_idx = 0; np->phys[0] = 1;		/* Default setting */ np->mii_preamble_required++; for (phy = 1; phy < 32 && phy_idx < MII_CNT; phy++) { int mii_status = mdio_read(dev, phy, MII_BMSR); if (mii_status != 0xffff  &&  mii_status != 0x0000) { np->phys[phy_idx++] = phy; np->mii_if.advertising = mdio_read(dev, phy, MII_ADVERTISE); if ((mii_status & 0x0040) == 0) np->mii_preamble_required++; printk(KERN_INFO "%s: MII PHY found at address %d, status " "0x%4.4x advertising %4.4x.\n", dev->name, phy, mii_status, np->mii_if.advertising); } 
np->phys[0] = 1;		/* Default setting */ np->mii_preamble_required++; for (phy = 1; phy < 32 && phy_idx < MII_CNT; phy++) { int mii_status = mdio_read(dev, phy, MII_BMSR); if (mii_status != 0xffff  &&  mii_status != 0x0000) { np->phys[phy_idx++] = phy; np->mii_if.advertising = mdio_read(dev, phy, MII_ADVERTISE); if ((mii_status & 0x0040) == 0) np->mii_preamble_required++; printk(KERN_INFO "%s: MII PHY found at address %d, status " "0x%4.4x advertising %4.4x.\n", dev->name, phy, mii_status, np->mii_if.advertising); 
static int __devinit sundance_probe1 (struct pci_dev *pdev,				      const struct pci_device_id *ent){	struct net_device *dev;	struct netdev_private *np;	static int card_idx;	int chip_idx = ent->driver_data;	int irq;	int i;	void __iomem *ioaddr;	u16 mii_ctl;	void *ring_space;	dma_addr_t ring_dma;#ifdef USE_IO_OPS	int bar = 0;#else	int bar = 1;#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	if (pci_enable_device(pdev))		return -EIO;	pci_set_master(pdev);	irq = pdev->irq;	dev = alloc_etherdev(sizeof(*np));	if (!dev)		return -ENOMEM;	SET_MODULE_OWNER(dev);	SET_NETDEV_DEV(dev, &pdev->dev);	if (pci_request_regions(pdev, DRV_NAME))		goto err_out_netdev;	ioaddr = pci_iomap(pdev, bar, netdev_io_size);	if (!ioaddr)		goto err_out_res;	for (i = 0; i < 3; i++)		((u16 *)dev->dev_addr)[i] =			le16_to_cpu(eeprom_read(ioaddr, i + EEPROM_SA_OFFSET));	memcpy(dev->perm_addr, dev->dev_addr, dev->addr_len);	dev->base_addr = (unsigned long)ioaddr;	dev->irq = irq;	np = netdev_priv(dev);	np->base = ioaddr;	np->pci_dev = pdev;	np->chip_id = chip_idx;	np->msg_enable = (1 << debug) - 1;	spin_lock_init(&np->lock);	tasklet_init(&np->rx_tasklet, rx_poll, (unsigned long)dev);	tasklet_init(&np->tx_tasklet, tx_poll, (unsigned long)dev);	ring_space = pci_alloc_consistent(pdev, TX_TOTAL_SIZE, &ring_dma);	if (!ring_space)		goto err_out_cleardev;	np->tx_ring = (struct netdev_desc *)ring_space;	np->tx_ring_dma = ring_dma;	ring_space = pci_alloc_consistent(pdev, RX_TOTAL_SIZE, &ring_dma);	if (!ring_space)		goto err_out_unmap_tx;	np->rx_ring = (struct netdev_desc *)ring_space;	np->rx_ring_dma = ring_dma;	np->mii_if.dev = dev;	np->mii_if.mdio_read = mdio_read;	np->mii_if.mdio_write = mdio_write;	np->mii_if.phy_id_mask = 0x1f;	np->mii_if.reg_num_mask = 0x1f;	/* The chip-specific entries in the device structure. */	dev->open = &netdev_open;	dev->hard_start_xmit = &start_tx;	dev->stop = &netdev_close;	dev->get_stats = &get_stats;	dev->set_multicast_list = &set_rx_mode;	dev->do_ioctl = &netdev_ioctl;	SET_ETHTOOL_OPS(dev, &ethtool_ops);	dev->tx_timeout = &tx_timeout;	dev->watchdog_timeo = TX_TIMEOUT;	dev->change_mtu = &change_mtu;	pci_set_drvdata(pdev, dev);	pci_read_config_byte(pdev, PCI_REVISION_ID, &np->pci_rev_id);	i = register_netdev(dev);	if (i)		goto err_out_unmap_rx;	printk(KERN_INFO "%s: %s at %p, ",		   dev->name, pci_id_tbl[chip_idx].name, ioaddr);	for (i = 0; i < 5; i++)			printk("%2.2x:", dev->dev_addr[i]);	printk("%2.2x, IRQ %d.\n", dev->dev_addr[i], irq);	if (1) {		int phy, phy_idx = 0;		np->phys[0] = 1;		/* Default setting */		np->mii_preamble_required++;		for (phy = 1; phy < 32 && phy_idx < MII_CNT; phy++) {			int mii_status = mdio_read(dev, phy, MII_BMSR);			if (mii_status != 0xffff  &&  mii_status != 0x0000) {				np->phys[phy_idx++] = phy;				np->mii_if.advertising = mdio_read(dev, phy, MII_ADVERTISE);				if ((mii_status & 0x0040) == 0)					np->mii_preamble_required++;				printk(KERN_INFO "%s: MII PHY found at address %d, status "					   "0x%4.4x advertising %4.4x.\n",					   dev->name, phy, mii_status, np->mii_if.advertising);			}		}		np->mii_preamble_required--;		if (phy_idx == 0) {			printk(KERN_INFO "%s: No MII transceiver found, aborting.  ASIC status %x\n",				   dev->name, ioread32(ioaddr + ASICCtrl));			goto err_out_unregister;		}		np->mii_if.phy_id = np->phys[0];	}	/* Parse override configuration */	np->an_enable = 1;	if (card_idx < MAX_UNITS) {		if (media[card_idx] != NULL) {			np->an_enable = 0;			if (strcmp (media[card_idx], "100mbps_fd") == 0 ||			    strcmp (media[card_idx], "4") == 0) {				np->speed = 100;				np->mii_if.full_duplex = 1;			} else if (strcmp (media[card_idx], "100mbps_hd") == 0				   || strcmp (media[card_idx], "3") == 0) {				np->speed = 100;				np->mii_if.full_duplex = 0;			} else if (strcmp (media[card_idx], "10mbps_fd") == 0 ||				   strcmp (media[card_idx], "2") == 0) {				np->speed = 10;				np->mii_if.full_duplex = 1;			} else if (strcmp (media[card_idx], "10mbps_hd") == 0 ||				   strcmp (media[card_idx], "1") == 0) {				np->speed = 10;				np->mii_if.full_duplex = 0;			} else {				np->an_enable = 1;			}		}		if (flowctrl == 1)			np->flowctrl = 1;	}	/* Fibre PHY? */	if (ioread32 (ioaddr + ASICCtrl) & 0x80) {		/* Default 100Mbps Full */		if (np->an_enable) {			np->speed = 100;			np->mii_if.full_duplex = 1;			np->an_enable = 0;		}	}	/* Reset PHY */	mdio_write (dev, np->phys[0], MII_BMCR, BMCR_RESET);	mdelay (300);	/* If flow control enabled, we need to advertise it.*/	if (np->flowctrl)		mdio_write (dev, np->phys[0], MII_ADVERTISE, np->mii_if.advertising | 0x0400);	mdio_write (dev, np->phys[0], MII_BMCR, BMCR_ANENABLE|BMCR_ANRESTART);	/* Force media type */	if (!np->an_enable) {		mii_ctl = 0;		mii_ctl |= (np->speed == 100) ? BMCR_SPEED100 : 0;		mii_ctl |= (np->mii_if.full_duplex) ? BMCR_FULLDPLX : 0;		mdio_write (dev, np->phys[0], MII_BMCR, mii_ctl);		printk (KERN_INFO "Override speed=%d, %s duplex\n",			np->speed, np->mii_if.full_duplex ? "Full" : "Half");	}	/* Perhaps move the reset here? */	/* Reset the chip to erase previous misconfiguration. */	if (netif_msg_hw(np))		printk("ASIC Control is %x.\n", ioread32(ioaddr + ASICCtrl));	iowrite16(0x007f, ioaddr + ASICCtrl + 2);	if (netif_msg_hw(np))		printk("ASIC Control is now %x.\n", ioread32(ioaddr + ASICCtrl));	card_idx++;	return 0;err_out_unregister:	unregister_netdev(dev);err_out_unmap_rx:        pci_free_consistent(pdev, RX_TOTAL_SIZE, np->rx_ring, np->rx_ring_dma);err_out_unmap_tx:        pci_free_consistent(pdev, TX_TOTAL_SIZE, np->tx_ring, np->tx_ring_dma);err_out_cleardev:	pci_set_drvdata(pdev, NULL);	pci_iounmap(pdev, ioaddr);err_out_res:	pci_release_regions(pdev);err_out_netdev:	free_netdev (dev);	return -ENODEV;}
4520	/local/tlutelli/issta_data/temp/c/2005_temp/2005/4520/67ec2f805a5260c041b1c3c7a86ecfbc9670db06/sundance.c/clean/drivers/net/sundance.c