diff options
author | Jamie Iles <jamie@jamieiles.com> | 2011-03-08 15:27:08 -0500 |
---|---|---|
committer | Jamie Iles <jamie@jamieiles.com> | 2011-11-22 10:21:17 -0500 |
commit | c220f8cd01198552a616c4216f2a8e719fdb5fd9 (patch) | |
tree | 09cf9a9d45418a949007f51005798019333a2e19 /drivers/net/ethernet/cadence/macb.c | |
parent | 84e0cdb0a262483a3618091c43dae33d36226430 (diff) |
macb: convert printk to netdev_ and friends
macb is already using the dev_dbg() and friends helpers so use netdev_()
along with a pr_fmt() definition to make the printing a little cleaner.
Acked-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com>
Signed-off-by: Jamie Iles <jamie@jamieiles.com>
Acked-by: David S. Miller <davem@davemloft.net>
Acked-by: Nicolas Ferre <nicolas.ferre@atmel.com>
Tested-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com>
Diffstat (limited to 'drivers/net/ethernet/cadence/macb.c')
-rw-r--r-- | drivers/net/ethernet/cadence/macb.c | 120 |
1 files changed, 56 insertions, 64 deletions
diff --git a/drivers/net/ethernet/cadence/macb.c b/drivers/net/ethernet/cadence/macb.c index d97d9ce986f8..aa1d597091a8 100644 --- a/drivers/net/ethernet/cadence/macb.c +++ b/drivers/net/ethernet/cadence/macb.c | |||
@@ -8,6 +8,7 @@ | |||
8 | * published by the Free Software Foundation. | 8 | * published by the Free Software Foundation. |
9 | */ | 9 | */ |
10 | 10 | ||
11 | #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt | ||
11 | #include <linux/clk.h> | 12 | #include <linux/clk.h> |
12 | #include <linux/module.h> | 13 | #include <linux/module.h> |
13 | #include <linux/moduleparam.h> | 14 | #include <linux/moduleparam.h> |
@@ -82,7 +83,7 @@ static void __init macb_get_hwaddr(struct macb *bp) | |||
82 | if (is_valid_ether_addr(addr)) { | 83 | if (is_valid_ether_addr(addr)) { |
83 | memcpy(bp->dev->dev_addr, addr, sizeof(addr)); | 84 | memcpy(bp->dev->dev_addr, addr, sizeof(addr)); |
84 | } else { | 85 | } else { |
85 | dev_info(&bp->pdev->dev, "invalid hw address, using random\n"); | 86 | netdev_info(bp->dev, "invalid hw address, using random\n"); |
86 | random_ether_addr(bp->dev->dev_addr); | 87 | random_ether_addr(bp->dev->dev_addr); |
87 | } | 88 | } |
88 | } | 89 | } |
@@ -176,11 +177,12 @@ static void macb_handle_link_change(struct net_device *dev) | |||
176 | 177 | ||
177 | if (status_change) { | 178 | if (status_change) { |
178 | if (phydev->link) | 179 | if (phydev->link) |
179 | printk(KERN_INFO "%s: link up (%d/%s)\n", | 180 | netdev_info(dev, "link up (%d/%s)\n", |
180 | dev->name, phydev->speed, | 181 | phydev->speed, |
181 | DUPLEX_FULL == phydev->duplex ? "Full":"Half"); | 182 | phydev->duplex == DUPLEX_FULL ? |
183 | "Full" : "Half"); | ||
182 | else | 184 | else |
183 | printk(KERN_INFO "%s: link down\n", dev->name); | 185 | netdev_info(dev, "link down\n"); |
184 | } | 186 | } |
185 | } | 187 | } |
186 | 188 | ||
@@ -194,7 +196,7 @@ static int macb_mii_probe(struct net_device *dev) | |||
194 | 196 | ||
195 | phydev = phy_find_first(bp->mii_bus); | 197 | phydev = phy_find_first(bp->mii_bus); |
196 | if (!phydev) { | 198 | if (!phydev) { |
197 | printk (KERN_ERR "%s: no PHY found\n", dev->name); | 199 | netdev_err(dev, "no PHY found\n"); |
198 | return -1; | 200 | return -1; |
199 | } | 201 | } |
200 | 202 | ||
@@ -207,7 +209,7 @@ static int macb_mii_probe(struct net_device *dev) | |||
207 | PHY_INTERFACE_MODE_RMII : | 209 | PHY_INTERFACE_MODE_RMII : |
208 | PHY_INTERFACE_MODE_MII); | 210 | PHY_INTERFACE_MODE_MII); |
209 | if (ret) { | 211 | if (ret) { |
210 | printk(KERN_ERR "%s: Could not attach to PHY\n", dev->name); | 212 | netdev_err(dev, "Could not attach to PHY\n"); |
211 | return ret; | 213 | return ret; |
212 | } | 214 | } |
213 | 215 | ||
@@ -301,14 +303,13 @@ static void macb_tx(struct macb *bp) | |||
301 | status = macb_readl(bp, TSR); | 303 | status = macb_readl(bp, TSR); |
302 | macb_writel(bp, TSR, status); | 304 | macb_writel(bp, TSR, status); |
303 | 305 | ||
304 | dev_dbg(&bp->pdev->dev, "macb_tx status = %02lx\n", | 306 | netdev_dbg(bp->dev, "macb_tx status = %02lx\n", (unsigned long)status); |
305 | (unsigned long)status); | ||
306 | 307 | ||
307 | if (status & (MACB_BIT(UND) | MACB_BIT(TSR_RLE))) { | 308 | if (status & (MACB_BIT(UND) | MACB_BIT(TSR_RLE))) { |
308 | int i; | 309 | int i; |
309 | printk(KERN_ERR "%s: TX %s, resetting buffers\n", | 310 | netdev_err(bp->dev, "TX %s, resetting buffers\n", |
310 | bp->dev->name, status & MACB_BIT(UND) ? | 311 | status & MACB_BIT(UND) ? |
311 | "underrun" : "retry limit exceeded"); | 312 | "underrun" : "retry limit exceeded"); |
312 | 313 | ||
313 | /* Transfer ongoing, disable transmitter, to avoid confusion */ | 314 | /* Transfer ongoing, disable transmitter, to avoid confusion */ |
314 | if (status & MACB_BIT(TGO)) | 315 | if (status & MACB_BIT(TGO)) |
@@ -367,8 +368,8 @@ static void macb_tx(struct macb *bp) | |||
367 | if (!(bufstat & MACB_BIT(TX_USED))) | 368 | if (!(bufstat & MACB_BIT(TX_USED))) |
368 | break; | 369 | break; |
369 | 370 | ||
370 | dev_dbg(&bp->pdev->dev, "skb %u (data %p) TX complete\n", | 371 | netdev_dbg(bp->dev, "skb %u (data %p) TX complete\n", |
371 | tail, skb->data); | 372 | tail, skb->data); |
372 | dma_unmap_single(&bp->pdev->dev, rp->mapping, skb->len, | 373 | dma_unmap_single(&bp->pdev->dev, rp->mapping, skb->len, |
373 | DMA_TO_DEVICE); | 374 | DMA_TO_DEVICE); |
374 | bp->stats.tx_packets++; | 375 | bp->stats.tx_packets++; |
@@ -393,8 +394,8 @@ static int macb_rx_frame(struct macb *bp, unsigned int first_frag, | |||
393 | 394 | ||
394 | len = MACB_BFEXT(RX_FRMLEN, bp->rx_ring[last_frag].ctrl); | 395 | len = MACB_BFEXT(RX_FRMLEN, bp->rx_ring[last_frag].ctrl); |
395 | 396 | ||
396 | dev_dbg(&bp->pdev->dev, "macb_rx_frame frags %u - %u (len %u)\n", | 397 | netdev_dbg(bp->dev, "macb_rx_frame frags %u - %u (len %u)\n", |
397 | first_frag, last_frag, len); | 398 | first_frag, last_frag, len); |
398 | 399 | ||
399 | skb = dev_alloc_skb(len + RX_OFFSET); | 400 | skb = dev_alloc_skb(len + RX_OFFSET); |
400 | if (!skb) { | 401 | if (!skb) { |
@@ -435,8 +436,8 @@ static int macb_rx_frame(struct macb *bp, unsigned int first_frag, | |||
435 | 436 | ||
436 | bp->stats.rx_packets++; | 437 | bp->stats.rx_packets++; |
437 | bp->stats.rx_bytes += len; | 438 | bp->stats.rx_bytes += len; |
438 | dev_dbg(&bp->pdev->dev, "received skb of length %u, csum: %08x\n", | 439 | netdev_dbg(bp->dev, "received skb of length %u, csum: %08x\n", |
439 | skb->len, skb->csum); | 440 | skb->len, skb->csum); |
440 | netif_receive_skb(skb); | 441 | netif_receive_skb(skb); |
441 | 442 | ||
442 | return 0; | 443 | return 0; |
@@ -513,8 +514,8 @@ static int macb_poll(struct napi_struct *napi, int budget) | |||
513 | 514 | ||
514 | work_done = 0; | 515 | work_done = 0; |
515 | 516 | ||
516 | dev_dbg(&bp->pdev->dev, "poll: status = %08lx, budget = %d\n", | 517 | netdev_dbg(bp->dev, "poll: status = %08lx, budget = %d\n", |
517 | (unsigned long)status, budget); | 518 | (unsigned long)status, budget); |
518 | 519 | ||
519 | work_done = macb_rx(bp, budget); | 520 | work_done = macb_rx(bp, budget); |
520 | if (work_done < budget) { | 521 | if (work_done < budget) { |
@@ -563,8 +564,7 @@ static irqreturn_t macb_interrupt(int irq, void *dev_id) | |||
563 | macb_writel(bp, IDR, MACB_RX_INT_FLAGS); | 564 | macb_writel(bp, IDR, MACB_RX_INT_FLAGS); |
564 | 565 | ||
565 | if (napi_schedule_prep(&bp->napi)) { | 566 | if (napi_schedule_prep(&bp->napi)) { |
566 | dev_dbg(&bp->pdev->dev, | 567 | netdev_dbg(bp->dev, "scheduling RX softirq\n"); |
567 | "scheduling RX softirq\n"); | ||
568 | __napi_schedule(&bp->napi); | 568 | __napi_schedule(&bp->napi); |
569 | } | 569 | } |
570 | } | 570 | } |
@@ -585,11 +585,11 @@ static irqreturn_t macb_interrupt(int irq, void *dev_id) | |||
585 | 585 | ||
586 | if (status & MACB_BIT(HRESP)) { | 586 | if (status & MACB_BIT(HRESP)) { |
587 | /* | 587 | /* |
588 | * TODO: Reset the hardware, and maybe move the printk | 588 | * TODO: Reset the hardware, and maybe move the |
589 | * to a lower-priority context as well (work queue?) | 589 | * netdev_err to a lower-priority context as well |
590 | * (work queue?) | ||
590 | */ | 591 | */ |
591 | printk(KERN_ERR "%s: DMA bus error: HRESP not OK\n", | 592 | netdev_err(dev, "DMA bus error: HRESP not OK\n"); |
592 | dev->name); | ||
593 | } | 593 | } |
594 | 594 | ||
595 | status = macb_readl(bp, ISR); | 595 | status = macb_readl(bp, ISR); |
@@ -624,16 +624,12 @@ static int macb_start_xmit(struct sk_buff *skb, struct net_device *dev) | |||
624 | unsigned long flags; | 624 | unsigned long flags; |
625 | 625 | ||
626 | #ifdef DEBUG | 626 | #ifdef DEBUG |
627 | int i; | 627 | netdev_dbg(bp->dev, |
628 | dev_dbg(&bp->pdev->dev, | 628 | "start_xmit: len %u head %p data %p tail %p end %p\n", |
629 | "start_xmit: len %u head %p data %p tail %p end %p\n", | 629 | skb->len, skb->head, skb->data, |
630 | skb->len, skb->head, skb->data, | 630 | skb_tail_pointer(skb), skb_end_pointer(skb)); |
631 | skb_tail_pointer(skb), skb_end_pointer(skb)); | 631 | print_hex_dump(KERN_DEBUG, "data: ", DUMP_PREFIX_OFFSET, 16, 1, |
632 | dev_dbg(&bp->pdev->dev, | 632 | skb->data, 16, true); |
633 | "data:"); | ||
634 | for (i = 0; i < 16; i++) | ||
635 | printk(" %02x", (unsigned int)skb->data[i]); | ||
636 | printk("\n"); | ||
637 | #endif | 633 | #endif |
638 | 634 | ||
639 | len = skb->len; | 635 | len = skb->len; |
@@ -643,21 +639,20 @@ static int macb_start_xmit(struct sk_buff *skb, struct net_device *dev) | |||
643 | if (TX_BUFFS_AVAIL(bp) < 1) { | 639 | if (TX_BUFFS_AVAIL(bp) < 1) { |
644 | netif_stop_queue(dev); | 640 | netif_stop_queue(dev); |
645 | spin_unlock_irqrestore(&bp->lock, flags); | 641 | spin_unlock_irqrestore(&bp->lock, flags); |
646 | dev_err(&bp->pdev->dev, | 642 | netdev_err(bp->dev, "BUG! Tx Ring full when queue awake!\n"); |
647 | "BUG! Tx Ring full when queue awake!\n"); | 643 | netdev_dbg(bp->dev, "tx_head = %u, tx_tail = %u\n", |
648 | dev_dbg(&bp->pdev->dev, "tx_head = %u, tx_tail = %u\n", | 644 | bp->tx_head, bp->tx_tail); |
649 | bp->tx_head, bp->tx_tail); | ||
650 | return NETDEV_TX_BUSY; | 645 | return NETDEV_TX_BUSY; |
651 | } | 646 | } |
652 | 647 | ||
653 | entry = bp->tx_head; | 648 | entry = bp->tx_head; |
654 | dev_dbg(&bp->pdev->dev, "Allocated ring entry %u\n", entry); | 649 | netdev_dbg(bp->dev, "Allocated ring entry %u\n", entry); |
655 | mapping = dma_map_single(&bp->pdev->dev, skb->data, | 650 | mapping = dma_map_single(&bp->pdev->dev, skb->data, |
656 | len, DMA_TO_DEVICE); | 651 | len, DMA_TO_DEVICE); |
657 | bp->tx_skb[entry].skb = skb; | 652 | bp->tx_skb[entry].skb = skb; |
658 | bp->tx_skb[entry].mapping = mapping; | 653 | bp->tx_skb[entry].mapping = mapping; |
659 | dev_dbg(&bp->pdev->dev, "Mapped skb data %p to DMA addr %08lx\n", | 654 | netdev_dbg(bp->dev, "Mapped skb data %p to DMA addr %08lx\n", |
660 | skb->data, (unsigned long)mapping); | 655 | skb->data, (unsigned long)mapping); |
661 | 656 | ||
662 | ctrl = MACB_BF(TX_FRMLEN, len); | 657 | ctrl = MACB_BF(TX_FRMLEN, len); |
663 | ctrl |= MACB_BIT(TX_LAST); | 658 | ctrl |= MACB_BIT(TX_LAST); |
@@ -721,27 +716,27 @@ static int macb_alloc_consistent(struct macb *bp) | |||
721 | &bp->rx_ring_dma, GFP_KERNEL); | 716 | &bp->rx_ring_dma, GFP_KERNEL); |
722 | if (!bp->rx_ring) | 717 | if (!bp->rx_ring) |
723 | goto out_err; | 718 | goto out_err; |
724 | dev_dbg(&bp->pdev->dev, | 719 | netdev_dbg(bp->dev, |
725 | "Allocated RX ring of %d bytes at %08lx (mapped %p)\n", | 720 | "Allocated RX ring of %d bytes at %08lx (mapped %p)\n", |
726 | size, (unsigned long)bp->rx_ring_dma, bp->rx_ring); | 721 | size, (unsigned long)bp->rx_ring_dma, bp->rx_ring); |
727 | 722 | ||
728 | size = TX_RING_BYTES; | 723 | size = TX_RING_BYTES; |
729 | bp->tx_ring = dma_alloc_coherent(&bp->pdev->dev, size, | 724 | bp->tx_ring = dma_alloc_coherent(&bp->pdev->dev, size, |
730 | &bp->tx_ring_dma, GFP_KERNEL); | 725 | &bp->tx_ring_dma, GFP_KERNEL); |
731 | if (!bp->tx_ring) | 726 | if (!bp->tx_ring) |
732 | goto out_err; | 727 | goto out_err; |
733 | dev_dbg(&bp->pdev->dev, | 728 | netdev_dbg(bp->dev, |
734 | "Allocated TX ring of %d bytes at %08lx (mapped %p)\n", | 729 | "Allocated TX ring of %d bytes at %08lx (mapped %p)\n", |
735 | size, (unsigned long)bp->tx_ring_dma, bp->tx_ring); | 730 | size, (unsigned long)bp->tx_ring_dma, bp->tx_ring); |
736 | 731 | ||
737 | size = RX_RING_SIZE * RX_BUFFER_SIZE; | 732 | size = RX_RING_SIZE * RX_BUFFER_SIZE; |
738 | bp->rx_buffers = dma_alloc_coherent(&bp->pdev->dev, size, | 733 | bp->rx_buffers = dma_alloc_coherent(&bp->pdev->dev, size, |
739 | &bp->rx_buffers_dma, GFP_KERNEL); | 734 | &bp->rx_buffers_dma, GFP_KERNEL); |
740 | if (!bp->rx_buffers) | 735 | if (!bp->rx_buffers) |
741 | goto out_err; | 736 | goto out_err; |
742 | dev_dbg(&bp->pdev->dev, | 737 | netdev_dbg(bp->dev, |
743 | "Allocated RX buffers of %d bytes at %08lx (mapped %p)\n", | 738 | "Allocated RX buffers of %d bytes at %08lx (mapped %p)\n", |
744 | size, (unsigned long)bp->rx_buffers_dma, bp->rx_buffers); | 739 | size, (unsigned long)bp->rx_buffers_dma, bp->rx_buffers); |
745 | 740 | ||
746 | return 0; | 741 | return 0; |
747 | 742 | ||
@@ -952,7 +947,7 @@ static int macb_open(struct net_device *dev) | |||
952 | struct macb *bp = netdev_priv(dev); | 947 | struct macb *bp = netdev_priv(dev); |
953 | int err; | 948 | int err; |
954 | 949 | ||
955 | dev_dbg(&bp->pdev->dev, "open\n"); | 950 | netdev_dbg(bp->dev, "open\n"); |
956 | 951 | ||
957 | /* if the phy is not yet register, retry later*/ | 952 | /* if the phy is not yet register, retry later*/ |
958 | if (!bp->phy_dev) | 953 | if (!bp->phy_dev) |
@@ -963,9 +958,8 @@ static int macb_open(struct net_device *dev) | |||
963 | 958 | ||
964 | err = macb_alloc_consistent(bp); | 959 | err = macb_alloc_consistent(bp); |
965 | if (err) { | 960 | if (err) { |
966 | printk(KERN_ERR | 961 | netdev_err(dev, "Unable to allocate DMA memory (error %d)\n", |
967 | "%s: Unable to allocate DMA memory (error %d)\n", | 962 | err); |
968 | dev->name, err); | ||
969 | return err; | 963 | return err; |
970 | } | 964 | } |
971 | 965 | ||
@@ -1174,9 +1168,8 @@ static int __init macb_probe(struct platform_device *pdev) | |||
1174 | dev->irq = platform_get_irq(pdev, 0); | 1168 | dev->irq = platform_get_irq(pdev, 0); |
1175 | err = request_irq(dev->irq, macb_interrupt, 0, dev->name, dev); | 1169 | err = request_irq(dev->irq, macb_interrupt, 0, dev->name, dev); |
1176 | if (err) { | 1170 | if (err) { |
1177 | printk(KERN_ERR | 1171 | dev_err(&pdev->dev, "Unable to request IRQ %d (error %d)\n", |
1178 | "%s: Unable to request IRQ %d (error %d)\n", | 1172 | dev->irq, err); |
1179 | dev->name, dev->irq, err); | ||
1180 | goto err_out_iounmap; | 1173 | goto err_out_iounmap; |
1181 | } | 1174 | } |
1182 | 1175 | ||
@@ -1228,13 +1221,12 @@ static int __init macb_probe(struct platform_device *pdev) | |||
1228 | 1221 | ||
1229 | platform_set_drvdata(pdev, dev); | 1222 | platform_set_drvdata(pdev, dev); |
1230 | 1223 | ||
1231 | printk(KERN_INFO "%s: Atmel MACB at 0x%08lx irq %d (%pM)\n", | 1224 | netdev_info(dev, "Atmel MACB at 0x%08lx irq %d (%pM)\n", |
1232 | dev->name, dev->base_addr, dev->irq, dev->dev_addr); | 1225 | dev->base_addr, dev->irq, dev->dev_addr); |
1233 | 1226 | ||
1234 | phydev = bp->phy_dev; | 1227 | phydev = bp->phy_dev; |
1235 | printk(KERN_INFO "%s: attached PHY driver [%s] " | 1228 | netdev_info(dev, "attached PHY driver [%s] (mii_bus:phy_addr=%s, irq=%d)\n", |
1236 | "(mii_bus:phy_addr=%s, irq=%d)\n", dev->name, | 1229 | phydev->drv->name, dev_name(&phydev->dev), phydev->irq); |
1237 | phydev->drv->name, dev_name(&phydev->dev), phydev->irq); | ||
1238 | 1230 | ||
1239 | return 0; | 1231 | return 0; |
1240 | 1232 | ||