提交 c220f8cd 编写于 作者: J Jamie Iles

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: NJean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com>
Signed-off-by: NJamie Iles <jamie@jamieiles.com>
Acked-by: NDavid S. Miller <davem@davemloft.net>
Acked-by: NNicolas Ferre <nicolas.ferre@atmel.com>
Tested-by: NJean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com>
上级 84e0cdb0
...@@ -8,6 +8,7 @@ ...@@ -8,6 +8,7 @@
* published by the Free Software Foundation. * published by the Free Software Foundation.
*/ */
#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
#include <linux/clk.h> #include <linux/clk.h>
#include <linux/module.h> #include <linux/module.h>
#include <linux/moduleparam.h> #include <linux/moduleparam.h>
...@@ -82,7 +83,7 @@ static void __init macb_get_hwaddr(struct macb *bp) ...@@ -82,7 +83,7 @@ static void __init macb_get_hwaddr(struct macb *bp)
if (is_valid_ether_addr(addr)) { if (is_valid_ether_addr(addr)) {
memcpy(bp->dev->dev_addr, addr, sizeof(addr)); memcpy(bp->dev->dev_addr, addr, sizeof(addr));
} else { } else {
dev_info(&bp->pdev->dev, "invalid hw address, using random\n"); netdev_info(bp->dev, "invalid hw address, using random\n");
random_ether_addr(bp->dev->dev_addr); random_ether_addr(bp->dev->dev_addr);
} }
} }
...@@ -176,11 +177,12 @@ static void macb_handle_link_change(struct net_device *dev) ...@@ -176,11 +177,12 @@ static void macb_handle_link_change(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"); phydev->duplex == DUPLEX_FULL ?
"Full" : "Half");
else else
printk(KERN_INFO "%s: link down\n", dev->name); netdev_info(dev, "link down\n");
} }
} }
...@@ -194,7 +196,7 @@ static int macb_mii_probe(struct net_device *dev) ...@@ -194,7 +196,7 @@ static int macb_mii_probe(struct net_device *dev)
phydev = phy_find_first(bp->mii_bus); phydev = phy_find_first(bp->mii_bus);
if (!phydev) { if (!phydev) {
printk (KERN_ERR "%s: no PHY found\n", dev->name); netdev_err(dev, "no PHY found\n");
return -1; return -1;
} }
...@@ -207,7 +209,7 @@ static int macb_mii_probe(struct net_device *dev) ...@@ -207,7 +209,7 @@ static int macb_mii_probe(struct net_device *dev)
PHY_INTERFACE_MODE_RMII : PHY_INTERFACE_MODE_RMII :
PHY_INTERFACE_MODE_MII); PHY_INTERFACE_MODE_MII);
if (ret) { if (ret) {
printk(KERN_ERR "%s: Could not attach to PHY\n", dev->name); netdev_err(dev, "Could not attach to PHY\n");
return ret; return ret;
} }
...@@ -301,14 +303,13 @@ static void macb_tx(struct macb *bp) ...@@ -301,14 +303,13 @@ static void macb_tx(struct macb *bp)
status = macb_readl(bp, TSR); status = macb_readl(bp, TSR);
macb_writel(bp, TSR, status); macb_writel(bp, TSR, status);
dev_dbg(&bp->pdev->dev, "macb_tx status = %02lx\n", netdev_dbg(bp->dev, "macb_tx status = %02lx\n", (unsigned long)status);
(unsigned long)status);
if (status & (MACB_BIT(UND) | MACB_BIT(TSR_RLE))) { if (status & (MACB_BIT(UND) | MACB_BIT(TSR_RLE))) {
int i; int i;
printk(KERN_ERR "%s: TX %s, resetting buffers\n", netdev_err(bp->dev, "TX %s, resetting buffers\n",
bp->dev->name, status & MACB_BIT(UND) ? status & MACB_BIT(UND) ?
"underrun" : "retry limit exceeded"); "underrun" : "retry limit exceeded");
/* Transfer ongoing, disable transmitter, to avoid confusion */ /* Transfer ongoing, disable transmitter, to avoid confusion */
if (status & MACB_BIT(TGO)) if (status & MACB_BIT(TGO))
...@@ -367,8 +368,8 @@ static void macb_tx(struct macb *bp) ...@@ -367,8 +368,8 @@ static void macb_tx(struct macb *bp)
if (!(bufstat & MACB_BIT(TX_USED))) if (!(bufstat & MACB_BIT(TX_USED)))
break; break;
dev_dbg(&bp->pdev->dev, "skb %u (data %p) TX complete\n", netdev_dbg(bp->dev, "skb %u (data %p) TX complete\n",
tail, skb->data); tail, skb->data);
dma_unmap_single(&bp->pdev->dev, rp->mapping, skb->len, dma_unmap_single(&bp->pdev->dev, rp->mapping, skb->len,
DMA_TO_DEVICE); DMA_TO_DEVICE);
bp->stats.tx_packets++; bp->stats.tx_packets++;
...@@ -393,8 +394,8 @@ static int macb_rx_frame(struct macb *bp, unsigned int first_frag, ...@@ -393,8 +394,8 @@ static int macb_rx_frame(struct macb *bp, unsigned int first_frag,
len = MACB_BFEXT(RX_FRMLEN, bp->rx_ring[last_frag].ctrl); len = MACB_BFEXT(RX_FRMLEN, bp->rx_ring[last_frag].ctrl);
dev_dbg(&bp->pdev->dev, "macb_rx_frame frags %u - %u (len %u)\n", netdev_dbg(bp->dev, "macb_rx_frame frags %u - %u (len %u)\n",
first_frag, last_frag, len); first_frag, last_frag, len);
skb = dev_alloc_skb(len + RX_OFFSET); skb = dev_alloc_skb(len + RX_OFFSET);
if (!skb) { if (!skb) {
...@@ -435,8 +436,8 @@ static int macb_rx_frame(struct macb *bp, unsigned int first_frag, ...@@ -435,8 +436,8 @@ static int macb_rx_frame(struct macb *bp, unsigned int first_frag,
bp->stats.rx_packets++; bp->stats.rx_packets++;
bp->stats.rx_bytes += len; bp->stats.rx_bytes += len;
dev_dbg(&bp->pdev->dev, "received skb of length %u, csum: %08x\n", netdev_dbg(bp->dev, "received skb of length %u, csum: %08x\n",
skb->len, skb->csum); skb->len, skb->csum);
netif_receive_skb(skb); netif_receive_skb(skb);
return 0; return 0;
...@@ -513,8 +514,8 @@ static int macb_poll(struct napi_struct *napi, int budget) ...@@ -513,8 +514,8 @@ static int macb_poll(struct napi_struct *napi, int budget)
work_done = 0; work_done = 0;
dev_dbg(&bp->pdev->dev, "poll: status = %08lx, budget = %d\n", netdev_dbg(bp->dev, "poll: status = %08lx, budget = %d\n",
(unsigned long)status, budget); (unsigned long)status, budget);
work_done = macb_rx(bp, budget); work_done = macb_rx(bp, budget);
if (work_done < budget) { if (work_done < budget) {
...@@ -563,8 +564,7 @@ static irqreturn_t macb_interrupt(int irq, void *dev_id) ...@@ -563,8 +564,7 @@ static irqreturn_t macb_interrupt(int irq, void *dev_id)
macb_writel(bp, IDR, MACB_RX_INT_FLAGS); macb_writel(bp, IDR, MACB_RX_INT_FLAGS);
if (napi_schedule_prep(&bp->napi)) { if (napi_schedule_prep(&bp->napi)) {
dev_dbg(&bp->pdev->dev, netdev_dbg(bp->dev, "scheduling RX softirq\n");
"scheduling RX softirq\n");
__napi_schedule(&bp->napi); __napi_schedule(&bp->napi);
} }
} }
...@@ -585,11 +585,11 @@ static irqreturn_t macb_interrupt(int irq, void *dev_id) ...@@ -585,11 +585,11 @@ static irqreturn_t macb_interrupt(int irq, void *dev_id)
if (status & MACB_BIT(HRESP)) { if (status & MACB_BIT(HRESP)) {
/* /*
* TODO: Reset the hardware, and maybe move the printk * TODO: Reset the hardware, and maybe move the
* to a lower-priority context as well (work queue?) * netdev_err to a lower-priority context as well
* (work queue?)
*/ */
printk(KERN_ERR "%s: DMA bus error: HRESP not OK\n", netdev_err(dev, "DMA bus error: HRESP not OK\n");
dev->name);
} }
status = macb_readl(bp, ISR); status = macb_readl(bp, ISR);
...@@ -624,16 +624,12 @@ static int macb_start_xmit(struct sk_buff *skb, struct net_device *dev) ...@@ -624,16 +624,12 @@ static int macb_start_xmit(struct sk_buff *skb, struct net_device *dev)
unsigned long flags; unsigned long flags;
#ifdef DEBUG #ifdef DEBUG
int i; netdev_dbg(bp->dev,
dev_dbg(&bp->pdev->dev, "start_xmit: len %u head %p data %p tail %p end %p\n",
"start_xmit: len %u head %p data %p tail %p end %p\n", skb->len, skb->head, skb->data,
skb->len, skb->head, skb->data, skb_tail_pointer(skb), skb_end_pointer(skb));
skb_tail_pointer(skb), skb_end_pointer(skb)); print_hex_dump(KERN_DEBUG, "data: ", DUMP_PREFIX_OFFSET, 16, 1,
dev_dbg(&bp->pdev->dev, skb->data, 16, true);
"data:");
for (i = 0; i < 16; i++)
printk(" %02x", (unsigned int)skb->data[i]);
printk("\n");
#endif #endif
len = skb->len; len = skb->len;
...@@ -643,21 +639,20 @@ static int macb_start_xmit(struct sk_buff *skb, struct net_device *dev) ...@@ -643,21 +639,20 @@ static int macb_start_xmit(struct sk_buff *skb, struct net_device *dev)
if (TX_BUFFS_AVAIL(bp) < 1) { if (TX_BUFFS_AVAIL(bp) < 1) {
netif_stop_queue(dev); netif_stop_queue(dev);
spin_unlock_irqrestore(&bp->lock, flags); spin_unlock_irqrestore(&bp->lock, flags);
dev_err(&bp->pdev->dev, netdev_err(bp->dev, "BUG! Tx Ring full when queue awake!\n");
"BUG! Tx Ring full when queue awake!\n"); netdev_dbg(bp->dev, "tx_head = %u, tx_tail = %u\n",
dev_dbg(&bp->pdev->dev, "tx_head = %u, tx_tail = %u\n", bp->tx_head, bp->tx_tail);
bp->tx_head, bp->tx_tail);
return NETDEV_TX_BUSY; return NETDEV_TX_BUSY;
} }
entry = bp->tx_head; entry = bp->tx_head;
dev_dbg(&bp->pdev->dev, "Allocated ring entry %u\n", entry); netdev_dbg(bp->dev, "Allocated ring entry %u\n", entry);
mapping = dma_map_single(&bp->pdev->dev, skb->data, mapping = dma_map_single(&bp->pdev->dev, skb->data,
len, DMA_TO_DEVICE); len, DMA_TO_DEVICE);
bp->tx_skb[entry].skb = skb; bp->tx_skb[entry].skb = skb;
bp->tx_skb[entry].mapping = mapping; bp->tx_skb[entry].mapping = mapping;
dev_dbg(&bp->pdev->dev, "Mapped skb data %p to DMA addr %08lx\n", netdev_dbg(bp->dev, "Mapped skb data %p to DMA addr %08lx\n",
skb->data, (unsigned long)mapping); skb->data, (unsigned long)mapping);
ctrl = MACB_BF(TX_FRMLEN, len); ctrl = MACB_BF(TX_FRMLEN, len);
ctrl |= MACB_BIT(TX_LAST); ctrl |= MACB_BIT(TX_LAST);
...@@ -721,27 +716,27 @@ static int macb_alloc_consistent(struct macb *bp) ...@@ -721,27 +716,27 @@ static int macb_alloc_consistent(struct macb *bp)
&bp->rx_ring_dma, GFP_KERNEL); &bp->rx_ring_dma, GFP_KERNEL);
if (!bp->rx_ring) if (!bp->rx_ring)
goto out_err; goto out_err;
dev_dbg(&bp->pdev->dev, netdev_dbg(bp->dev,
"Allocated RX ring of %d bytes at %08lx (mapped %p)\n", "Allocated RX ring of %d bytes at %08lx (mapped %p)\n",
size, (unsigned long)bp->rx_ring_dma, bp->rx_ring); size, (unsigned long)bp->rx_ring_dma, bp->rx_ring);
size = TX_RING_BYTES; size = TX_RING_BYTES;
bp->tx_ring = dma_alloc_coherent(&bp->pdev->dev, size, bp->tx_ring = dma_alloc_coherent(&bp->pdev->dev, size,
&bp->tx_ring_dma, GFP_KERNEL); &bp->tx_ring_dma, GFP_KERNEL);
if (!bp->tx_ring) if (!bp->tx_ring)
goto out_err; goto out_err;
dev_dbg(&bp->pdev->dev, netdev_dbg(bp->dev,
"Allocated TX ring of %d bytes at %08lx (mapped %p)\n", "Allocated TX ring of %d bytes at %08lx (mapped %p)\n",
size, (unsigned long)bp->tx_ring_dma, bp->tx_ring); size, (unsigned long)bp->tx_ring_dma, bp->tx_ring);
size = RX_RING_SIZE * RX_BUFFER_SIZE; size = RX_RING_SIZE * RX_BUFFER_SIZE;
bp->rx_buffers = dma_alloc_coherent(&bp->pdev->dev, size, bp->rx_buffers = dma_alloc_coherent(&bp->pdev->dev, size,
&bp->rx_buffers_dma, GFP_KERNEL); &bp->rx_buffers_dma, GFP_KERNEL);
if (!bp->rx_buffers) if (!bp->rx_buffers)
goto out_err; goto out_err;
dev_dbg(&bp->pdev->dev, netdev_dbg(bp->dev,
"Allocated RX buffers of %d bytes at %08lx (mapped %p)\n", "Allocated RX buffers of %d bytes at %08lx (mapped %p)\n",
size, (unsigned long)bp->rx_buffers_dma, bp->rx_buffers); size, (unsigned long)bp->rx_buffers_dma, bp->rx_buffers);
return 0; return 0;
...@@ -952,7 +947,7 @@ static int macb_open(struct net_device *dev) ...@@ -952,7 +947,7 @@ static int macb_open(struct net_device *dev)
struct macb *bp = netdev_priv(dev); struct macb *bp = netdev_priv(dev);
int err; int err;
dev_dbg(&bp->pdev->dev, "open\n"); netdev_dbg(bp->dev, "open\n");
/* if the phy is not yet register, retry later*/ /* if the phy is not yet register, retry later*/
if (!bp->phy_dev) if (!bp->phy_dev)
...@@ -963,9 +958,8 @@ static int macb_open(struct net_device *dev) ...@@ -963,9 +958,8 @@ static int macb_open(struct net_device *dev)
err = macb_alloc_consistent(bp); err = macb_alloc_consistent(bp);
if (err) { if (err) {
printk(KERN_ERR netdev_err(dev, "Unable to allocate DMA memory (error %d)\n",
"%s: Unable to allocate DMA memory (error %d)\n", err);
dev->name, err);
return err; return err;
} }
...@@ -1174,9 +1168,8 @@ static int __init macb_probe(struct platform_device *pdev) ...@@ -1174,9 +1168,8 @@ static int __init macb_probe(struct platform_device *pdev)
dev->irq = platform_get_irq(pdev, 0); dev->irq = platform_get_irq(pdev, 0);
err = request_irq(dev->irq, macb_interrupt, 0, dev->name, dev); err = request_irq(dev->irq, macb_interrupt, 0, dev->name, dev);
if (err) { if (err) {
printk(KERN_ERR dev_err(&pdev->dev, "Unable to request IRQ %d (error %d)\n",
"%s: Unable to request IRQ %d (error %d)\n", dev->irq, err);
dev->name, dev->irq, err);
goto err_out_iounmap; goto err_out_iounmap;
} }
...@@ -1228,13 +1221,12 @@ static int __init macb_probe(struct platform_device *pdev) ...@@ -1228,13 +1221,12 @@ static int __init macb_probe(struct platform_device *pdev)
platform_set_drvdata(pdev, dev); platform_set_drvdata(pdev, dev);
printk(KERN_INFO "%s: Atmel MACB at 0x%08lx irq %d (%pM)\n", netdev_info(dev, "Atmel MACB at 0x%08lx irq %d (%pM)\n",
dev->name, dev->base_addr, dev->irq, dev->dev_addr); dev->base_addr, dev->irq, dev->dev_addr);
phydev = bp->phy_dev; phydev = bp->phy_dev;
printk(KERN_INFO "%s: attached PHY driver [%s] " netdev_info(dev, "attached PHY driver [%s] (mii_bus:phy_addr=%s, irq=%d)\n",
"(mii_bus:phy_addr=%s, irq=%d)\n", dev->name, phydev->drv->name, dev_name(&phydev->dev), phydev->irq);
phydev->drv->name, dev_name(&phydev->dev), phydev->irq);
return 0; return 0;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册