Skip to content

Commit f160a2d

Browse files
bhadramdavem330
authored andcommitted
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>
1 parent 8bcd5c6 commit f160a2d

File tree

1 file changed

+62
-74
lines changed

1 file changed

+62
-74
lines changed

drivers/net/ethernet/ti/cpmac.c

Lines changed: 62 additions & 74 deletions
Original file line numberDiff line numberDiff line change
@@ -228,21 +228,20 @@ static void cpmac_dump_regs(struct net_device *dev)
228228
if (i % 16 == 0) {
229229
if (i)
230230
pr_cont("\n");
231-
printk(KERN_DEBUG "%s: reg[%p]:", dev->name,
232-
priv->regs + i);
231+
netdev_dbg(dev, "reg[%p]:", priv->regs + i);
233232
}
234-
printk(" %08x", cpmac_read(priv->regs, i));
233+
pr_debug(" %08x", cpmac_read(priv->regs, i));
235234
}
236-
printk("\n");
235+
pr_debug("\n");
237236
}
238237

239238
static void cpmac_dump_desc(struct net_device *dev, struct cpmac_desc *desc)
240239
{
241240
int i;
242-
printk(KERN_DEBUG "%s: desc[%p]:", dev->name, desc);
241+
netdev_dbg(dev, "desc[%p]:", desc);
243242
for (i = 0; i < sizeof(*desc) / 4; i++)
244-
printk(" %08x", ((u32 *)desc)[i]);
245-
printk("\n");
243+
pr_debug(" %08x", ((u32 *)desc)[i]);
244+
pr_debug("\n");
246245
}
247246

248247
static void cpmac_dump_all_desc(struct net_device *dev)
@@ -258,17 +257,16 @@ static void cpmac_dump_all_desc(struct net_device *dev)
258257
static void cpmac_dump_skb(struct net_device *dev, struct sk_buff *skb)
259258
{
260259
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);
262261
for (i = 0; i < skb->len; i++) {
263262
if (i % 16 == 0) {
264263
if (i)
265264
pr_cont("\n");
266-
printk(KERN_DEBUG "%s: data[%p]:", dev->name,
267-
skb->data + i);
265+
netdev_dbg(dev, "data[%p]:", skb->data + i);
268266
}
269-
printk(" %02x", ((u8 *)skb->data)[i]);
267+
pr_debug(" %02x", ((u8 *)skb->data)[i]);
270268
}
271-
printk("\n");
269+
pr_debug("\n");
272270
}
273271

274272
static 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)
300298

301299
cpmac_clk = clk_get(&bus->dev, "cpmac");
302300
if (IS_ERR(cpmac_clk)) {
303-
printk(KERN_ERR "unable to get cpmac clock\n");
301+
pr_err("unable to get cpmac clock\n");
304302
return -1;
305303
}
306304
ar7_device_reset(AR7_RESET_BIT_MDIO);
@@ -368,8 +366,8 @@ static struct sk_buff *cpmac_rx_one(struct cpmac_priv *priv,
368366
cpmac_write(priv->regs, CPMAC_RX_ACK(0), (u32)desc->mapping);
369367
if (unlikely(!desc->datalen)) {
370368
if (netif_msg_rx_err(priv) && net_ratelimit())
371-
printk(KERN_WARNING "%s: rx: spurious interrupt\n",
372-
priv->dev->name);
369+
netdev_warn(priv->dev, "rx: spurious interrupt\n");
370+
373371
return NULL;
374372
}
375373

@@ -389,15 +387,14 @@ static struct sk_buff *cpmac_rx_one(struct cpmac_priv *priv,
389387
DMA_FROM_DEVICE);
390388
desc->hw_data = (u32)desc->data_mapping;
391389
if (unlikely(netif_msg_pktdata(priv))) {
392-
printk(KERN_DEBUG "%s: received packet:\n",
393-
priv->dev->name);
390+
netdev_dbg(priv->dev, "received packet:\n");
394391
cpmac_dump_skb(priv->dev, result);
395392
}
396393
} else {
397394
if (netif_msg_rx_err(priv) && net_ratelimit())
398-
printk(KERN_WARNING
399-
"%s: low on skbs, dropping packet\n",
400-
priv->dev->name);
395+
netdev_warn(priv->dev,
396+
"low on skbs, dropping packet\n");
397+
401398
priv->dev->stats.rx_dropped++;
402399
}
403400

@@ -417,8 +414,8 @@ static int cpmac_poll(struct napi_struct *napi, int budget)
417414
spin_lock(&priv->rx_lock);
418415
if (unlikely(!priv->rx_head)) {
419416
if (netif_msg_rx_err(priv) && net_ratelimit())
420-
printk(KERN_WARNING "%s: rx: polling, but no queue\n",
421-
priv->dev->name);
417+
netdev_warn(priv->dev, "rx: polling, but no queue\n");
418+
422419
spin_unlock(&priv->rx_lock);
423420
napi_complete(napi);
424421
return 0;
@@ -437,9 +434,9 @@ static int cpmac_poll(struct napi_struct *napi, int budget)
437434
*/
438435
if (unlikely(restart)) {
439436
if (netif_msg_rx_err(priv))
440-
printk(KERN_ERR "%s: poll found a"
441-
" duplicate EOQ: %p and %p\n",
442-
priv->dev->name, restart, desc);
437+
netdev_err(priv->dev, "poll found a"
438+
" duplicate EOQ: %p and %p\n",
439+
restart, desc);
443440
goto fatal_error;
444441
}
445442

@@ -485,15 +482,13 @@ static int cpmac_poll(struct napi_struct *napi, int budget)
485482
priv->dev->stats.rx_errors++;
486483
priv->dev->stats.rx_fifo_errors++;
487484
if (netif_msg_rx_err(priv) && net_ratelimit())
488-
printk(KERN_WARNING "%s: rx dma ring overrun\n",
489-
priv->dev->name);
485+
netdev_warn(priv->dev, "rx dma ring overrun\n");
490486

491487
if (unlikely((restart->dataflags & CPMAC_OWN) == 0)) {
492488
if (netif_msg_drv(priv))
493-
printk(KERN_ERR "%s: cpmac_poll is trying to "
494-
"restart rx from a descriptor that's "
495-
"not free: %p\n",
496-
priv->dev->name, restart);
489+
netdev_err(priv->dev, "cpmac_poll is trying "
490+
"to restart rx from a descriptor "
491+
"that's not free: %p\n", restart);
497492
goto fatal_error;
498493
}
499494

@@ -503,8 +498,8 @@ static int cpmac_poll(struct napi_struct *napi, int budget)
503498
priv->rx_head = desc;
504499
spin_unlock(&priv->rx_lock);
505500
if (unlikely(netif_msg_rx_status(priv)))
506-
printk(KERN_DEBUG "%s: poll processed %d packets\n",
507-
priv->dev->name, received);
501+
netdev_dbg(priv->dev, "poll processed %d packets\n", received);
502+
508503
if (processed == 0) {
509504
/* we ran out of packets to read,
510505
* revert to interrupt-driven mode
@@ -521,13 +516,12 @@ static int cpmac_poll(struct napi_struct *napi, int budget)
521516
* Reset hardware to try to recover rather than wedging.
522517
*/
523518
if (netif_msg_drv(priv)) {
524-
printk(KERN_ERR "%s: cpmac_poll is confused. "
525-
"Resetting hardware\n", priv->dev->name);
519+
netdev_err(priv->dev, "cpmac_poll is confused. "
520+
"Resetting hardware\n");
526521
cpmac_dump_all_desc(priv->dev);
527-
printk(KERN_DEBUG "%s: RX_PTR(0)=0x%08x RX_ACK(0)=0x%08x\n",
528-
priv->dev->name,
529-
cpmac_read(priv->regs, CPMAC_RX_PTR(0)),
530-
cpmac_read(priv->regs, CPMAC_RX_ACK(0)));
522+
netdev_dbg(priv->dev, "RX_PTR(0)=0x%08x RX_ACK(0)=0x%08x\n",
523+
cpmac_read(priv->regs, CPMAC_RX_PTR(0)),
524+
cpmac_read(priv->regs, CPMAC_RX_ACK(0)));
531525
}
532526

533527
spin_unlock(&priv->rx_lock);
@@ -562,8 +556,8 @@ static int cpmac_start_xmit(struct sk_buff *skb, struct net_device *dev)
562556
desc = &priv->desc_ring[queue];
563557
if (unlikely(desc->dataflags & CPMAC_OWN)) {
564558
if (netif_msg_tx_err(priv) && net_ratelimit())
565-
printk(KERN_WARNING "%s: tx dma ring full\n",
566-
dev->name);
559+
netdev_warn(dev, "tx dma ring full\n");
560+
567561
return NETDEV_TX_BUSY;
568562
}
569563

@@ -577,8 +571,7 @@ static int cpmac_start_xmit(struct sk_buff *skb, struct net_device *dev)
577571
desc->datalen = len;
578572
desc->buflen = len;
579573
if (unlikely(netif_msg_tx_queued(priv)))
580-
printk(KERN_DEBUG "%s: sending 0x%p, len=%d\n", dev->name, skb,
581-
skb->len);
574+
netdev_dbg(dev, "sending 0x%p, len=%d\n", skb, skb->len);
582575
if (unlikely(netif_msg_hw(priv)))
583576
cpmac_dump_desc(dev, desc);
584577
if (unlikely(netif_msg_pktdata(priv)))
@@ -604,17 +597,16 @@ static void cpmac_end_xmit(struct net_device *dev, int queue)
604597
DMA_TO_DEVICE);
605598

606599
if (unlikely(netif_msg_tx_done(priv)))
607-
printk(KERN_DEBUG "%s: sent 0x%p, len=%d\n", dev->name,
608-
desc->skb, desc->skb->len);
600+
netdev_dbg(dev, "sent 0x%p, len=%d\n",
601+
desc->skb, desc->skb->len);
609602

610603
dev_kfree_skb_irq(desc->skb);
611604
desc->skb = NULL;
612605
if (__netif_subqueue_stopped(dev, queue))
613606
netif_wake_subqueue(dev, queue);
614607
} else {
615608
if (netif_msg_tx_err(priv) && net_ratelimit())
616-
printk(KERN_WARNING
617-
"%s: end_xmit: spurious interrupt\n", dev->name);
609+
netdev_warn(dev, "end_xmit: spurious interrupt\n");
618610
if (__netif_subqueue_stopped(dev, queue))
619611
netif_wake_subqueue(dev, queue);
620612
}
@@ -695,8 +687,7 @@ static void cpmac_clear_rx(struct net_device *dev)
695687
for (i = 0; i < priv->ring_size; i++) {
696688
if ((desc->dataflags & CPMAC_OWN) == 0) {
697689
if (netif_msg_rx_err(priv) && net_ratelimit())
698-
printk(KERN_WARNING "%s: packet dropped\n",
699-
dev->name);
690+
netdev_warn(dev, "packet dropped\n");
700691
if (unlikely(netif_msg_hw(priv)))
701692
cpmac_dump_desc(dev, desc);
702693
desc->dataflags = CPMAC_OWN;
@@ -756,13 +747,13 @@ static void cpmac_check_status(struct net_device *dev)
756747
* error codes actually are. So just log them and hope..
757748
*/
758749
if (rx_code)
759-
printk(KERN_WARNING "%s: host error %d on rx "
760-
"channel %d (macstatus %08x), resetting\n",
761-
dev->name, rx_code, rx_channel, macstatus);
750+
netdev_warn(dev, "host error %d on rx "
751+
"channel %d (macstatus %08x), resetting\n",
752+
rx_code, rx_channel, macstatus);
762753
if (tx_code)
763-
printk(KERN_WARNING "%s: host error %d on tx "
764-
"channel %d (macstatus %08x), resetting\n",
765-
dev->name, tx_code, tx_channel, macstatus);
754+
netdev_warn(dev, "host error %d on tx "
755+
"channel %d (macstatus %08x), resetting\n",
756+
tx_code, tx_channel, macstatus);
766757
}
767758

768759
netif_tx_stop_all_queues(dev);
@@ -787,8 +778,7 @@ static irqreturn_t cpmac_irq(int irq, void *dev_id)
787778
status = cpmac_read(priv->regs, CPMAC_MAC_INT_VECTOR);
788779

789780
if (unlikely(netif_msg_intr(priv)))
790-
printk(KERN_DEBUG "%s: interrupt status: 0x%08x\n", dev->name,
791-
status);
781+
netdev_dbg(dev, "interrupt status: 0x%08x\n", status);
792782

793783
if (status & MAC_INT_TX)
794784
cpmac_end_xmit(dev, (status & 7));
@@ -817,7 +807,7 @@ static void cpmac_tx_timeout(struct net_device *dev)
817807
dev->stats.tx_errors++;
818808
spin_unlock(&priv->lock);
819809
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");
821811

822812
atomic_inc(&priv->reset_pending);
823813
barrier();
@@ -953,17 +943,17 @@ static int cpmac_open(struct net_device *dev)
953943
mem = platform_get_resource_byname(priv->pdev, IORESOURCE_MEM, "regs");
954944
if (!request_mem_region(mem->start, resource_size(mem), dev->name)) {
955945
if (netif_msg_drv(priv))
956-
printk(KERN_ERR "%s: failed to request registers\n",
957-
dev->name);
946+
netdev_err(dev, "failed to request registers\n");
947+
958948
res = -ENXIO;
959949
goto fail_reserve;
960950
}
961951

962952
priv->regs = ioremap(mem->start, resource_size(mem));
963953
if (!priv->regs) {
964954
if (netif_msg_drv(priv))
965-
printk(KERN_ERR "%s: failed to remap registers\n",
966-
dev->name);
955+
netdev_err(dev, "failed to remap registers\n");
956+
967957
res = -ENXIO;
968958
goto fail_remap;
969959
}
@@ -1005,8 +995,8 @@ static int cpmac_open(struct net_device *dev)
1005995
res = request_irq(dev->irq, cpmac_irq, IRQF_SHARED, dev->name, dev);
1006996
if (res) {
1007997
if (netif_msg_drv(priv))
1008-
printk(KERN_ERR "%s: failed to obtain irq\n",
1009-
dev->name);
998+
netdev_err(dev, "failed to obtain irq\n");
999+
10101000
goto fail_irq;
10111001
}
10121002

@@ -1123,7 +1113,7 @@ static int cpmac_probe(struct platform_device *pdev)
11231113

11241114
if (phy_id == PHY_MAX_ADDR) {
11251115
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");
11271117
strncpy(mdio_bus_id, "fixed-0", MII_BUS_ID_SIZE); /* fixed phys bus */
11281118
phy_id = pdev->id;
11291119
}
@@ -1164,24 +1154,22 @@ static int cpmac_probe(struct platform_device *pdev)
11641154

11651155
if (IS_ERR(priv->phy)) {
11661156
if (netif_msg_drv(priv))
1167-
printk(KERN_ERR "%s: Could not attach to PHY\n",
1168-
dev->name);
1157+
dev_err(&pdev->dev, "Could not attach to PHY\n");
1158+
11691159
rc = PTR_ERR(priv->phy);
11701160
goto fail;
11711161
}
11721162

11731163
rc = register_netdev(dev);
11741164
if (rc) {
1175-
printk(KERN_ERR "cpmac: error %i registering device %s\n", rc,
1176-
dev->name);
1165+
dev_err(&pdev->dev, "Could not register net device\n");
11771166
goto fail;
11781167
}
11791168

11801169
if (netif_msg_probe(priv)) {
1181-
printk(KERN_INFO
1182-
"cpmac: device %s (regs: %p, irq: %d, phy: %s, "
1183-
"mac: %pM)\n", dev->name, (void *)mem->start, dev->irq,
1184-
priv->phy_name, dev->dev_addr);
1170+
dev_info(&pdev->dev, "regs: %p, irq: %d, phy: %s, "
1171+
"mac: %pM\n", (void *)mem->start, dev->irq,
1172+
priv->phy_name, dev->dev_addr);
11851173
}
11861174
return 0;
11871175

@@ -1223,7 +1211,7 @@ int cpmac_init(void)
12231211
cpmac_mii->priv = ioremap(AR7_REGS_MDIO, 256);
12241212

12251213
if (!cpmac_mii->priv) {
1226-
printk(KERN_ERR "Can't ioremap mdio registers\n");
1214+
pr_err("Can't ioremap mdio registers\n");
12271215
res = -ENXIO;
12281216
goto fail_alloc;
12291217
}

0 commit comments

Comments
 (0)