aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net
diff options
context:
space:
mode:
authorJoe Perches <joe@perches.com>2010-02-27 09:43:51 -0500
committerDavid S. Miller <davem@davemloft.net>2010-03-17 00:23:25 -0400
commit0dc7d2b3cbfcf4ff20bdc68f563a2e52e6a2178f (patch)
tree9f81abd6d5d494230a4d23b1a27f399f5832f9e7 /drivers/net
parentca50910185fcce694af0cc194de50d2374a7c7ef (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')
-rw-r--r--drivers/net/ks8842.c8
-rw-r--r--drivers/net/ks8851.c88
-rw-r--r--drivers/net/ks8851_mll.c50
-rw-r--r--drivers/net/ksz884x.c65
4 files changed, 91 insertions, 120 deletions
diff --git a/drivers/net/ks8842.c b/drivers/net/ks8842.c
index 5c45cb58d02..b91492f4e48 100644
--- a/drivers/net/ks8842.c
+++ b/drivers/net/ks8842.c
@@ -20,6 +20,8 @@
20 * The Micrel KS8842 behind the timberdale FPGA 20 * The Micrel KS8842 behind the timberdale FPGA
21 */ 21 */
22 22
23#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
24
23#include <linux/kernel.h> 25#include <linux/kernel.h>
24#include <linux/module.h> 26#include <linux/module.h>
25#include <linux/platform_device.h> 27#include <linux/platform_device.h>
@@ -525,8 +527,7 @@ static int ks8842_open(struct net_device *netdev)
525 err = request_irq(adapter->irq, ks8842_irq, IRQF_SHARED, DRV_NAME, 527 err = request_irq(adapter->irq, ks8842_irq, IRQF_SHARED, DRV_NAME,
526 adapter); 528 adapter);
527 if (err) { 529 if (err) {
528 printk(KERN_ERR "Failed to request IRQ: %d: %d\n", 530 pr_err("Failed to request IRQ: %d: %d\n", adapter->irq, err);
529 adapter->irq, err);
530 return err; 531 return err;
531 } 532 }
532 533
@@ -668,8 +669,7 @@ static int __devinit ks8842_probe(struct platform_device *pdev)
668 669
669 platform_set_drvdata(pdev, netdev); 670 platform_set_drvdata(pdev, netdev);
670 671
671 printk(KERN_INFO DRV_NAME 672 pr_info("Found chip, family: 0x%x, id: 0x%x, rev: 0x%x\n",
672 " Found chip, family: 0x%x, id: 0x%x, rev: 0x%x\n",
673 (id >> 8) & 0xff, (id >> 4) & 0xf, (id >> 1) & 0x7); 673 (id >> 8) & 0xff, (id >> 4) & 0xf, (id >> 1) & 0x7);
674 674
675 return 0; 675 return 0;
diff --git a/drivers/net/ks8851.c b/drivers/net/ks8851.c
index 0573e0bb444..6f414824caf 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
126static int msg_enable; 128static 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*/
447static void ks8851_dbg_dumpkkt(struct ks8851_net *ks, u8 *rxpkt) 444static 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);
diff --git a/drivers/net/ks8851_mll.c b/drivers/net/ks8851_mll.c
index 84b0e15831f..d3c6a77f7ec 100644
--- a/drivers/net/ks8851_mll.c
+++ b/drivers/net/ks8851_mll.c
@@ -21,6 +21,8 @@
21 * KS8851 16bit MLL chip from Micrel Inc. 21 * KS8851 16bit MLL chip from Micrel Inc.
22 */ 22 */
23 23
24#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
25
24#include <linux/module.h> 26#include <linux/module.h>
25#include <linux/kernel.h> 27#include <linux/kernel.h>
26#include <linux/netdevice.h> 28#include <linux/netdevice.h>
@@ -458,11 +460,6 @@ struct ks_net {
458 460
459static int msg_enable; 461static int msg_enable;
460 462
461#define ks_info(_ks, _msg...) dev_info(&(_ks)->pdev->dev, _msg)
462#define ks_warn(_ks, _msg...) dev_warn(&(_ks)->pdev->dev, _msg)
463#define ks_dbg(_ks, _msg...) dev_dbg(&(_ks)->pdev->dev, _msg)
464#define ks_err(_ks, _msg...) dev_err(&(_ks)->pdev->dev, _msg)
465
466#define BE3 0x8000 /* Byte Enable 3 */ 463#define BE3 0x8000 /* Byte Enable 3 */
467#define BE2 0x4000 /* Byte Enable 2 */ 464#define BE2 0x4000 /* Byte Enable 2 */
468#define BE1 0x2000 /* Byte Enable 1 */ 465#define BE1 0x2000 /* Byte Enable 1 */
@@ -624,8 +621,7 @@ static void ks_set_powermode(struct ks_net *ks, unsigned pwrmode)
624{ 621{
625 unsigned pmecr; 622 unsigned pmecr;
626 623
627 if (netif_msg_hw(ks)) 624 netif_dbg(ks, hw, ks->netdev, "setting power mode %d\n", pwrmode);
628 ks_dbg(ks, "setting power mode %d\n", pwrmode);
629 625
630 ks_rdreg16(ks, KS_GRR); 626 ks_rdreg16(ks, KS_GRR);
631 pmecr = ks_rdreg16(ks, KS_PMECR); 627 pmecr = ks_rdreg16(ks, KS_PMECR);
@@ -809,7 +805,7 @@ static void ks_rcv(struct ks_net *ks, struct net_device *netdev)
809 skb->protocol = eth_type_trans(skb, netdev); 805 skb->protocol = eth_type_trans(skb, netdev);
810 netif_rx(skb); 806 netif_rx(skb);
811 } else { 807 } else {
812 printk(KERN_ERR "%s: err:skb alloc\n", __func__); 808 pr_err("%s: err:skb alloc\n", __func__);
813 ks_wrreg16(ks, KS_RXQCR, (ks->rc_rxqcr | RXQCR_RRXEF)); 809 ks_wrreg16(ks, KS_RXQCR, (ks->rc_rxqcr | RXQCR_RRXEF));
814 if (skb) 810 if (skb)
815 dev_kfree_skb_irq(skb); 811 dev_kfree_skb_irq(skb);
@@ -836,9 +832,8 @@ static void ks_update_link_status(struct net_device *netdev, struct ks_net *ks)
836 netif_carrier_off(netdev); 832 netif_carrier_off(netdev);
837 link_up_status = false; 833 link_up_status = false;
838 } 834 }
839 if (netif_msg_link(ks)) 835 netif_dbg(ks, link, ks->netdev,
840 ks_dbg(ks, "%s: %s\n", 836 "%s: %s\n", __func__, link_up_status ? "UP" : "DOWN");
841 __func__, link_up_status ? "UP" : "DOWN");
842} 837}
843 838
844/** 839/**
@@ -908,15 +903,13 @@ static int ks_net_open(struct net_device *netdev)
908 * else at the moment. 903 * else at the moment.
909 */ 904 */
910 905
911 if (netif_msg_ifup(ks)) 906 netif_dbg(ks, ifup, ks->netdev, "%s - entry\n", __func__);
912 ks_dbg(ks, "%s - entry\n", __func__);
913 907
914 /* reset the HW */ 908 /* reset the HW */
915 err = request_irq(ks->irq, ks_irq, KS_INT_FLAGS, DRV_NAME, netdev); 909 err = request_irq(ks->irq, ks_irq, KS_INT_FLAGS, DRV_NAME, netdev);
916 910
917 if (err) { 911 if (err) {
918 printk(KERN_ERR "Failed to request IRQ: %d: %d\n", 912 pr_err("Failed to request IRQ: %d: %d\n", ks->irq, err);
919 ks->irq, err);
920 return err; 913 return err;
921 } 914 }
922 915
@@ -929,8 +922,7 @@ static int ks_net_open(struct net_device *netdev)
929 ks_enable_qmu(ks); 922 ks_enable_qmu(ks);
930 netif_start_queue(ks->netdev); 923 netif_start_queue(ks->netdev);
931 924
932 if (netif_msg_ifup(ks)) 925 netif_dbg(ks, ifup, ks->netdev, "network device up\n");
933 ks_dbg(ks, "network device %s up\n", netdev->name);
934 926
935 return 0; 927 return 0;
936} 928}
@@ -947,8 +939,7 @@ static int ks_net_stop(struct net_device *netdev)
947{ 939{
948 struct ks_net *ks = netdev_priv(netdev); 940 struct ks_net *ks = netdev_priv(netdev);
949 941
950 if (netif_msg_ifdown(ks)) 942 netif_info(ks, ifdown, netdev, "shutting down\n");
951 ks_info(ks, "%s: shutting down\n", netdev->name);
952 943
953 netif_stop_queue(netdev); 944 netif_stop_queue(netdev);
954 945
@@ -1429,21 +1420,21 @@ static int ks_read_selftest(struct ks_net *ks)
1429 rd = ks_rdreg16(ks, KS_MBIR); 1420 rd = ks_rdreg16(ks, KS_MBIR);
1430 1421
1431 if ((rd & both_done) != both_done) { 1422 if ((rd & both_done) != both_done) {
1432 ks_warn(ks, "Memory selftest not finished\n"); 1423 netdev_warn(ks->netdev, "Memory selftest not finished\n");
1433 return 0; 1424 return 0;
1434 } 1425 }
1435 1426
1436 if (rd & MBIR_TXMBFA) { 1427 if (rd & MBIR_TXMBFA) {
1437 ks_err(ks, "TX memory selftest fails\n"); 1428 netdev_err(ks->netdev, "TX memory selftest fails\n");
1438 ret |= 1; 1429 ret |= 1;
1439 } 1430 }
1440 1431
1441 if (rd & MBIR_RXMBFA) { 1432 if (rd & MBIR_RXMBFA) {
1442 ks_err(ks, "RX memory selftest fails\n"); 1433 netdev_err(ks->netdev, "RX memory selftest fails\n");
1443 ret |= 2; 1434 ret |= 2;
1444 } 1435 }
1445 1436
1446 ks_info(ks, "the selftest passes\n"); 1437 netdev_info(ks->netdev, "the selftest passes\n");
1447 return ret; 1438 return ret;
1448} 1439}
1449 1440
@@ -1514,7 +1505,7 @@ static int ks_hw_init(struct ks_net *ks)
1514 ks->frame_head_info = (struct type_frame_head *) \ 1505 ks->frame_head_info = (struct type_frame_head *) \
1515 kmalloc(MHEADER_SIZE, GFP_KERNEL); 1506 kmalloc(MHEADER_SIZE, GFP_KERNEL);
1516 if (!ks->frame_head_info) { 1507 if (!ks->frame_head_info) {
1517 printk(KERN_ERR "Error: Fail to allocate frame memory\n"); 1508 pr_err("Error: Fail to allocate frame memory\n");
1518 return false; 1509 return false;
1519 } 1510 }
1520 1511
@@ -1580,7 +1571,7 @@ static int __devinit ks8851_probe(struct platform_device *pdev)
1580 ks->mii.mdio_read = ks_phy_read; 1571 ks->mii.mdio_read = ks_phy_read;
1581 ks->mii.mdio_write = ks_phy_write; 1572 ks->mii.mdio_write = ks_phy_write;
1582 1573
1583 ks_info(ks, "message enable is %d\n", msg_enable); 1574 netdev_info(netdev, "message enable is %d\n", msg_enable);
1584 /* set the default message enable */ 1575 /* set the default message enable */
1585 ks->msg_enable = netif_msg_init(msg_enable, (NETIF_MSG_DRV | 1576 ks->msg_enable = netif_msg_init(msg_enable, (NETIF_MSG_DRV |
1586 NETIF_MSG_PROBE | 1577 NETIF_MSG_PROBE |
@@ -1589,13 +1580,13 @@ static int __devinit ks8851_probe(struct platform_device *pdev)
1589 1580
1590 /* simple check for a valid chip being connected to the bus */ 1581 /* simple check for a valid chip being connected to the bus */
1591 if ((ks_rdreg16(ks, KS_CIDER) & ~CIDER_REV_MASK) != CIDER_ID) { 1582 if ((ks_rdreg16(ks, KS_CIDER) & ~CIDER_REV_MASK) != CIDER_ID) {
1592 ks_err(ks, "failed to read device ID\n"); 1583 netdev_err(netdev, "failed to read device ID\n");
1593 err = -ENODEV; 1584 err = -ENODEV;
1594 goto err_register; 1585 goto err_register;
1595 } 1586 }
1596 1587
1597 if (ks_read_selftest(ks)) { 1588 if (ks_read_selftest(ks)) {
1598 ks_err(ks, "failed to read device ID\n"); 1589 netdev_err(netdev, "failed to read device ID\n");
1599 err = -ENODEV; 1590 err = -ENODEV;
1600 goto err_register; 1591 goto err_register;
1601 } 1592 }
@@ -1626,9 +1617,8 @@ static int __devinit ks8851_probe(struct platform_device *pdev)
1626 1617
1627 id = ks_rdreg16(ks, KS_CIDER); 1618 id = ks_rdreg16(ks, KS_CIDER);
1628 1619
1629 printk(KERN_INFO DRV_NAME 1620 netdev_info(netdev, "Found chip, family: 0x%x, id: 0x%x, rev: 0x%x\n",
1630 " Found chip, family: 0x%x, id: 0x%x, rev: 0x%x\n", 1621 (id >> 8) & 0xff, (id >> 4) & 0xf, (id >> 1) & 0x7);
1631 (id >> 8) & 0xff, (id >> 4) & 0xf, (id >> 1) & 0x7);
1632 return 0; 1622 return 0;
1633 1623
1634err_register: 1624err_register:
diff --git a/drivers/net/ksz884x.c b/drivers/net/ksz884x.c
index 0f59099ee72..f3357ae13f8 100644
--- a/drivers/net/ksz884x.c
+++ b/drivers/net/ksz884x.c
@@ -14,6 +14,8 @@
14 * GNU General Public License for more details. 14 * GNU General Public License for more details.
15 */ 15 */
16 16
17#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
18
17#include <linux/init.h> 19#include <linux/init.h>
18#include <linux/kernel.h> 20#include <linux/kernel.h>
19#include <linux/module.h> 21#include <linux/module.h>
@@ -1483,11 +1485,6 @@ struct dev_priv {
1483 int promiscuous; 1485 int promiscuous;
1484}; 1486};
1485 1487
1486#define ks_info(_ks, _msg...) dev_info(&(_ks)->pdev->dev, _msg)
1487#define ks_warn(_ks, _msg...) dev_warn(&(_ks)->pdev->dev, _msg)
1488#define ks_dbg(_ks, _msg...) dev_dbg(&(_ks)->pdev->dev, _msg)
1489#define ks_err(_ks, _msg...) dev_err(&(_ks)->pdev->dev, _msg)
1490
1491#define DRV_NAME "KSZ884X PCI" 1488#define DRV_NAME "KSZ884X PCI"
1492#define DEVICE_NAME "KSZ884x PCI" 1489#define DEVICE_NAME "KSZ884x PCI"
1493#define DRV_VERSION "1.0.0" 1490#define DRV_VERSION "1.0.0"
@@ -3834,7 +3831,7 @@ static void ksz_check_desc_num(struct ksz_desc_info *info)
3834 alloc >>= 1; 3831 alloc >>= 1;
3835 } 3832 }
3836 if (alloc != 1 || shift < MIN_DESC_SHIFT) { 3833 if (alloc != 1 || shift < MIN_DESC_SHIFT) {
3837 printk(KERN_ALERT "Hardware descriptor numbers not right!\n"); 3834 pr_alert("Hardware descriptor numbers not right!\n");
3838 while (alloc) { 3835 while (alloc) {
3839 shift++; 3836 shift++;
3840 alloc >>= 1; 3837 alloc >>= 1;
@@ -4545,8 +4542,7 @@ static int ksz_alloc_mem(struct dev_info *adapter)
4545 (((sizeof(struct ksz_hw_desc) + DESC_ALIGNMENT - 1) / 4542 (((sizeof(struct ksz_hw_desc) + DESC_ALIGNMENT - 1) /
4546 DESC_ALIGNMENT) * DESC_ALIGNMENT); 4543 DESC_ALIGNMENT) * DESC_ALIGNMENT);
4547 if (hw->rx_desc_info.size != sizeof(struct ksz_hw_desc)) 4544 if (hw->rx_desc_info.size != sizeof(struct ksz_hw_desc))
4548 printk(KERN_ALERT 4545 pr_alert("Hardware descriptor size not right!\n");
4549 "Hardware descriptor size not right!\n");
4550 ksz_check_desc_num(&hw->rx_desc_info); 4546 ksz_check_desc_num(&hw->rx_desc_info);
4551 ksz_check_desc_num(&hw->tx_desc_info); 4547 ksz_check_desc_num(&hw->tx_desc_info);
4552 4548
@@ -5319,10 +5315,10 @@ static irqreturn_t netdev_intr(int irq, void *dev_id)
5319 u32 data; 5315 u32 data;
5320 5316
5321 hw->intr_mask &= ~KS884X_INT_TX_STOPPED; 5317 hw->intr_mask &= ~KS884X_INT_TX_STOPPED;
5322 printk(KERN_INFO "Tx stopped\n"); 5318 pr_info("Tx stopped\n");
5323 data = readl(hw->io + KS_DMA_TX_CTRL); 5319 data = readl(hw->io + KS_DMA_TX_CTRL);
5324 if (!(data & DMA_TX_ENABLE)) 5320 if (!(data & DMA_TX_ENABLE))
5325 printk(KERN_INFO "Tx disabled\n"); 5321 pr_info("Tx disabled\n");
5326 break; 5322 break;
5327 } 5323 }
5328 } while (0); 5324 } while (0);
@@ -5495,6 +5491,18 @@ static int prepare_hardware(struct net_device *dev)
5495 return 0; 5491 return 0;
5496} 5492}
5497 5493
5494static void set_media_state(struct net_device *dev, int media_state)
5495{
5496 struct dev_priv *priv = netdev_priv(dev);
5497
5498 if (media_state == priv->media_state)
5499 netif_carrier_on(dev);
5500 else
5501 netif_carrier_off(dev);
5502 netif_info(priv, link, dev, "link %s\n",
5503 media_state == priv->media_state ? "on" : "off");
5504}
5505
5498/** 5506/**
5499 * netdev_open - open network device 5507 * netdev_open - open network device
5500 * @dev: Network device. 5508 * @dev: Network device.
@@ -5584,15 +5592,7 @@ static int netdev_open(struct net_device *dev)
5584 5592
5585 priv->media_state = port->linked->state; 5593 priv->media_state = port->linked->state;
5586 5594
5587 if (media_connected == priv->media_state) 5595 set_media_state(dev, media_connected);
5588 netif_carrier_on(dev);
5589 else
5590 netif_carrier_off(dev);
5591 if (netif_msg_link(priv))
5592 printk(KERN_INFO "%s link %s\n", dev->name,
5593 (media_connected == priv->media_state ?
5594 "on" : "off"));
5595
5596 netif_start_queue(dev); 5596 netif_start_queue(dev);
5597 5597
5598 return 0; 5598 return 0;
@@ -6682,16 +6682,8 @@ static void update_link(struct net_device *dev, struct dev_priv *priv,
6682{ 6682{
6683 if (priv->media_state != port->linked->state) { 6683 if (priv->media_state != port->linked->state) {
6684 priv->media_state = port->linked->state; 6684 priv->media_state = port->linked->state;
6685 if (netif_running(dev)) { 6685 if (netif_running(dev))
6686 if (media_connected == priv->media_state) 6686 set_media_state(dev, media_connected);
6687 netif_carrier_on(dev);
6688 else
6689 netif_carrier_off(dev);
6690 if (netif_msg_link(priv))
6691 printk(KERN_INFO "%s link %s\n", dev->name,
6692 (media_connected == priv->media_state ?
6693 "on" : "off"));
6694 }
6695 } 6687 }
6696} 6688}
6697 6689
@@ -6985,7 +6977,7 @@ static int __init pcidev_init(struct pci_dev *pdev,
6985 int pi; 6977 int pi;
6986 int port_count; 6978 int port_count;
6987 int result; 6979 int result;
6988 char banner[80]; 6980 char banner[sizeof(version)];
6989 struct ksz_switch *sw = NULL; 6981 struct ksz_switch *sw = NULL;
6990 6982
6991 result = pci_enable_device(pdev); 6983 result = pci_enable_device(pdev);
@@ -7009,10 +7001,9 @@ static int __init pcidev_init(struct pci_dev *pdev,
7009 7001
7010 result = -ENOMEM; 7002 result = -ENOMEM;
7011 7003
7012 info = kmalloc(sizeof(struct platform_info), GFP_KERNEL); 7004 info = kzalloc(sizeof(struct platform_info), GFP_KERNEL);
7013 if (!info) 7005 if (!info)
7014 goto pcidev_init_dev_err; 7006 goto pcidev_init_dev_err;
7015 memset(info, 0, sizeof(struct platform_info));
7016 7007
7017 hw_priv = &info->dev_info; 7008 hw_priv = &info->dev_info;
7018 hw_priv->pdev = pdev; 7009 hw_priv->pdev = pdev;
@@ -7026,15 +7017,15 @@ static int __init pcidev_init(struct pci_dev *pdev,
7026 cnt = hw_init(hw); 7017 cnt = hw_init(hw);
7027 if (!cnt) { 7018 if (!cnt) {
7028 if (msg_enable & NETIF_MSG_PROBE) 7019 if (msg_enable & NETIF_MSG_PROBE)
7029 printk(KERN_ALERT "chip not detected\n"); 7020 pr_alert("chip not detected\n");
7030 result = -ENODEV; 7021 result = -ENODEV;
7031 goto pcidev_init_alloc_err; 7022 goto pcidev_init_alloc_err;
7032 } 7023 }
7033 7024
7034 sprintf(banner, "%s\n", version); 7025 snprintf(banner, sizeof(banner), "%s", version);
7035 banner[13] = cnt + '0'; 7026 banner[13] = cnt + '0'; /* Replace x in "Micrel KSZ884x" */
7036 ks_info(hw_priv, "%s", banner); 7027 dev_info(&hw_priv->pdev->dev, "%s\n", banner);
7037 ks_dbg(hw_priv, "Mem = %p; IRQ = %d\n", hw->io, pdev->irq); 7028 dev_dbg(&hw_priv->pdev->dev, "Mem = %p; IRQ = %d\n", hw->io, pdev->irq);
7038 7029
7039 /* Assume device is KSZ8841. */ 7030 /* Assume device is KSZ8841. */
7040 hw->dev_count = 1; 7031 hw->dev_count = 1;