diff options
author | Joe Perches <joe@perches.com> | 2010-02-27 09:43:51 -0500 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2010-03-17 00:23:25 -0400 |
commit | 0dc7d2b3cbfcf4ff20bdc68f563a2e52e6a2178f (patch) | |
tree | 9f81abd6d5d494230a4d23b1a27f399f5832f9e7 /drivers/net/ks8851.c | |
parent | ca50910185fcce694af0cc194de50d2374a7c7ef (diff) |
drivers/net/ks*: Use netdev_<level>, netif_<level> and pr_<level>
I'm not sure this is correct.
It changes logging macros from:
dev_<level>(&ks->spidev->dev,
to
netdev_<level>(ks->netdev,
Comments?
Use netdev_<level>
Use netif_<level>
Use pr_<level>
Add #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
Add missing line to message in ks8851_remove
Change kmalloc/memset(,0) to kzalloc
Remove ks_<level> macros
Consolidation code into set_media_state
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'drivers/net/ks8851.c')
-rw-r--r-- | drivers/net/ks8851.c | 88 |
1 files changed, 39 insertions, 49 deletions
diff --git a/drivers/net/ks8851.c b/drivers/net/ks8851.c index 0573e0bb4444..6f414824caf7 100644 --- a/drivers/net/ks8851.c +++ b/drivers/net/ks8851.c | |||
@@ -9,6 +9,8 @@ | |||
9 | * published by the Free Software Foundation. | 9 | * published by the Free Software Foundation. |
10 | */ | 10 | */ |
11 | 11 | ||
12 | #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt | ||
13 | |||
12 | #define DEBUG | 14 | #define DEBUG |
13 | 15 | ||
14 | #include <linux/module.h> | 16 | #include <linux/module.h> |
@@ -125,11 +127,6 @@ struct ks8851_net { | |||
125 | 127 | ||
126 | static int msg_enable; | 128 | static int msg_enable; |
127 | 129 | ||
128 | #define ks_info(_ks, _msg...) dev_info(&(_ks)->spidev->dev, _msg) | ||
129 | #define ks_warn(_ks, _msg...) dev_warn(&(_ks)->spidev->dev, _msg) | ||
130 | #define ks_dbg(_ks, _msg...) dev_dbg(&(_ks)->spidev->dev, _msg) | ||
131 | #define ks_err(_ks, _msg...) dev_err(&(_ks)->spidev->dev, _msg) | ||
132 | |||
133 | /* shift for byte-enable data */ | 130 | /* shift for byte-enable data */ |
134 | #define BYTE_EN(_x) ((_x) << 2) | 131 | #define BYTE_EN(_x) ((_x) << 2) |
135 | 132 | ||
@@ -167,7 +164,7 @@ static void ks8851_wrreg16(struct ks8851_net *ks, unsigned reg, unsigned val) | |||
167 | 164 | ||
168 | ret = spi_sync(ks->spidev, msg); | 165 | ret = spi_sync(ks->spidev, msg); |
169 | if (ret < 0) | 166 | if (ret < 0) |
170 | ks_err(ks, "spi_sync() failed\n"); | 167 | netdev_err(ks->netdev, "spi_sync() failed\n"); |
171 | } | 168 | } |
172 | 169 | ||
173 | /** | 170 | /** |
@@ -197,7 +194,7 @@ static void ks8851_wrreg8(struct ks8851_net *ks, unsigned reg, unsigned val) | |||
197 | 194 | ||
198 | ret = spi_sync(ks->spidev, msg); | 195 | ret = spi_sync(ks->spidev, msg); |
199 | if (ret < 0) | 196 | if (ret < 0) |
200 | ks_err(ks, "spi_sync() failed\n"); | 197 | netdev_err(ks->netdev, "spi_sync() failed\n"); |
201 | } | 198 | } |
202 | 199 | ||
203 | /** | 200 | /** |
@@ -263,7 +260,7 @@ static void ks8851_rdreg(struct ks8851_net *ks, unsigned op, | |||
263 | 260 | ||
264 | ret = spi_sync(ks->spidev, msg); | 261 | ret = spi_sync(ks->spidev, msg); |
265 | if (ret < 0) | 262 | if (ret < 0) |
266 | ks_err(ks, "read: spi_sync() failed\n"); | 263 | netdev_err(ks->netdev, "read: spi_sync() failed\n"); |
267 | else if (ks8851_rx_1msg(ks)) | 264 | else if (ks8851_rx_1msg(ks)) |
268 | memcpy(rxb, trx + 2, rxl); | 265 | memcpy(rxb, trx + 2, rxl); |
269 | else | 266 | else |
@@ -417,8 +414,8 @@ static void ks8851_rdfifo(struct ks8851_net *ks, u8 *buff, unsigned len) | |||
417 | u8 txb[1]; | 414 | u8 txb[1]; |
418 | int ret; | 415 | int ret; |
419 | 416 | ||
420 | if (netif_msg_rx_status(ks)) | 417 | netif_dbg(ks, rx_status, ks->netdev, |
421 | ks_dbg(ks, "%s: %d@%p\n", __func__, len, buff); | 418 | "%s: %d@%p\n", __func__, len, buff); |
422 | 419 | ||
423 | /* set the operation we're issuing */ | 420 | /* set the operation we're issuing */ |
424 | txb[0] = KS_SPIOP_RXFIFO; | 421 | txb[0] = KS_SPIOP_RXFIFO; |
@@ -434,7 +431,7 @@ static void ks8851_rdfifo(struct ks8851_net *ks, u8 *buff, unsigned len) | |||
434 | 431 | ||
435 | ret = spi_sync(ks->spidev, msg); | 432 | ret = spi_sync(ks->spidev, msg); |
436 | if (ret < 0) | 433 | if (ret < 0) |
437 | ks_err(ks, "%s: spi_sync() failed\n", __func__); | 434 | netdev_err(ks->netdev, "%s: spi_sync() failed\n", __func__); |
438 | } | 435 | } |
439 | 436 | ||
440 | /** | 437 | /** |
@@ -446,10 +443,11 @@ static void ks8851_rdfifo(struct ks8851_net *ks, u8 *buff, unsigned len) | |||
446 | */ | 443 | */ |
447 | static void ks8851_dbg_dumpkkt(struct ks8851_net *ks, u8 *rxpkt) | 444 | static void ks8851_dbg_dumpkkt(struct ks8851_net *ks, u8 *rxpkt) |
448 | { | 445 | { |
449 | ks_dbg(ks, "pkt %02x%02x%02x%02x %02x%02x%02x%02x %02x%02x%02x%02x\n", | 446 | netdev_dbg(ks->netdev, |
450 | rxpkt[4], rxpkt[5], rxpkt[6], rxpkt[7], | 447 | "pkt %02x%02x%02x%02x %02x%02x%02x%02x %02x%02x%02x%02x\n", |
451 | rxpkt[8], rxpkt[9], rxpkt[10], rxpkt[11], | 448 | rxpkt[4], rxpkt[5], rxpkt[6], rxpkt[7], |
452 | rxpkt[12], rxpkt[13], rxpkt[14], rxpkt[15]); | 449 | rxpkt[8], rxpkt[9], rxpkt[10], rxpkt[11], |
450 | rxpkt[12], rxpkt[13], rxpkt[14], rxpkt[15]); | ||
453 | } | 451 | } |
454 | 452 | ||
455 | /** | 453 | /** |
@@ -471,8 +469,8 @@ static void ks8851_rx_pkts(struct ks8851_net *ks) | |||
471 | 469 | ||
472 | rxfc = ks8851_rdreg8(ks, KS_RXFC); | 470 | rxfc = ks8851_rdreg8(ks, KS_RXFC); |
473 | 471 | ||
474 | if (netif_msg_rx_status(ks)) | 472 | netif_dbg(ks, rx_status, ks->netdev, |
475 | ks_dbg(ks, "%s: %d packets\n", __func__, rxfc); | 473 | "%s: %d packets\n", __func__, rxfc); |
476 | 474 | ||
477 | /* Currently we're issuing a read per packet, but we could possibly | 475 | /* Currently we're issuing a read per packet, but we could possibly |
478 | * improve the code by issuing a single read, getting the receive | 476 | * improve the code by issuing a single read, getting the receive |
@@ -489,9 +487,8 @@ static void ks8851_rx_pkts(struct ks8851_net *ks) | |||
489 | rxstat = rxh & 0xffff; | 487 | rxstat = rxh & 0xffff; |
490 | rxlen = rxh >> 16; | 488 | rxlen = rxh >> 16; |
491 | 489 | ||
492 | if (netif_msg_rx_status(ks)) | 490 | netif_dbg(ks, rx_status, ks->netdev, |
493 | ks_dbg(ks, "rx: stat 0x%04x, len 0x%04x\n", | 491 | "rx: stat 0x%04x, len 0x%04x\n", rxstat, rxlen); |
494 | rxstat, rxlen); | ||
495 | 492 | ||
496 | /* the length of the packet includes the 32bit CRC */ | 493 | /* the length of the packet includes the 32bit CRC */ |
497 | 494 | ||
@@ -553,9 +550,8 @@ static void ks8851_irq_work(struct work_struct *work) | |||
553 | 550 | ||
554 | status = ks8851_rdreg16(ks, KS_ISR); | 551 | status = ks8851_rdreg16(ks, KS_ISR); |
555 | 552 | ||
556 | if (netif_msg_intr(ks)) | 553 | netif_dbg(ks, intr, ks->netdev, |
557 | dev_dbg(&ks->spidev->dev, "%s: status 0x%04x\n", | 554 | "%s: status 0x%04x\n", __func__, status); |
558 | __func__, status); | ||
559 | 555 | ||
560 | if (status & IRQ_LCI) { | 556 | if (status & IRQ_LCI) { |
561 | /* should do something about checking link status */ | 557 | /* should do something about checking link status */ |
@@ -582,8 +578,8 @@ static void ks8851_irq_work(struct work_struct *work) | |||
582 | * system */ | 578 | * system */ |
583 | ks->tx_space = ks8851_rdreg16(ks, KS_TXMIR); | 579 | ks->tx_space = ks8851_rdreg16(ks, KS_TXMIR); |
584 | 580 | ||
585 | if (netif_msg_intr(ks)) | 581 | netif_dbg(ks, intr, ks->netdev, |
586 | ks_dbg(ks, "%s: txspace %d\n", __func__, ks->tx_space); | 582 | "%s: txspace %d\n", __func__, ks->tx_space); |
587 | } | 583 | } |
588 | 584 | ||
589 | if (status & IRQ_RXI) | 585 | if (status & IRQ_RXI) |
@@ -659,9 +655,8 @@ static void ks8851_wrpkt(struct ks8851_net *ks, struct sk_buff *txp, bool irq) | |||
659 | unsigned fid = 0; | 655 | unsigned fid = 0; |
660 | int ret; | 656 | int ret; |
661 | 657 | ||
662 | if (netif_msg_tx_queued(ks)) | 658 | netif_dbg(ks, tx_queued, ks->netdev, "%s: skb %p, %d@%p, irq %d\n", |
663 | dev_dbg(&ks->spidev->dev, "%s: skb %p, %d@%p, irq %d\n", | 659 | __func__, txp, txp->len, txp->data, irq); |
664 | __func__, txp, txp->len, txp->data, irq); | ||
665 | 660 | ||
666 | fid = ks->fid++; | 661 | fid = ks->fid++; |
667 | fid &= TXFR_TXFID_MASK; | 662 | fid &= TXFR_TXFID_MASK; |
@@ -685,7 +680,7 @@ static void ks8851_wrpkt(struct ks8851_net *ks, struct sk_buff *txp, bool irq) | |||
685 | 680 | ||
686 | ret = spi_sync(ks->spidev, msg); | 681 | ret = spi_sync(ks->spidev, msg); |
687 | if (ret < 0) | 682 | if (ret < 0) |
688 | ks_err(ks, "%s: spi_sync() failed\n", __func__); | 683 | netdev_err(ks->netdev, "%s: spi_sync() failed\n", __func__); |
689 | } | 684 | } |
690 | 685 | ||
691 | /** | 686 | /** |
@@ -744,8 +739,7 @@ static void ks8851_set_powermode(struct ks8851_net *ks, unsigned pwrmode) | |||
744 | { | 739 | { |
745 | unsigned pmecr; | 740 | unsigned pmecr; |
746 | 741 | ||
747 | if (netif_msg_hw(ks)) | 742 | netif_dbg(ks, hw, ks->netdev, "setting power mode %d\n", pwrmode); |
748 | ks_dbg(ks, "setting power mode %d\n", pwrmode); | ||
749 | 743 | ||
750 | pmecr = ks8851_rdreg16(ks, KS_PMECR); | 744 | pmecr = ks8851_rdreg16(ks, KS_PMECR); |
751 | pmecr &= ~PMECR_PM_MASK; | 745 | pmecr &= ~PMECR_PM_MASK; |
@@ -769,8 +763,7 @@ static int ks8851_net_open(struct net_device *dev) | |||
769 | * else at the moment */ | 763 | * else at the moment */ |
770 | mutex_lock(&ks->lock); | 764 | mutex_lock(&ks->lock); |
771 | 765 | ||
772 | if (netif_msg_ifup(ks)) | 766 | netif_dbg(ks, ifup, ks->netdev, "opening\n"); |
773 | ks_dbg(ks, "opening %s\n", dev->name); | ||
774 | 767 | ||
775 | /* bring chip out of any power saving mode it was in */ | 768 | /* bring chip out of any power saving mode it was in */ |
776 | ks8851_set_powermode(ks, PMECR_PM_NORMAL); | 769 | ks8851_set_powermode(ks, PMECR_PM_NORMAL); |
@@ -826,8 +819,7 @@ static int ks8851_net_open(struct net_device *dev) | |||
826 | 819 | ||
827 | netif_start_queue(ks->netdev); | 820 | netif_start_queue(ks->netdev); |
828 | 821 | ||
829 | if (netif_msg_ifup(ks)) | 822 | netif_dbg(ks, ifup, ks->netdev, "network device up\n"); |
830 | ks_dbg(ks, "network device %s up\n", dev->name); | ||
831 | 823 | ||
832 | mutex_unlock(&ks->lock); | 824 | mutex_unlock(&ks->lock); |
833 | return 0; | 825 | return 0; |
@@ -845,8 +837,7 @@ static int ks8851_net_stop(struct net_device *dev) | |||
845 | { | 837 | { |
846 | struct ks8851_net *ks = netdev_priv(dev); | 838 | struct ks8851_net *ks = netdev_priv(dev); |
847 | 839 | ||
848 | if (netif_msg_ifdown(ks)) | 840 | netif_info(ks, ifdown, dev, "shutting down\n"); |
849 | ks_info(ks, "%s: shutting down\n", dev->name); | ||
850 | 841 | ||
851 | netif_stop_queue(dev); | 842 | netif_stop_queue(dev); |
852 | 843 | ||
@@ -874,8 +865,8 @@ static int ks8851_net_stop(struct net_device *dev) | |||
874 | while (!skb_queue_empty(&ks->txq)) { | 865 | while (!skb_queue_empty(&ks->txq)) { |
875 | struct sk_buff *txb = skb_dequeue(&ks->txq); | 866 | struct sk_buff *txb = skb_dequeue(&ks->txq); |
876 | 867 | ||
877 | if (netif_msg_ifdown(ks)) | 868 | netif_dbg(ks, ifdown, ks->netdev, |
878 | ks_dbg(ks, "%s: freeing txb %p\n", __func__, txb); | 869 | "%s: freeing txb %p\n", __func__, txb); |
879 | 870 | ||
880 | dev_kfree_skb(txb); | 871 | dev_kfree_skb(txb); |
881 | } | 872 | } |
@@ -904,9 +895,8 @@ static netdev_tx_t ks8851_start_xmit(struct sk_buff *skb, | |||
904 | unsigned needed = calc_txlen(skb->len); | 895 | unsigned needed = calc_txlen(skb->len); |
905 | netdev_tx_t ret = NETDEV_TX_OK; | 896 | netdev_tx_t ret = NETDEV_TX_OK; |
906 | 897 | ||
907 | if (netif_msg_tx_queued(ks)) | 898 | netif_dbg(ks, tx_queued, ks->netdev, |
908 | ks_dbg(ks, "%s: skb %p, %d@%p\n", __func__, | 899 | "%s: skb %p, %d@%p\n", __func__, skb, skb->len, skb->data); |
909 | skb, skb->len, skb->data); | ||
910 | 900 | ||
911 | spin_lock(&ks->statelock); | 901 | spin_lock(&ks->statelock); |
912 | 902 | ||
@@ -1186,17 +1176,17 @@ static int ks8851_read_selftest(struct ks8851_net *ks) | |||
1186 | rd = ks8851_rdreg16(ks, KS_MBIR); | 1176 | rd = ks8851_rdreg16(ks, KS_MBIR); |
1187 | 1177 | ||
1188 | if ((rd & both_done) != both_done) { | 1178 | if ((rd & both_done) != both_done) { |
1189 | ks_warn(ks, "Memory selftest not finished\n"); | 1179 | netdev_warn(ks->netdev, "Memory selftest not finished\n"); |
1190 | return 0; | 1180 | return 0; |
1191 | } | 1181 | } |
1192 | 1182 | ||
1193 | if (rd & MBIR_TXMBFA) { | 1183 | if (rd & MBIR_TXMBFA) { |
1194 | ks_err(ks, "TX memory selftest fail\n"); | 1184 | netdev_err(ks->netdev, "TX memory selftest fail\n"); |
1195 | ret |= 1; | 1185 | ret |= 1; |
1196 | } | 1186 | } |
1197 | 1187 | ||
1198 | if (rd & MBIR_RXMBFA) { | 1188 | if (rd & MBIR_RXMBFA) { |
1199 | ks_err(ks, "RX memory selftest fail\n"); | 1189 | netdev_err(ks->netdev, "RX memory selftest fail\n"); |
1200 | ret |= 2; | 1190 | ret |= 2; |
1201 | } | 1191 | } |
1202 | 1192 | ||
@@ -1294,9 +1284,9 @@ static int __devinit ks8851_probe(struct spi_device *spi) | |||
1294 | goto err_netdev; | 1284 | goto err_netdev; |
1295 | } | 1285 | } |
1296 | 1286 | ||
1297 | dev_info(&spi->dev, "revision %d, MAC %pM, IRQ %d\n", | 1287 | netdev_info(ndev, "revision %d, MAC %pM, IRQ %d\n", |
1298 | CIDER_REV_GET(ks8851_rdreg16(ks, KS_CIDER)), | 1288 | CIDER_REV_GET(ks8851_rdreg16(ks, KS_CIDER)), |
1299 | ndev->dev_addr, ndev->irq); | 1289 | ndev->dev_addr, ndev->irq); |
1300 | 1290 | ||
1301 | return 0; | 1291 | return 0; |
1302 | 1292 | ||
@@ -1315,7 +1305,7 @@ static int __devexit ks8851_remove(struct spi_device *spi) | |||
1315 | struct ks8851_net *priv = dev_get_drvdata(&spi->dev); | 1305 | struct ks8851_net *priv = dev_get_drvdata(&spi->dev); |
1316 | 1306 | ||
1317 | if (netif_msg_drv(priv)) | 1307 | if (netif_msg_drv(priv)) |
1318 | dev_info(&spi->dev, "remove"); | 1308 | dev_info(&spi->dev, "remove\n"); |
1319 | 1309 | ||
1320 | unregister_netdev(priv->netdev); | 1310 | unregister_netdev(priv->netdev); |
1321 | free_irq(spi->irq, priv); | 1311 | free_irq(spi->irq, priv); |