]> pilppa.org Git - linux-2.6-omap-h63xx.git/blobdiff - drivers/net/gianfar.c
[PATCH] Remove more unnecessary driver printk's
[linux-2.6-omap-h63xx.git] / drivers / net / gianfar.c
index 146f9513aea57f89e04cea2b5f201730590dfc1d..5130da094305ed4e4a51ad41ce0efdd55c9268c0 100644 (file)
@@ -64,7 +64,6 @@
  *  The driver then cleans up the buffer.
  */
 
-#include <linux/config.h>
 #include <linux/kernel.h>
 #include <linux/sched.h>
 #include <linux/string.h>
@@ -84,6 +83,7 @@
 #include <linux/ip.h>
 #include <linux/tcp.h>
 #include <linux/udp.h>
+#include <linux/in.h>
 
 #include <asm/io.h>
 #include <asm/irq.h>
@@ -192,21 +192,25 @@ static int gfar_probe(struct platform_device *pdev)
                priv->interruptTransmit = platform_get_irq_byname(pdev, "tx");
                priv->interruptReceive = platform_get_irq_byname(pdev, "rx");
                priv->interruptError = platform_get_irq_byname(pdev, "error");
+               if (priv->interruptTransmit < 0 || priv->interruptReceive < 0 || priv->interruptError < 0)
+                       goto regs_fail;
        } else {
                priv->interruptTransmit = platform_get_irq(pdev, 0);
+               if (priv->interruptTransmit < 0)
+                       goto regs_fail;
        }
 
        /* get a pointer to the register memory */
        r = platform_get_resource(pdev, IORESOURCE_MEM, 0);
-       priv->regs = (struct gfar *)
-               ioremap(r->start, sizeof (struct gfar));
+       priv->regs = ioremap(r->start, sizeof (struct gfar));
 
        if (NULL == priv->regs) {
                err = -ENOMEM;
                goto regs_fail;
        }
 
-       spin_lock_init(&priv->lock);
+       spin_lock_init(&priv->txlock);
+       spin_lock_init(&priv->rxlock);
 
        platform_set_drvdata(pdev, dev);
 
@@ -368,7 +372,7 @@ static int gfar_probe(struct platform_device *pdev)
        return 0;
 
 register_fail:
-       iounmap((void *) priv->regs);
+       iounmap(priv->regs);
 regs_fail:
        free_netdev(dev);
        return err;
@@ -381,7 +385,7 @@ static int gfar_remove(struct platform_device *pdev)
 
        platform_set_drvdata(pdev, NULL);
 
-       iounmap((void *) priv->regs);
+       iounmap(priv->regs);
        free_netdev(dev);
 
        return 0;
@@ -398,12 +402,15 @@ static int init_phy(struct net_device *dev)
                priv->einfo->device_flags & FSL_GIANFAR_DEV_HAS_GIGABIT ?
                SUPPORTED_1000baseT_Full : 0;
        struct phy_device *phydev;
+       char phy_id[BUS_ID_SIZE];
 
        priv->oldlink = 0;
        priv->oldspeed = 0;
        priv->oldduplex = -1;
 
-       phydev = phy_connect(dev, priv->einfo->bus_id, &adjust_link, 0);
+       snprintf(phy_id, BUS_ID_SIZE, PHY_ID_FMT, priv->einfo->bus_id, priv->einfo->phy_id);
+
+       phydev = phy_connect(dev, phy_id, &adjust_link, 0);
 
        if (IS_ERR(phydev)) {
                printk(KERN_ERR "%s: Could not attach to PHY\n", dev->name);
@@ -450,8 +457,7 @@ static void init_registers(struct net_device *dev)
 
        /* Zero out the rmon mib registers if it has them */
        if (priv->einfo->device_flags & FSL_GIANFAR_DEV_HAS_RMON) {
-               memset((void *) &(priv->regs->rmon), 0,
-                      sizeof (struct rmon_mib));
+               memset_io(&(priv->regs->rmon), 0, sizeof (struct rmon_mib));
 
                /* Mask off the CAM interrupts */
                gfar_write(&priv->regs->rmon.cam1, 0xffffffff);
@@ -473,7 +479,7 @@ static void init_registers(struct net_device *dev)
 void gfar_halt(struct net_device *dev)
 {
        struct gfar_private *priv = netdev_priv(dev);
-       struct gfar *regs = priv->regs;
+       struct gfar __iomem *regs = priv->regs;
        u32 tempval;
 
        /* Mask all interrupts */
@@ -503,17 +509,19 @@ void gfar_halt(struct net_device *dev)
 void stop_gfar(struct net_device *dev)
 {
        struct gfar_private *priv = netdev_priv(dev);
-       struct gfar *regs = priv->regs;
+       struct gfar __iomem *regs = priv->regs;
        unsigned long flags;
 
        phy_stop(priv->phydev);
 
        /* Lock it down */
-       spin_lock_irqsave(&priv->lock, flags);
+       spin_lock_irqsave(&priv->txlock, flags);
+       spin_lock(&priv->rxlock);
 
        gfar_halt(dev);
 
-       spin_unlock_irqrestore(&priv->lock, flags);
+       spin_unlock(&priv->rxlock);
+       spin_unlock_irqrestore(&priv->txlock, flags);
 
        /* Free the IRQs */
        if (priv->einfo->device_flags & FSL_GIANFAR_DEV_HAS_MULTI_INTR) {
@@ -586,7 +594,7 @@ static void free_skb_resources(struct gfar_private *priv)
 void gfar_start(struct net_device *dev)
 {
        struct gfar_private *priv = netdev_priv(dev);
-       struct gfar *regs = priv->regs;
+       struct gfar __iomem *regs = priv->regs;
        u32 tempval;
 
        /* Enable Rx and Tx in MACCFG1 */
@@ -599,14 +607,15 @@ void gfar_start(struct net_device *dev)
        tempval |= DMACTRL_INIT_SETTINGS;
        gfar_write(&priv->regs->dmactrl, tempval);
 
-       /* Clear THLT, so that the DMA starts polling now */
-       gfar_write(&regs->tstat, TSTAT_CLEAR_THALT);
-
        /* Make sure we aren't stopped */
        tempval = gfar_read(&priv->regs->dmactrl);
        tempval &= ~(DMACTRL_GRS | DMACTRL_GTS);
        gfar_write(&priv->regs->dmactrl, tempval);
 
+       /* Clear THLT/RHLT, so that the DMA starts polling now */
+       gfar_write(&regs->tstat, TSTAT_CLEAR_THALT);
+       gfar_write(&regs->rstat, RSTAT_CLEAR_RHALT);
+
        /* Unmask the interrupts we look for */
        gfar_write(&regs->imask, IMASK_DEFAULT);
 }
@@ -620,7 +629,7 @@ int startup_gfar(struct net_device *dev)
        unsigned long vaddr;
        int i;
        struct gfar_private *priv = netdev_priv(dev);
-       struct gfar *regs = priv->regs;
+       struct gfar __iomem *regs = priv->regs;
        int err = 0;
        u32 rctrl = 0;
        u32 attrs = 0;
@@ -922,12 +931,13 @@ static int gfar_start_xmit(struct sk_buff *skb, struct net_device *dev)
        struct txfcb *fcb = NULL;
        struct txbd8 *txbdp;
        u16 status;
+       unsigned long flags;
 
        /* Update transmit stats */
        priv->stats.tx_bytes += skb->len;
 
        /* Lock priv now */
-       spin_lock_irq(&priv->lock);
+       spin_lock_irqsave(&priv->txlock, flags);
 
        /* Point at the first free tx descriptor */
        txbdp = priv->cur_tx;
@@ -998,7 +1008,7 @@ static int gfar_start_xmit(struct sk_buff *skb, struct net_device *dev)
        gfar_write(&priv->regs->tstat, TSTAT_CLEAR_THALT);
 
        /* Unlock priv */
-       spin_unlock_irq(&priv->lock);
+       spin_unlock_irqrestore(&priv->txlock, flags);
 
        return 0;
 }
@@ -1043,7 +1053,7 @@ static void gfar_vlan_rx_register(struct net_device *dev,
        unsigned long flags;
        u32 tempval;
 
-       spin_lock_irqsave(&priv->lock, flags);
+       spin_lock_irqsave(&priv->rxlock, flags);
 
        priv->vlgrp = grp;
 
@@ -1070,7 +1080,7 @@ static void gfar_vlan_rx_register(struct net_device *dev,
                gfar_write(&priv->regs->rctrl, tempval);
        }
 
-       spin_unlock_irqrestore(&priv->lock, flags);
+       spin_unlock_irqrestore(&priv->rxlock, flags);
 }
 
 
@@ -1079,12 +1089,12 @@ static void gfar_vlan_rx_kill_vid(struct net_device *dev, uint16_t vid)
        struct gfar_private *priv = netdev_priv(dev);
        unsigned long flags;
 
-       spin_lock_irqsave(&priv->lock, flags);
+       spin_lock_irqsave(&priv->rxlock, flags);
 
        if (priv->vlgrp)
                priv->vlgrp->vlan_devices[vid] = NULL;
 
-       spin_unlock_irqrestore(&priv->lock, flags);
+       spin_unlock_irqrestore(&priv->rxlock, flags);
 }
 
 
@@ -1173,7 +1183,7 @@ static irqreturn_t gfar_transmit(int irq, void *dev_id, struct pt_regs *regs)
        gfar_write(&priv->regs->ievent, IEVENT_TX_MASK);
 
        /* Lock priv */
-       spin_lock(&priv->lock);
+       spin_lock(&priv->txlock);
        bdp = priv->dirty_tx;
        while ((bdp->status & TXBD_READY) == 0) {
                /* If dirty_tx and cur_tx are the same, then either the */
@@ -1218,7 +1228,7 @@ static irqreturn_t gfar_transmit(int irq, void *dev_id, struct pt_regs *regs)
        else
                gfar_write(&priv->regs->txic, 0);
 
-       spin_unlock(&priv->lock);
+       spin_unlock(&priv->txlock);
 
        return IRQ_HANDLED;
 }
@@ -1299,9 +1309,10 @@ irqreturn_t gfar_receive(int irq, void *dev_id, struct pt_regs *regs)
 {
        struct net_device *dev = (struct net_device *) dev_id;
        struct gfar_private *priv = netdev_priv(dev);
-
 #ifdef CONFIG_GFAR_NAPI
        u32 tempval;
+#else
+       unsigned long flags;
 #endif
 
        /* Clear IEVENT, so rx interrupt isn't called again
@@ -1324,7 +1335,7 @@ irqreturn_t gfar_receive(int irq, void *dev_id, struct pt_regs *regs)
        }
 #else
 
-       spin_lock(&priv->lock);
+       spin_lock_irqsave(&priv->rxlock, flags);
        gfar_clean_rx_ring(dev, priv->rx_ring_size);
 
        /* If we are coalescing interrupts, update the timer */
@@ -1335,7 +1346,7 @@ irqreturn_t gfar_receive(int irq, void *dev_id, struct pt_regs *regs)
        else
                gfar_write(&priv->regs->rxic, 0);
 
-       spin_unlock(&priv->lock);
+       spin_unlock_irqrestore(&priv->rxlock, flags);
 #endif
 
        return IRQ_HANDLED;
@@ -1484,13 +1495,6 @@ int gfar_clean_rx_ring(struct net_device *dev, int rx_work_limit)
        /* Update the current rxbd pointer to be the next one */
        priv->cur_rx = bdp;
 
-       /* If no packets have arrived since the
-        * last one we processed, clear the IEVENT RX and
-        * BSY bits so that another interrupt won't be
-        * generated when we set IMASK */
-       if (bdp->status & RXBD_EMPTY)
-               gfar_write(&priv->regs->ievent, IEVENT_RX_MASK);
-
        return howmany;
 }
 
@@ -1510,7 +1514,7 @@ static int gfar_poll(struct net_device *dev, int *budget)
        rx_work_limit -= howmany;
        *budget -= howmany;
 
-       if (rx_work_limit >= 0) {
+       if (rx_work_limit > 0) {
                netif_rx_complete(dev);
 
                /* Clear the halt bit in RSTAT */
@@ -1527,7 +1531,8 @@ static int gfar_poll(struct net_device *dev, int *budget)
                        gfar_write(&priv->regs->rxic, 0);
        }
 
-       return (rx_work_limit < 0) ? 1 : 0;
+       /* Return 1 if there's more work to do */
+       return (rx_work_limit > 0) ? 0 : 1;
 }
 #endif
 
@@ -1618,12 +1623,12 @@ static irqreturn_t gfar_interrupt(int irq, void *dev_id, struct pt_regs *regs)
 static void adjust_link(struct net_device *dev)
 {
        struct gfar_private *priv = netdev_priv(dev);
-       struct gfar *regs = priv->regs;
+       struct gfar __iomem *regs = priv->regs;
        unsigned long flags;
        struct phy_device *phydev = priv->phydev;
        int new_state = 0;
 
-       spin_lock_irqsave(&priv->lock, flags);
+       spin_lock_irqsave(&priv->txlock, flags);
        if (phydev->link) {
                u32 tempval = gfar_read(&regs->maccfg2);
                u32 ecntrl = gfar_read(&regs->ecntrl);
@@ -1688,7 +1693,7 @@ static void adjust_link(struct net_device *dev)
        if (new_state && netif_msg_link(priv))
                phy_print_status(phydev);
 
-       spin_unlock_irqrestore(&priv->lock, flags);
+       spin_unlock_irqrestore(&priv->txlock, flags);
 }
 
 /* Update the hash table based on the current list of multicast
@@ -1699,13 +1704,10 @@ static void gfar_set_multi(struct net_device *dev)
 {
        struct dev_mc_list *mc_ptr;
        struct gfar_private *priv = netdev_priv(dev);
-       struct gfar *regs = priv->regs;
+       struct gfar __iomem *regs = priv->regs;
        u32 tempval;
 
        if(dev->flags & IFF_PROMISC) {
-               if (netif_msg_drv(priv))
-                       printk(KERN_INFO "%s: Entering promiscuous mode.\n",
-                                       dev->name);
                /* Set RCTRL to PROM */
                tempval = gfar_read(&regs->rctrl);
                tempval |= RCTRL_PROM;
@@ -1838,7 +1840,7 @@ static void gfar_set_mac_for_addr(struct net_device *dev, int num, u8 *addr)
        int idx;
        char tmpbuf[MAC_ADDR_LEN];
        u32 tempval;
-       u32 *macptr = &priv->regs->macstnaddr1;
+       u32 __iomem *macptr = &priv->regs->macstnaddr1;
 
        macptr += num*2;