]> pilppa.org Git - linux-2.6-omap-h63xx.git/blobdiff - drivers/net/tc35815.c
tc35815: Use print_mac() helper
[linux-2.6-omap-h63xx.git] / drivers / net / tc35815.c
index 370d329d15d91cb1b56955afe8888e89d1c1234d..1f623e5af9484b3e6256d203a58827f9507a02c4 100644 (file)
@@ -418,7 +418,6 @@ struct tc35815_local {
        struct napi_struct napi;
 
        /* statistics */
-       struct net_device_stats stats;
        struct {
                int max_tx_qlen;
                int tx_ints;
@@ -665,6 +664,7 @@ static int __devinit tc35815_init_one (struct pci_dev *pdev,
        struct tc35815_local *lp;
        int rc;
        unsigned long mmio_start, mmio_end, mmio_flags, mmio_len;
+       DECLARE_MAC_BUF(mac);
 
        static int printed_version;
        if (!printed_version++) {
@@ -771,15 +771,11 @@ static int __devinit tc35815_init_one (struct pci_dev *pdev,
                goto err_out_unmap;
 
        memcpy(dev->perm_addr, dev->dev_addr, dev->addr_len);
-       printk(KERN_INFO "%s: %s at 0x%lx, "
-               "%2.2x:%2.2x:%2.2x:%2.2x:%2.2x:%2.2x, "
-               "IRQ %d\n",
+       printk(KERN_INFO "%s: %s at 0x%lx, %s, IRQ %d\n",
                dev->name,
                board_info[ent->driver_data].name,
                dev->base_addr,
-               dev->dev_addr[0], dev->dev_addr[1],
-               dev->dev_addr[2], dev->dev_addr[3],
-               dev->dev_addr[4], dev->dev_addr[5],
+               print_mac(mac, dev->dev_addr),
                dev->irq);
 
        setup_timer(&lp->timer, tc35815_timer, (unsigned long) dev);
@@ -1128,17 +1124,14 @@ panic_queues(struct net_device *dev)
 }
 #endif
 
-static void print_eth(char *add)
+static void print_eth(const u8 *add)
 {
-       int i;
+       DECLARE_MAC_BUF(mac);
 
-       printk("print_eth(%p)\n", add);
-       for (i = 0; i < 6; i++)
-               printk(" %2.2X", (unsigned char) add[i + 6]);
-       printk(" =>");
-       for (i = 0; i < 6; i++)
-               printk(" %2.2X", (unsigned char) add[i]);
-       printk(" : %2.2X%2.2X\n", (unsigned char) add[12], (unsigned char) add[13]);
+       printk(KERN_DEBUG "print_eth(%p)\n", add);
+       printk(KERN_DEBUG " %s =>", print_mac(mac, add + 6));
+       printk(KERN_CONT " %s : %02x%02x\n",
+               print_mac(mac, add), add[12], add[13]);
 }
 
 static int tc35815_tx_full(struct net_device *dev)
@@ -1192,7 +1185,7 @@ static void tc35815_tx_timeout(struct net_device *dev)
        tc35815_restart(dev);
        spin_unlock_irq(&lp->lock);
 
-       lp->stats.tx_errors++;
+       dev->stats.tx_errors++;
 
        /* If we have space available to accept new transmit
         * requests, wake up the queueing layer.  This would
@@ -1392,7 +1385,7 @@ static int tc35815_do_interrupt(struct net_device *dev, u32 status)
                printk(KERN_WARNING
                       "%s: Free Descriptor Area Exhausted (%#x).\n",
                       dev->name, status);
-               lp->stats.rx_dropped++;
+               dev->stats.rx_dropped++;
                ret = 0;
        }
        if (status & Int_IntBLEx) {
@@ -1401,14 +1394,14 @@ static int tc35815_do_interrupt(struct net_device *dev, u32 status)
                printk(KERN_WARNING
                       "%s: Buffer List Exhausted (%#x).\n",
                       dev->name, status);
-               lp->stats.rx_dropped++;
+               dev->stats.rx_dropped++;
                ret = 0;
        }
        if (status & Int_IntExBD) {
                printk(KERN_WARNING
                       "%s: Excessive Buffer Descriptiors (%#x).\n",
                       dev->name, status);
-               lp->stats.rx_length_errors++;
+               dev->stats.rx_length_errors++;
                ret = 0;
        }
 
@@ -1532,7 +1525,7 @@ tc35815_rx(struct net_device *dev)
                        if (skb == NULL) {
                                printk(KERN_NOTICE "%s: Memory squeeze, dropping packet.\n",
                                       dev->name);
-                               lp->stats.rx_dropped++;
+                               dev->stats.rx_dropped++;
                                break;
                        }
                        skb_reserve(skb, 2);   /* 16 bit alignment */
@@ -1602,10 +1595,10 @@ tc35815_rx(struct net_device *dev)
                        netif_rx(skb);
 #endif
                        dev->last_rx = jiffies;
-                       lp->stats.rx_packets++;
-                       lp->stats.rx_bytes += pkt_len;
+                       dev->stats.rx_packets++;
+                       dev->stats.rx_bytes += pkt_len;
                } else {
-                       lp->stats.rx_errors++;
+                       dev->stats.rx_errors++;
                        printk(KERN_DEBUG "%s: Rx error (status %x)\n",
                               dev->name, status & Rx_Stat_Mask);
                        /* WORKAROUND: LongErr and CRCErr means Overflow. */
@@ -1613,10 +1606,14 @@ tc35815_rx(struct net_device *dev)
                                status &= ~(Rx_LongErr|Rx_CRCErr);
                                status |= Rx_Over;
                        }
-                       if (status & Rx_LongErr) lp->stats.rx_length_errors++;
-                       if (status & Rx_Over) lp->stats.rx_fifo_errors++;
-                       if (status & Rx_CRCErr) lp->stats.rx_crc_errors++;
-                       if (status & Rx_Align) lp->stats.rx_frame_errors++;
+                       if (status & Rx_LongErr)
+                               dev->stats.rx_length_errors++;
+                       if (status & Rx_Over)
+                               dev->stats.rx_fifo_errors++;
+                       if (status & Rx_CRCErr)
+                               dev->stats.rx_crc_errors++;
+                       if (status & Rx_Align)
+                               dev->stats.rx_frame_errors++;
                }
 
                if (bd_count > 0) {
@@ -1777,9 +1774,9 @@ tc35815_check_tx_stat(struct net_device *dev, int status)
 
        /* count collisions */
        if (status & Tx_ExColl)
-               lp->stats.collisions += 16;
+               dev->stats.collisions += 16;
        if (status & Tx_TxColl_MASK)
-               lp->stats.collisions += status & Tx_TxColl_MASK;
+               dev->stats.collisions += status & Tx_TxColl_MASK;
 
 #ifndef NO_CHECK_CARRIER
        /* TX4939 does not have NCarr */
@@ -1795,17 +1792,17 @@ tc35815_check_tx_stat(struct net_device *dev, int status)
 
        if (!(status & TX_STA_ERR)) {
                /* no error. */
-               lp->stats.tx_packets++;
+               dev->stats.tx_packets++;
                return;
        }
 
-       lp->stats.tx_errors++;
+       dev->stats.tx_errors++;
        if (status & Tx_ExColl) {
-               lp->stats.tx_aborted_errors++;
+               dev->stats.tx_aborted_errors++;
                msg = "Excessive Collision.";
        }
        if (status & Tx_Under) {
-               lp->stats.tx_fifo_errors++;
+               dev->stats.tx_fifo_errors++;
                msg = "Tx FIFO Underrun.";
                if (lp->lstats.tx_underrun < TX_THRESHOLD_KEEP_LIMIT) {
                        lp->lstats.tx_underrun++;
@@ -1818,25 +1815,25 @@ tc35815_check_tx_stat(struct net_device *dev, int status)
                }
        }
        if (status & Tx_Defer) {
-               lp->stats.tx_fifo_errors++;
+               dev->stats.tx_fifo_errors++;
                msg = "Excessive Deferral.";
        }
 #ifndef NO_CHECK_CARRIER
        if (status & Tx_NCarr) {
-               lp->stats.tx_carrier_errors++;
+               dev->stats.tx_carrier_errors++;
                msg = "Lost Carrier Sense.";
        }
 #endif
        if (status & Tx_LateColl) {
-               lp->stats.tx_aborted_errors++;
+               dev->stats.tx_aborted_errors++;
                msg = "Late Collision.";
        }
        if (status & Tx_TxPar) {
-               lp->stats.tx_fifo_errors++;
+               dev->stats.tx_fifo_errors++;
                msg = "Transmit Parity Error.";
        }
        if (status & Tx_SQErr) {
-               lp->stats.tx_heartbeat_errors++;
+               dev->stats.tx_heartbeat_errors++;
                msg = "Signal Quality Error.";
        }
        if (msg && netif_msg_tx_err(lp))
@@ -1878,7 +1875,7 @@ tc35815_txdone(struct net_device *dev)
                BUG_ON(lp->tx_skbs[lp->tfd_end].skb != skb);
 #endif
                if (skb) {
-                       lp->stats.tx_bytes += skb->len;
+                       dev->stats.tx_bytes += skb->len;
                        pci_unmap_single(lp->pci_dev, lp->tx_skbs[lp->tfd_end].skb_dma, skb->len, PCI_DMA_TODEVICE);
                        lp->tx_skbs[lp->tfd_end].skb = NULL;
                        lp->tx_skbs[lp->tfd_end].skb_dma = 0;
@@ -1972,15 +1969,13 @@ tc35815_close(struct net_device *dev)
  */
 static struct net_device_stats *tc35815_get_stats(struct net_device *dev)
 {
-       struct tc35815_local *lp = dev->priv;
        struct tc35815_regs __iomem *tr =
                (struct tc35815_regs __iomem *)dev->base_addr;
-       if (netif_running(dev)) {
+       if (netif_running(dev))
                /* Update the statistics from the device registers. */
-               lp->stats.rx_missed_errors = tc_readl(&tr->Miss_Cnt);
-       }
+               dev->stats.rx_missed_errors = tc_readl(&tr->Miss_Cnt);
 
-       return &lp->stats;
+       return &dev->stats;
 }
 
 static void tc35815_set_cam_entry(struct net_device *dev, int index, unsigned char *addr)
@@ -1991,15 +1986,13 @@ static void tc35815_set_cam_entry(struct net_device *dev, int index, unsigned ch
        int cam_index = index * 6;
        u32 cam_data;
        u32 saved_addr;
+       DECLARE_MAC_BUF(mac);
+
        saved_addr = tc_readl(&tr->CAM_Adr);
 
-       if (netif_msg_hw(lp)) {
-               int i;
-               printk(KERN_DEBUG "%s: CAM %d:", dev->name, index);
-               for (i = 0; i < 6; i++)
-                       printk(" %02x", addr[i]);
-               printk("\n");
-       }
+       if (netif_msg_hw(lp))
+               printk(KERN_DEBUG "%s: CAM %d: %s\n",
+                       dev->name, index, print_mac(mac, addr));
        if (index & 1) {
                /* read modify write */
                tc_writel(cam_index - 2, &tr->CAM_Adr);