aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorVarka Bhadram <varkab@cdac.in>2014-07-10 01:35:41 -0400
committerDavid S. Miller <davem@davemloft.net>2014-07-10 03:40:36 -0400
commitf160a2d0b524eeebd97a68e2fbb59fad4cdd3fee (patch)
tree1c2e40b80265c1090e6662509a8c8751bea33b10
parent8bcd5c6d513274f93d81584ad5b2d6b1841f63aa (diff)
net: cpmac: dynamic debug fixes
This patch does the following changes 1. convert printk(KERN_DEBUG.. to netdev_dbg() if we have net_device object or convert to dev_dbg() if we have device object. 2. convert printk(KERN_WARNING.. to netdev_warn() if we have net_device object or convert to dev_warn() if we have device object 3. convert printk() to pr_* Signed-off-by: Varka Bhadram <varkab@cdac.in> Signed-off-by: David S. Miller <davem@davemloft.net>
-rw-r--r--drivers/net/ethernet/ti/cpmac.c136
1 files changed, 62 insertions, 74 deletions
diff --git a/drivers/net/ethernet/ti/cpmac.c b/drivers/net/ethernet/ti/cpmac.c
index 1d8ef39f370f..9faf6699561e 100644
--- a/drivers/net/ethernet/ti/cpmac.c
+++ b/drivers/net/ethernet/ti/cpmac.c
@@ -228,21 +228,20 @@ static void cpmac_dump_regs(struct net_device *dev)
228 if (i % 16 == 0) { 228 if (i % 16 == 0) {
229 if (i) 229 if (i)
230 pr_cont("\n"); 230 pr_cont("\n");
231 printk(KERN_DEBUG "%s: reg[%p]:", dev->name, 231 netdev_dbg(dev, "reg[%p]:", priv->regs + i);
232 priv->regs + i);
233 } 232 }
234 printk(" %08x", cpmac_read(priv->regs, i)); 233 pr_debug(" %08x", cpmac_read(priv->regs, i));
235 } 234 }
236 printk("\n"); 235 pr_debug("\n");
237} 236}
238 237
239static void cpmac_dump_desc(struct net_device *dev, struct cpmac_desc *desc) 238static void cpmac_dump_desc(struct net_device *dev, struct cpmac_desc *desc)
240{ 239{
241 int i; 240 int i;
242 printk(KERN_DEBUG "%s: desc[%p]:", dev->name, desc); 241 netdev_dbg(dev, "desc[%p]:", desc);
243 for (i = 0; i < sizeof(*desc) / 4; i++) 242 for (i = 0; i < sizeof(*desc) / 4; i++)
244 printk(" %08x", ((u32 *)desc)[i]); 243 pr_debug(" %08x", ((u32 *)desc)[i]);
245 printk("\n"); 244 pr_debug("\n");
246} 245}
247 246
248static void cpmac_dump_all_desc(struct net_device *dev) 247static void cpmac_dump_all_desc(struct net_device *dev)
@@ -258,17 +257,16 @@ static void cpmac_dump_all_desc(struct net_device *dev)
258static void cpmac_dump_skb(struct net_device *dev, struct sk_buff *skb) 257static void cpmac_dump_skb(struct net_device *dev, struct sk_buff *skb)
259{ 258{
260 int i; 259 int i;
261 printk(KERN_DEBUG "%s: skb 0x%p, len=%d\n", dev->name, skb, skb->len); 260 netdev_dbg(dev, "skb 0x%p, len=%d\n", skb, skb->len);
262 for (i = 0; i < skb->len; i++) { 261 for (i = 0; i < skb->len; i++) {
263 if (i % 16 == 0) { 262 if (i % 16 == 0) {
264 if (i) 263 if (i)
265 pr_cont("\n"); 264 pr_cont("\n");
266 printk(KERN_DEBUG "%s: data[%p]:", dev->name, 265 netdev_dbg(dev, "data[%p]:", skb->data + i);
267 skb->data + i);
268 } 266 }
269 printk(" %02x", ((u8 *)skb->data)[i]); 267 pr_debug(" %02x", ((u8 *)skb->data)[i]);
270 } 268 }
271 printk("\n"); 269 pr_debug("\n");
272} 270}
273 271
274static int cpmac_mdio_read(struct mii_bus *bus, int phy_id, int reg) 272static int cpmac_mdio_read(struct mii_bus *bus, int phy_id, int reg)
@@ -300,7 +298,7 @@ static int cpmac_mdio_reset(struct mii_bus *bus)
300 298
301 cpmac_clk = clk_get(&bus->dev, "cpmac"); 299 cpmac_clk = clk_get(&bus->dev, "cpmac");
302 if (IS_ERR(cpmac_clk)) { 300 if (IS_ERR(cpmac_clk)) {
303 printk(KERN_ERR "unable to get cpmac clock\n"); 301 pr_err("unable to get cpmac clock\n");
304 return -1; 302 return -1;
305 } 303 }
306 ar7_device_reset(AR7_RESET_BIT_MDIO); 304 ar7_device_reset(AR7_RESET_BIT_MDIO);
@@ -368,8 +366,8 @@ static struct sk_buff *cpmac_rx_one(struct cpmac_priv *priv,
368 cpmac_write(priv->regs, CPMAC_RX_ACK(0), (u32)desc->mapping); 366 cpmac_write(priv->regs, CPMAC_RX_ACK(0), (u32)desc->mapping);
369 if (unlikely(!desc->datalen)) { 367 if (unlikely(!desc->datalen)) {
370 if (netif_msg_rx_err(priv) && net_ratelimit()) 368 if (netif_msg_rx_err(priv) && net_ratelimit())
371 printk(KERN_WARNING "%s: rx: spurious interrupt\n", 369 netdev_warn(priv->dev, "rx: spurious interrupt\n");
372 priv->dev->name); 370
373 return NULL; 371 return NULL;
374 } 372 }
375 373
@@ -389,15 +387,14 @@ static struct sk_buff *cpmac_rx_one(struct cpmac_priv *priv,
389 DMA_FROM_DEVICE); 387 DMA_FROM_DEVICE);
390 desc->hw_data = (u32)desc->data_mapping; 388 desc->hw_data = (u32)desc->data_mapping;
391 if (unlikely(netif_msg_pktdata(priv))) { 389 if (unlikely(netif_msg_pktdata(priv))) {
392 printk(KERN_DEBUG "%s: received packet:\n", 390 netdev_dbg(priv->dev, "received packet:\n");
393 priv->dev->name);
394 cpmac_dump_skb(priv->dev, result); 391 cpmac_dump_skb(priv->dev, result);
395 } 392 }
396 } else { 393 } else {
397 if (netif_msg_rx_err(priv) && net_ratelimit()) 394 if (netif_msg_rx_err(priv) && net_ratelimit())
398 printk(KERN_WARNING 395 netdev_warn(priv->dev,
399 "%s: low on skbs, dropping packet\n", 396 "low on skbs, dropping packet\n");
400 priv->dev->name); 397
401 priv->dev->stats.rx_dropped++; 398 priv->dev->stats.rx_dropped++;
402 } 399 }
403 400
@@ -417,8 +414,8 @@ static int cpmac_poll(struct napi_struct *napi, int budget)
417 spin_lock(&priv->rx_lock); 414 spin_lock(&priv->rx_lock);
418 if (unlikely(!priv->rx_head)) { 415 if (unlikely(!priv->rx_head)) {
419 if (netif_msg_rx_err(priv) && net_ratelimit()) 416 if (netif_msg_rx_err(priv) && net_ratelimit())
420 printk(KERN_WARNING "%s: rx: polling, but no queue\n", 417 netdev_warn(priv->dev, "rx: polling, but no queue\n");
421 priv->dev->name); 418
422 spin_unlock(&priv->rx_lock); 419 spin_unlock(&priv->rx_lock);
423 napi_complete(napi); 420 napi_complete(napi);
424 return 0; 421 return 0;
@@ -437,9 +434,9 @@ static int cpmac_poll(struct napi_struct *napi, int budget)
437 */ 434 */
438 if (unlikely(restart)) { 435 if (unlikely(restart)) {
439 if (netif_msg_rx_err(priv)) 436 if (netif_msg_rx_err(priv))
440 printk(KERN_ERR "%s: poll found a" 437 netdev_err(priv->dev, "poll found a"
441 " duplicate EOQ: %p and %p\n", 438 " duplicate EOQ: %p and %p\n",
442 priv->dev->name, restart, desc); 439 restart, desc);
443 goto fatal_error; 440 goto fatal_error;
444 } 441 }
445 442
@@ -485,15 +482,13 @@ static int cpmac_poll(struct napi_struct *napi, int budget)
485 priv->dev->stats.rx_errors++; 482 priv->dev->stats.rx_errors++;
486 priv->dev->stats.rx_fifo_errors++; 483 priv->dev->stats.rx_fifo_errors++;
487 if (netif_msg_rx_err(priv) && net_ratelimit()) 484 if (netif_msg_rx_err(priv) && net_ratelimit())
488 printk(KERN_WARNING "%s: rx dma ring overrun\n", 485 netdev_warn(priv->dev, "rx dma ring overrun\n");
489 priv->dev->name);
490 486
491 if (unlikely((restart->dataflags & CPMAC_OWN) == 0)) { 487 if (unlikely((restart->dataflags & CPMAC_OWN) == 0)) {
492 if (netif_msg_drv(priv)) 488 if (netif_msg_drv(priv))
493 printk(KERN_ERR "%s: cpmac_poll is trying to " 489 netdev_err(priv->dev, "cpmac_poll is trying "
494 "restart rx from a descriptor that's " 490 "to restart rx from a descriptor "
495 "not free: %p\n", 491 "that's not free: %p\n", restart);
496 priv->dev->name, restart);
497 goto fatal_error; 492 goto fatal_error;
498 } 493 }
499 494
@@ -503,8 +498,8 @@ static int cpmac_poll(struct napi_struct *napi, int budget)
503 priv->rx_head = desc; 498 priv->rx_head = desc;
504 spin_unlock(&priv->rx_lock); 499 spin_unlock(&priv->rx_lock);
505 if (unlikely(netif_msg_rx_status(priv))) 500 if (unlikely(netif_msg_rx_status(priv)))
506 printk(KERN_DEBUG "%s: poll processed %d packets\n", 501 netdev_dbg(priv->dev, "poll processed %d packets\n", received);
507 priv->dev->name, received); 502
508 if (processed == 0) { 503 if (processed == 0) {
509 /* we ran out of packets to read, 504 /* we ran out of packets to read,
510 * revert to interrupt-driven mode 505 * revert to interrupt-driven mode
@@ -521,13 +516,12 @@ fatal_error:
521 * Reset hardware to try to recover rather than wedging. 516 * Reset hardware to try to recover rather than wedging.
522 */ 517 */
523 if (netif_msg_drv(priv)) { 518 if (netif_msg_drv(priv)) {
524 printk(KERN_ERR "%s: cpmac_poll is confused. " 519 netdev_err(priv->dev, "cpmac_poll is confused. "
525 "Resetting hardware\n", priv->dev->name); 520 "Resetting hardware\n");
526 cpmac_dump_all_desc(priv->dev); 521 cpmac_dump_all_desc(priv->dev);
527 printk(KERN_DEBUG "%s: RX_PTR(0)=0x%08x RX_ACK(0)=0x%08x\n", 522 netdev_dbg(priv->dev, "RX_PTR(0)=0x%08x RX_ACK(0)=0x%08x\n",
528 priv->dev->name, 523 cpmac_read(priv->regs, CPMAC_RX_PTR(0)),
529 cpmac_read(priv->regs, CPMAC_RX_PTR(0)), 524 cpmac_read(priv->regs, CPMAC_RX_ACK(0)));
530 cpmac_read(priv->regs, CPMAC_RX_ACK(0)));
531 } 525 }
532 526
533 spin_unlock(&priv->rx_lock); 527 spin_unlock(&priv->rx_lock);
@@ -562,8 +556,8 @@ static int cpmac_start_xmit(struct sk_buff *skb, struct net_device *dev)
562 desc = &priv->desc_ring[queue]; 556 desc = &priv->desc_ring[queue];
563 if (unlikely(desc->dataflags & CPMAC_OWN)) { 557 if (unlikely(desc->dataflags & CPMAC_OWN)) {
564 if (netif_msg_tx_err(priv) && net_ratelimit()) 558 if (netif_msg_tx_err(priv) && net_ratelimit())
565 printk(KERN_WARNING "%s: tx dma ring full\n", 559 netdev_warn(dev, "tx dma ring full\n");
566 dev->name); 560
567 return NETDEV_TX_BUSY; 561 return NETDEV_TX_BUSY;
568 } 562 }
569 563
@@ -577,8 +571,7 @@ static int cpmac_start_xmit(struct sk_buff *skb, struct net_device *dev)
577 desc->datalen = len; 571 desc->datalen = len;
578 desc->buflen = len; 572 desc->buflen = len;
579 if (unlikely(netif_msg_tx_queued(priv))) 573 if (unlikely(netif_msg_tx_queued(priv)))
580 printk(KERN_DEBUG "%s: sending 0x%p, len=%d\n", dev->name, skb, 574 netdev_dbg(dev, "sending 0x%p, len=%d\n", skb, skb->len);
581 skb->len);
582 if (unlikely(netif_msg_hw(priv))) 575 if (unlikely(netif_msg_hw(priv)))
583 cpmac_dump_desc(dev, desc); 576 cpmac_dump_desc(dev, desc);
584 if (unlikely(netif_msg_pktdata(priv))) 577 if (unlikely(netif_msg_pktdata(priv)))
@@ -604,8 +597,8 @@ static void cpmac_end_xmit(struct net_device *dev, int queue)
604 DMA_TO_DEVICE); 597 DMA_TO_DEVICE);
605 598
606 if (unlikely(netif_msg_tx_done(priv))) 599 if (unlikely(netif_msg_tx_done(priv)))
607 printk(KERN_DEBUG "%s: sent 0x%p, len=%d\n", dev->name, 600 netdev_dbg(dev, "sent 0x%p, len=%d\n",
608 desc->skb, desc->skb->len); 601 desc->skb, desc->skb->len);
609 602
610 dev_kfree_skb_irq(desc->skb); 603 dev_kfree_skb_irq(desc->skb);
611 desc->skb = NULL; 604 desc->skb = NULL;
@@ -613,8 +606,7 @@ static void cpmac_end_xmit(struct net_device *dev, int queue)
613 netif_wake_subqueue(dev, queue); 606 netif_wake_subqueue(dev, queue);
614 } else { 607 } else {
615 if (netif_msg_tx_err(priv) && net_ratelimit()) 608 if (netif_msg_tx_err(priv) && net_ratelimit())
616 printk(KERN_WARNING 609 netdev_warn(dev, "end_xmit: spurious interrupt\n");
617 "%s: end_xmit: spurious interrupt\n", dev->name);
618 if (__netif_subqueue_stopped(dev, queue)) 610 if (__netif_subqueue_stopped(dev, queue))
619 netif_wake_subqueue(dev, queue); 611 netif_wake_subqueue(dev, queue);
620 } 612 }
@@ -695,8 +687,7 @@ static void cpmac_clear_rx(struct net_device *dev)
695 for (i = 0; i < priv->ring_size; i++) { 687 for (i = 0; i < priv->ring_size; i++) {
696 if ((desc->dataflags & CPMAC_OWN) == 0) { 688 if ((desc->dataflags & CPMAC_OWN) == 0) {
697 if (netif_msg_rx_err(priv) && net_ratelimit()) 689 if (netif_msg_rx_err(priv) && net_ratelimit())
698 printk(KERN_WARNING "%s: packet dropped\n", 690 netdev_warn(dev, "packet dropped\n");
699 dev->name);
700 if (unlikely(netif_msg_hw(priv))) 691 if (unlikely(netif_msg_hw(priv)))
701 cpmac_dump_desc(dev, desc); 692 cpmac_dump_desc(dev, desc);
702 desc->dataflags = CPMAC_OWN; 693 desc->dataflags = CPMAC_OWN;
@@ -756,13 +747,13 @@ static void cpmac_check_status(struct net_device *dev)
756 * error codes actually are. So just log them and hope.. 747 * error codes actually are. So just log them and hope..
757 */ 748 */
758 if (rx_code) 749 if (rx_code)
759 printk(KERN_WARNING "%s: host error %d on rx " 750 netdev_warn(dev, "host error %d on rx "
760 "channel %d (macstatus %08x), resetting\n", 751 "channel %d (macstatus %08x), resetting\n",
761 dev->name, rx_code, rx_channel, macstatus); 752 rx_code, rx_channel, macstatus);
762 if (tx_code) 753 if (tx_code)
763 printk(KERN_WARNING "%s: host error %d on tx " 754 netdev_warn(dev, "host error %d on tx "
764 "channel %d (macstatus %08x), resetting\n", 755 "channel %d (macstatus %08x), resetting\n",
765 dev->name, tx_code, tx_channel, macstatus); 756 tx_code, tx_channel, macstatus);
766 } 757 }
767 758
768 netif_tx_stop_all_queues(dev); 759 netif_tx_stop_all_queues(dev);
@@ -787,8 +778,7 @@ static irqreturn_t cpmac_irq(int irq, void *dev_id)
787 status = cpmac_read(priv->regs, CPMAC_MAC_INT_VECTOR); 778 status = cpmac_read(priv->regs, CPMAC_MAC_INT_VECTOR);
788 779
789 if (unlikely(netif_msg_intr(priv))) 780 if (unlikely(netif_msg_intr(priv)))
790 printk(KERN_DEBUG "%s: interrupt status: 0x%08x\n", dev->name, 781 netdev_dbg(dev, "interrupt status: 0x%08x\n", status);
791 status);
792 782
793 if (status & MAC_INT_TX) 783 if (status & MAC_INT_TX)
794 cpmac_end_xmit(dev, (status & 7)); 784 cpmac_end_xmit(dev, (status & 7));
@@ -817,7 +807,7 @@ static void cpmac_tx_timeout(struct net_device *dev)
817 dev->stats.tx_errors++; 807 dev->stats.tx_errors++;
818 spin_unlock(&priv->lock); 808 spin_unlock(&priv->lock);
819 if (netif_msg_tx_err(priv) && net_ratelimit()) 809 if (netif_msg_tx_err(priv) && net_ratelimit())
820 printk(KERN_WARNING "%s: transmit timeout\n", dev->name); 810 netdev_warn(dev, "transmit timeout\n");
821 811
822 atomic_inc(&priv->reset_pending); 812 atomic_inc(&priv->reset_pending);
823 barrier(); 813 barrier();
@@ -953,8 +943,8 @@ static int cpmac_open(struct net_device *dev)
953 mem = platform_get_resource_byname(priv->pdev, IORESOURCE_MEM, "regs"); 943 mem = platform_get_resource_byname(priv->pdev, IORESOURCE_MEM, "regs");
954 if (!request_mem_region(mem->start, resource_size(mem), dev->name)) { 944 if (!request_mem_region(mem->start, resource_size(mem), dev->name)) {
955 if (netif_msg_drv(priv)) 945 if (netif_msg_drv(priv))
956 printk(KERN_ERR "%s: failed to request registers\n", 946 netdev_err(dev, "failed to request registers\n");
957 dev->name); 947
958 res = -ENXIO; 948 res = -ENXIO;
959 goto fail_reserve; 949 goto fail_reserve;
960 } 950 }
@@ -962,8 +952,8 @@ static int cpmac_open(struct net_device *dev)
962 priv->regs = ioremap(mem->start, resource_size(mem)); 952 priv->regs = ioremap(mem->start, resource_size(mem));
963 if (!priv->regs) { 953 if (!priv->regs) {
964 if (netif_msg_drv(priv)) 954 if (netif_msg_drv(priv))
965 printk(KERN_ERR "%s: failed to remap registers\n", 955 netdev_err(dev, "failed to remap registers\n");
966 dev->name); 956
967 res = -ENXIO; 957 res = -ENXIO;
968 goto fail_remap; 958 goto fail_remap;
969 } 959 }
@@ -1005,8 +995,8 @@ static int cpmac_open(struct net_device *dev)
1005 res = request_irq(dev->irq, cpmac_irq, IRQF_SHARED, dev->name, dev); 995 res = request_irq(dev->irq, cpmac_irq, IRQF_SHARED, dev->name, dev);
1006 if (res) { 996 if (res) {
1007 if (netif_msg_drv(priv)) 997 if (netif_msg_drv(priv))
1008 printk(KERN_ERR "%s: failed to obtain irq\n", 998 netdev_err(dev, "failed to obtain irq\n");
1009 dev->name); 999
1010 goto fail_irq; 1000 goto fail_irq;
1011 } 1001 }
1012 1002
@@ -1123,7 +1113,7 @@ static int cpmac_probe(struct platform_device *pdev)
1123 1113
1124 if (phy_id == PHY_MAX_ADDR) { 1114 if (phy_id == PHY_MAX_ADDR) {
1125 dev_err(&pdev->dev, "no PHY present, falling back " 1115 dev_err(&pdev->dev, "no PHY present, falling back "
1126 "to switch on MDIO bus 0\n"); 1116 "to switch on MDIO bus 0\n");
1127 strncpy(mdio_bus_id, "fixed-0", MII_BUS_ID_SIZE); /* fixed phys bus */ 1117 strncpy(mdio_bus_id, "fixed-0", MII_BUS_ID_SIZE); /* fixed phys bus */
1128 phy_id = pdev->id; 1118 phy_id = pdev->id;
1129 } 1119 }
@@ -1164,24 +1154,22 @@ static int cpmac_probe(struct platform_device *pdev)
1164 1154
1165 if (IS_ERR(priv->phy)) { 1155 if (IS_ERR(priv->phy)) {
1166 if (netif_msg_drv(priv)) 1156 if (netif_msg_drv(priv))
1167 printk(KERN_ERR "%s: Could not attach to PHY\n", 1157 dev_err(&pdev->dev, "Could not attach to PHY\n");
1168 dev->name); 1158
1169 rc = PTR_ERR(priv->phy); 1159 rc = PTR_ERR(priv->phy);
1170 goto fail; 1160 goto fail;
1171 } 1161 }
1172 1162
1173 rc = register_netdev(dev); 1163 rc = register_netdev(dev);
1174 if (rc) { 1164 if (rc) {
1175 printk(KERN_ERR "cpmac: error %i registering device %s\n", rc, 1165 dev_err(&pdev->dev, "Could not register net device\n");
1176 dev->name);
1177 goto fail; 1166 goto fail;
1178 } 1167 }
1179 1168
1180 if (netif_msg_probe(priv)) { 1169 if (netif_msg_probe(priv)) {
1181 printk(KERN_INFO 1170 dev_info(&pdev->dev, "regs: %p, irq: %d, phy: %s, "
1182 "cpmac: device %s (regs: %p, irq: %d, phy: %s, " 1171 "mac: %pM\n", (void *)mem->start, dev->irq,
1183 "mac: %pM)\n", dev->name, (void *)mem->start, dev->irq, 1172 priv->phy_name, dev->dev_addr);
1184 priv->phy_name, dev->dev_addr);
1185 } 1173 }
1186 return 0; 1174 return 0;
1187 1175
@@ -1223,7 +1211,7 @@ int cpmac_init(void)
1223 cpmac_mii->priv = ioremap(AR7_REGS_MDIO, 256); 1211 cpmac_mii->priv = ioremap(AR7_REGS_MDIO, 256);
1224 1212
1225 if (!cpmac_mii->priv) { 1213 if (!cpmac_mii->priv) {
1226 printk(KERN_ERR "Can't ioremap mdio registers\n"); 1214 pr_err("Can't ioremap mdio registers\n");
1227 res = -ENXIO; 1215 res = -ENXIO;
1228 goto fail_alloc; 1216 goto fail_alloc;
1229 } 1217 }