Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 5368c726 authored by Florian Fainelli's avatar Florian Fainelli Committed by David S. Miller
Browse files

au1000-eth: Use (dev|netdev|netif)_<level> macro helpers

parent 7cd2e6e3
Loading
Loading
Loading
Loading
+48 −68
Original line number Original line Diff line number Diff line
@@ -187,8 +187,7 @@ static int au1000_mdio_read(struct net_device *dev, int phy_addr, int reg)
	while (*mii_control_reg & MAC_MII_BUSY) {
	while (*mii_control_reg & MAC_MII_BUSY) {
		mdelay(1);
		mdelay(1);
		if (--timedout == 0) {
		if (--timedout == 0) {
			printk(KERN_ERR "%s: read_MII busy timeout!!\n",
			netdev_err(dev, "read_MII busy timeout!!\n");
					dev->name);
			return -1;
			return -1;
		}
		}
	}
	}
@@ -202,8 +201,7 @@ static int au1000_mdio_read(struct net_device *dev, int phy_addr, int reg)
	while (*mii_control_reg & MAC_MII_BUSY) {
	while (*mii_control_reg & MAC_MII_BUSY) {
		mdelay(1);
		mdelay(1);
		if (--timedout == 0) {
		if (--timedout == 0) {
			printk(KERN_ERR "%s: mdio_read busy timeout!!\n",
			netdev_err(dev, "mdio_read busy timeout!!\n");
					dev->name);
			return -1;
			return -1;
		}
		}
	}
	}
@@ -222,8 +220,7 @@ static void au1000_mdio_write(struct net_device *dev, int phy_addr,
	while (*mii_control_reg & MAC_MII_BUSY) {
	while (*mii_control_reg & MAC_MII_BUSY) {
		mdelay(1);
		mdelay(1);
		if (--timedout == 0) {
		if (--timedout == 0) {
			printk(KERN_ERR "%s: mdio_write busy timeout!!\n",
			netdev_err(dev, "mdio_write busy timeout!!\n");
					dev->name);
			return;
			return;
		}
		}
	}
	}
@@ -270,8 +267,7 @@ static void au1000_hard_stop(struct net_device *dev)
{
{
	struct au1000_private *aup = netdev_priv(dev);
	struct au1000_private *aup = netdev_priv(dev);


	if (au1000_debug > 4)
	netif_dbg(aup, drv, dev, "hard stop\n");
		printk(KERN_INFO "%s: hard stop\n", dev->name);


	aup->mac->control &= ~(MAC_RX_ENABLE | MAC_TX_ENABLE);
	aup->mac->control &= ~(MAC_RX_ENABLE | MAC_TX_ENABLE);
	au_sync_delay(10);
	au_sync_delay(10);
@@ -281,8 +277,7 @@ static void au1000_enable_rx_tx(struct net_device *dev)
{
{
	struct au1000_private *aup = netdev_priv(dev);
	struct au1000_private *aup = netdev_priv(dev);


	if (au1000_debug > 4)
	netif_dbg(aup, hw, dev, "enable_rx_tx\n");
		printk(KERN_INFO "%s: enable_rx_tx\n", dev->name);


	aup->mac->control |= (MAC_RX_ENABLE | MAC_TX_ENABLE);
	aup->mac->control |= (MAC_RX_ENABLE | MAC_TX_ENABLE);
	au_sync_delay(10);
	au_sync_delay(10);
@@ -309,9 +304,8 @@ au1000_adjust_link(struct net_device *dev)
		case SPEED_100:
		case SPEED_100:
			break;
			break;
		default:
		default:
			printk(KERN_WARNING
			netdev_warn(dev, "Speed (%d) is not 10/100 ???\n",
			       "%s: Speed (%d) is not 10/100 ???\n",
							phydev->speed);
			       dev->name, phydev->speed);
			break;
			break;
		}
		}


@@ -359,11 +353,11 @@ au1000_adjust_link(struct net_device *dev)


	if (status_change) {
	if (status_change) {
		if (phydev->link)
		if (phydev->link)
			printk(KERN_INFO "%s: link up (%d/%s)\n",
			netdev_info(dev, "link up (%d/%s)\n",
			       dev->name, phydev->speed,
			       phydev->speed,
			       DUPLEX_FULL == phydev->duplex ? "Full" : "Half");
			       DUPLEX_FULL == phydev->duplex ? "Full" : "Half");
		else
		else
			printk(KERN_INFO "%s: link down\n", dev->name);
			netdev_info(dev, "link down\n");
	}
	}
}
}


@@ -378,8 +372,7 @@ static int au1000_mii_probe (struct net_device *dev)
		if (aup->phy_addr)
		if (aup->phy_addr)
			phydev = aup->mii_bus->phy_map[aup->phy_addr];
			phydev = aup->mii_bus->phy_map[aup->phy_addr];
		else
		else
			printk (KERN_INFO DRV_NAME ":%s: using PHY-less setup\n",
			netdev_info(dev, "using PHY-less setup\n");
				dev->name);
		return 0;
		return 0;
	} else {
	} else {
		int phy_addr;
		int phy_addr;
@@ -396,7 +389,7 @@ static int au1000_mii_probe (struct net_device *dev)
			/* try harder to find a PHY */
			/* try harder to find a PHY */
			if (!phydev && (aup->mac_id == 1)) {
			if (!phydev && (aup->mac_id == 1)) {
				/* no PHY found, maybe we have a dual PHY? */
				/* no PHY found, maybe we have a dual PHY? */
				printk (KERN_INFO DRV_NAME ": no PHY found on MAC1, "
				dev_info(&dev->dev, ": no PHY found on MAC1, "
					"let's see if it's attached to MAC0...\n");
					"let's see if it's attached to MAC0...\n");


				/* find the first (lowest address) non-attached PHY on
				/* find the first (lowest address) non-attached PHY on
@@ -422,7 +415,7 @@ static int au1000_mii_probe (struct net_device *dev)
	}
	}


	if (!phydev) {
	if (!phydev) {
		printk (KERN_ERR DRV_NAME ":%s: no PHY found\n", dev->name);
		netdev_err(dev, "no PHY found\n");
		return -1;
		return -1;
	}
	}


@@ -433,7 +426,7 @@ static int au1000_mii_probe (struct net_device *dev)
			0, PHY_INTERFACE_MODE_MII);
			0, PHY_INTERFACE_MODE_MII);


	if (IS_ERR(phydev)) {
	if (IS_ERR(phydev)) {
		printk(KERN_ERR "%s: Could not attach to PHY\n", dev->name);
		netdev_err(dev, "Could not attach to PHY\n");
		return PTR_ERR(phydev);
		return PTR_ERR(phydev);
	}
	}


@@ -454,8 +447,8 @@ static int au1000_mii_probe (struct net_device *dev)
	aup->old_duplex = -1;
	aup->old_duplex = -1;
	aup->phy_dev = phydev;
	aup->phy_dev = phydev;


	printk(KERN_INFO "%s: attached PHY driver [%s] "
	netdev_info(dev, "attached PHY driver [%s] "
	       "(mii_bus:phy_addr=%s, irq=%d)\n", dev->name,
	       "(mii_bus:phy_addr=%s, irq=%d)\n",
	       phydev->drv->name, dev_name(&phydev->dev), phydev->irq);
	       phydev->drv->name, dev_name(&phydev->dev), phydev->irq);


	return 0;
	return 0;
@@ -517,9 +510,8 @@ static void au1000_reset_mac(struct net_device *dev)
	struct au1000_private *const aup = netdev_priv(dev);
	struct au1000_private *const aup = netdev_priv(dev);
	unsigned long flags;
	unsigned long flags;


	if (au1000_debug > 4)
	netif_dbg(aup, hw, dev, "reset mac, aup %x\n",
		printk(KERN_INFO "%s: reset mac, aup %x\n",
					(unsigned)aup);
		       dev->name, (unsigned)aup);


	spin_lock_irqsave(&aup->lock, flags);
	spin_lock_irqsave(&aup->lock, flags);


@@ -625,8 +617,7 @@ static int au1000_init(struct net_device *dev)
	int i;
	int i;
	u32 control;
	u32 control;


	if (au1000_debug > 4)
	netif_dbg(aup, hw, dev, "au1000_init\n");
		printk("%s: au1000_init\n", dev->name);


	/* bring the device out of reset */
	/* bring the device out of reset */
	au1000_enable_mac(dev, 1);
	au1000_enable_mac(dev, 1);
@@ -703,8 +694,7 @@ static int au1000_rx(struct net_device *dev)
	db_dest_t *pDB;
	db_dest_t *pDB;
	u32	frmlen;
	u32	frmlen;


	if (au1000_debug > 5)
	netif_dbg(aup, rx_status, dev, "au1000_rx head %d\n", aup->rx_head);
		printk("%s: au1000_rx head %d\n", dev->name, aup->rx_head);


	prxd = aup->rx_dma_ring[aup->rx_head];
	prxd = aup->rx_dma_ring[aup->rx_head];
	buff_stat = prxd->buff_stat;
	buff_stat = prxd->buff_stat;
@@ -719,9 +709,7 @@ static int au1000_rx(struct net_device *dev)
			frmlen -= 4; /* Remove FCS */
			frmlen -= 4; /* Remove FCS */
			skb = dev_alloc_skb(frmlen + 2);
			skb = dev_alloc_skb(frmlen + 2);
			if (skb == NULL) {
			if (skb == NULL) {
				printk(KERN_ERR
				netdev_err(dev, "Memory squeeze, dropping packet.\n");
				       "%s: Memory squeeze, dropping packet.\n",
				       dev->name);
				dev->stats.rx_dropped++;
				dev->stats.rx_dropped++;
				continue;
				continue;
			}
			}
@@ -833,20 +821,18 @@ static int au1000_open(struct net_device *dev)
	int retval;
	int retval;
	struct au1000_private *aup = netdev_priv(dev);
	struct au1000_private *aup = netdev_priv(dev);


	if (au1000_debug > 4)
	netif_dbg(aup, drv, dev, "open: dev=%p\n", dev);
		printk("%s: open: dev=%p\n", dev->name, dev);


	retval = request_irq(dev->irq, au1000_interrupt, 0,
	retval = request_irq(dev->irq, au1000_interrupt, 0,
					dev->name, dev);
					dev->name, dev);
	if (retval) {
	if (retval) {
		printk(KERN_ERR "%s: unable to get IRQ %d\n",
		netdev_err(dev, "unable to get IRQ %d\n", dev->irq);
				dev->name, dev->irq);
		return retval;
		return retval;
	}
	}


	retval = au1000_init(dev);
	retval = au1000_init(dev);
	if (retval) {
	if (retval) {
		printk(KERN_ERR "%s: error in au1000_init\n", dev->name);
		netdev_err(dev, "error in au1000_init\n");
		free_irq(dev->irq, dev);
		free_irq(dev->irq, dev);
		return retval;
		return retval;
	}
	}
@@ -859,8 +845,7 @@ static int au1000_open(struct net_device *dev)


	netif_start_queue(dev);
	netif_start_queue(dev);


	if (au1000_debug > 4)
	netif_dbg(aup, drv, dev, "open: Initialization done.\n");
		printk("%s: open: Initialization done.\n", dev->name);


	return 0;
	return 0;
}
}
@@ -870,8 +855,7 @@ static int au1000_close(struct net_device *dev)
	unsigned long flags;
	unsigned long flags;
	struct au1000_private *const aup = netdev_priv(dev);
	struct au1000_private *const aup = netdev_priv(dev);


	if (au1000_debug > 4)
	netif_dbg(aup, drv, dev, "close: dev=%p\n", dev);
		printk("%s: close: dev=%p\n", dev->name, dev);


	if (aup->phy_dev)
	if (aup->phy_dev)
		phy_stop(aup->phy_dev);
		phy_stop(aup->phy_dev);
@@ -902,9 +886,8 @@ static netdev_tx_t au1000_tx(struct sk_buff *skb, struct net_device *dev)
	db_dest_t *pDB;
	db_dest_t *pDB;
	int i;
	int i;


	if (au1000_debug > 5)
	netif_dbg(aup, tx_queued, dev, "tx: aup %x len=%d, data=%p, head %d\n",
		printk("%s: tx: aup %x len=%d, data=%p, head %d\n",
				(unsigned)aup, skb->len,
				dev->name, (unsigned)aup, skb->len,
				skb->data, aup->tx_head);
				skb->data, aup->tx_head);


	ptxd = aup->tx_dma_ring[aup->tx_head];
	ptxd = aup->tx_dma_ring[aup->tx_head];
@@ -951,7 +934,7 @@ static netdev_tx_t au1000_tx(struct sk_buff *skb, struct net_device *dev)
 */
 */
static void au1000_tx_timeout(struct net_device *dev)
static void au1000_tx_timeout(struct net_device *dev)
{
{
	printk(KERN_ERR "%s: au1000_tx_timeout: dev=%p\n", dev->name, dev);
	netdev_err(dev, "au1000_tx_timeout: dev=%p\n", dev);
	au1000_reset_mac(dev);
	au1000_reset_mac(dev);
	au1000_init(dev);
	au1000_init(dev);
	dev->trans_start = jiffies;
	dev->trans_start = jiffies;
@@ -962,8 +945,7 @@ static void au1000_multicast_list(struct net_device *dev)
{
{
	struct au1000_private *aup = netdev_priv(dev);
	struct au1000_private *aup = netdev_priv(dev);


	if (au1000_debug > 4)
	netif_dbg(aup, drv, dev, "au1000_multicast_list: flags=%x\n", dev->flags);
		printk("%s: au1000_multicast_list: flags=%x\n", dev->name, dev->flags);


	if (dev->flags & IFF_PROMISC) {			/* Set promiscuous. */
	if (dev->flags & IFF_PROMISC) {			/* Set promiscuous. */
		aup->mac->control |= MAC_PROMISCUOUS;
		aup->mac->control |= MAC_PROMISCUOUS;
@@ -971,7 +953,7 @@ static void au1000_multicast_list(struct net_device *dev)
			   netdev_mc_count(dev) > MULTICAST_FILTER_LIMIT) {
			   netdev_mc_count(dev) > MULTICAST_FILTER_LIMIT) {
		aup->mac->control |= MAC_PASS_ALL_MULTI;
		aup->mac->control |= MAC_PASS_ALL_MULTI;
		aup->mac->control &= ~MAC_PROMISCUOUS;
		aup->mac->control &= ~MAC_PROMISCUOUS;
		printk(KERN_INFO "%s: Pass all multicast\n", dev->name);
		netdev_info(dev, "Pass all multicast\n");
	} else {
	} else {
		struct netdev_hw_addr *ha;
		struct netdev_hw_addr *ha;
		u32 mc_filter[2];	/* Multicast hash filter */
		u32 mc_filter[2];	/* Multicast hash filter */
@@ -1025,40 +1007,40 @@ static int __devinit au1000_probe(struct platform_device *pdev)


	base = platform_get_resource(pdev, IORESOURCE_MEM, 0);
	base = platform_get_resource(pdev, IORESOURCE_MEM, 0);
	if (!base) {
	if (!base) {
		printk(KERN_ERR DRV_NAME ": failed to retrieve base register\n");
		dev_err(&pdev->dev, "failed to retrieve base register\n");
		err = -ENODEV;
		err = -ENODEV;
		goto out;
		goto out;
	}
	}


	macen = platform_get_resource(pdev, IORESOURCE_MEM, 1);
	macen = platform_get_resource(pdev, IORESOURCE_MEM, 1);
	if (!macen) {
	if (!macen) {
		printk(KERN_ERR DRV_NAME ": failed to retrieve MAC Enable register\n");
		dev_err(&pdev->dev, "failed to retrieve MAC Enable register\n");
		err = -ENODEV;
		err = -ENODEV;
		goto out;
		goto out;
	}
	}


	irq = platform_get_irq(pdev, 0);
	irq = platform_get_irq(pdev, 0);
	if (irq < 0) {
	if (irq < 0) {
		printk(KERN_ERR DRV_NAME ": failed to retrieve IRQ\n");
		dev_err(&pdev->dev, "failed to retrieve IRQ\n");
		err = -ENODEV;
		err = -ENODEV;
		goto out;
		goto out;
	}
	}


	if (!request_mem_region(base->start, resource_size(base), pdev->name)) {
	if (!request_mem_region(base->start, resource_size(base), pdev->name)) {
		printk(KERN_ERR DRV_NAME ": failed to request memory region for base registers\n");
		dev_err(&pdev->dev, "failed to request memory region for base registers\n");
		err = -ENXIO;
		err = -ENXIO;
		goto out;
		goto out;
	}
	}


	if (!request_mem_region(macen->start, resource_size(macen), pdev->name)) {
	if (!request_mem_region(macen->start, resource_size(macen), pdev->name)) {
		printk(KERN_ERR DRV_NAME ": failed to request memory region for MAC enable register\n");
		dev_err(&pdev->dev, "failed to request memory region for MAC enable register\n");
		err = -ENXIO;
		err = -ENXIO;
		goto err_request;
		goto err_request;
	}
	}


	dev = alloc_etherdev(sizeof(struct au1000_private));
	dev = alloc_etherdev(sizeof(struct au1000_private));
	if (!dev) {
	if (!dev) {
		printk(KERN_ERR "%s: alloc_etherdev failed\n", DRV_NAME);
		dev_err(&pdev->dev, "alloc_etherdev failed\n");
		err = -ENOMEM;
		err = -ENOMEM;
		goto err_alloc;
		goto err_alloc;
	}
	}
@@ -1076,7 +1058,7 @@ static int __devinit au1000_probe(struct platform_device *pdev)
						(NUM_TX_BUFFS + NUM_RX_BUFFS),
						(NUM_TX_BUFFS + NUM_RX_BUFFS),
						&aup->dma_addr,	0);
						&aup->dma_addr,	0);
	if (!aup->vaddr) {
	if (!aup->vaddr) {
		printk(KERN_ERR DRV_NAME ": failed to allocate data buffers\n");
		dev_err(&pdev->dev, "failed to allocate data buffers\n");
		err = -ENOMEM;
		err = -ENOMEM;
		goto err_vaddr;
		goto err_vaddr;
	}
	}
@@ -1084,7 +1066,7 @@ static int __devinit au1000_probe(struct platform_device *pdev)
	/* aup->mac is the base address of the MAC's registers */
	/* aup->mac is the base address of the MAC's registers */
	aup->mac = (volatile mac_reg_t *)ioremap_nocache(base->start, resource_size(base));
	aup->mac = (volatile mac_reg_t *)ioremap_nocache(base->start, resource_size(base));
	if (!aup->mac) {
	if (!aup->mac) {
		printk(KERN_ERR DRV_NAME ": failed to ioremap MAC registers\n");
		dev_err(&pdev->dev, "failed to ioremap MAC registers\n");
		err = -ENXIO;
		err = -ENXIO;
		goto err_remap1;
		goto err_remap1;
	}
	}
@@ -1092,7 +1074,7 @@ static int __devinit au1000_probe(struct platform_device *pdev)
        /* Setup some variables for quick register address access */
        /* Setup some variables for quick register address access */
	aup->enable = (volatile u32 *)ioremap_nocache(macen->start, resource_size(macen));
	aup->enable = (volatile u32 *)ioremap_nocache(macen->start, resource_size(macen));
	if (!aup->enable) {
	if (!aup->enable) {
		printk(KERN_ERR DRV_NAME ": failed to ioremap MAC enable register\n");
		dev_err(&pdev->dev, "failed to ioremap MAC enable register\n");
		err = -ENXIO;
		err = -ENXIO;
		goto err_remap2;
		goto err_remap2;
	}
	}
@@ -1102,8 +1084,7 @@ static int __devinit au1000_probe(struct platform_device *pdev)
		if (prom_get_ethernet_addr(ethaddr) == 0)
		if (prom_get_ethernet_addr(ethaddr) == 0)
			memcpy(au1000_mac_addr, ethaddr, sizeof(au1000_mac_addr));
			memcpy(au1000_mac_addr, ethaddr, sizeof(au1000_mac_addr));
		else {
		else {
			printk(KERN_INFO "%s: No MAC address found\n",
			netdev_info(dev, "No MAC address found\n");
					 dev->name);
				/* Use the hard coded MAC addresses */
				/* Use the hard coded MAC addresses */
		}
		}


@@ -1123,7 +1104,7 @@ static int __devinit au1000_probe(struct platform_device *pdev)


	pd = pdev->dev.platform_data;
	pd = pdev->dev.platform_data;
	if (!pd) {
	if (!pd) {
		printk(KERN_INFO DRV_NAME ": no platform_data passed, PHY search on MAC0\n");
		dev_info(&pdev->dev, "no platform_data passed, PHY search on MAC0\n");
		aup->phy1_search_mac0 = 1;
		aup->phy1_search_mac0 = 1;
	} else {
	} else {
		aup->phy_static_config = pd->phy_static_config;
		aup->phy_static_config = pd->phy_static_config;
@@ -1135,7 +1116,7 @@ static int __devinit au1000_probe(struct platform_device *pdev)
	}
	}


	if (aup->phy_busid && aup->phy_busid > 0) {
	if (aup->phy_busid && aup->phy_busid > 0) {
		printk(KERN_ERR DRV_NAME ": MAC0-associated PHY attached 2nd MACs MII"
		dev_err(&pdev->dev, "MAC0-associated PHY attached 2nd MACs MII"
				"bus not supported yet\n");
				"bus not supported yet\n");
		err = -ENODEV;
		err = -ENODEV;
		goto err_mdiobus_alloc;
		goto err_mdiobus_alloc;
@@ -1143,7 +1124,7 @@ static int __devinit au1000_probe(struct platform_device *pdev)


	aup->mii_bus = mdiobus_alloc();
	aup->mii_bus = mdiobus_alloc();
	if (aup->mii_bus == NULL) {
	if (aup->mii_bus == NULL) {
		printk(KERN_ERR DRV_NAME ": failed to allocate mdiobus structure\n");
		dev_err(&pdev->dev, "failed to allocate mdiobus structure\n");
		err = -ENOMEM;
		err = -ENOMEM;
		goto err_mdiobus_alloc;
		goto err_mdiobus_alloc;
	}
	}
@@ -1167,7 +1148,7 @@ static int __devinit au1000_probe(struct platform_device *pdev)


	err = mdiobus_register(aup->mii_bus);
	err = mdiobus_register(aup->mii_bus);
	if (err) {
	if (err) {
		printk(KERN_ERR DRV_NAME " failed to register MDIO bus\n");
		dev_err(&pdev->dev, "failed to register MDIO bus\n");
		goto err_mdiobus_reg;
		goto err_mdiobus_reg;
	}
	}


@@ -1218,13 +1199,12 @@ static int __devinit au1000_probe(struct platform_device *pdev)


	err = register_netdev(dev);
	err = register_netdev(dev);
	if (err) {
	if (err) {
		printk(KERN_ERR DRV_NAME "%s: Cannot register net device, aborting.\n",
		netdev_err(dev, "Cannot register net device, aborting.\n");
					dev->name);
		goto err_out;
		goto err_out;
	}
	}


	printk("%s: Au1xx0 Ethernet found at 0x%lx, irq %d\n",
	netdev_info(dev, "Au1xx0 Ethernet found at 0x%lx, irq %d\n",
			dev->name, (unsigned long)base->start, irq);
			(unsigned long)base->start, irq);
	if (version_printed++ == 0)
	if (version_printed++ == 0)
		printk("%s version %s %s\n", DRV_NAME, DRV_VERSION, DRV_AUTHOR);
		printk("%s version %s %s\n", DRV_NAME, DRV_VERSION, DRV_AUTHOR);