aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/ks8851.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/net/ks8851.c')
-rw-r--r--drivers/net/ks8851.c88
1 files changed, 39 insertions, 49 deletions
diff --git a/drivers/net/ks8851.c b/drivers/net/ks8851.c
index 13cc1ca261d..66be4e449f0 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
@@ -1185,17 +1175,17 @@ static int ks8851_read_selftest(struct ks8851_net *ks)
1185 rd = ks8851_rdreg16(ks, KS_MBIR); 1175 rd = ks8851_rdreg16(ks, KS_MBIR);
1186 1176
1187 if ((rd & both_done) != both_done) { 1177 if ((rd & both_done) != both_done) {
1188 ks_warn(ks, "Memory selftest not finished\n"); 1178 netdev_warn(ks->netdev, "Memory selftest not finished\n");
1189 return 0; 1179 return 0;
1190 } 1180 }
1191 1181
1192 if (rd & MBIR_TXMBFA) { 1182 if (rd & MBIR_TXMBFA) {
1193 ks_err(ks, "TX memory selftest fail\n"); 1183 netdev_err(ks->netdev, "TX memory selftest fail\n");
1194 ret |= 1; 1184 ret |= 1;
1195 } 1185 }
1196 1186
1197 if (rd & MBIR_RXMBFA) { 1187 if (rd & MBIR_RXMBFA) {
1198 ks_err(ks, "RX memory selftest fail\n"); 1188 netdev_err(ks->netdev, "RX memory selftest fail\n");
1199 ret |= 2; 1189 ret |= 2;
1200 } 1190 }
1201 1191
@@ -1293,9 +1283,9 @@ static int __devinit ks8851_probe(struct spi_device *spi)
1293 goto err_netdev; 1283 goto err_netdev;
1294 } 1284 }
1295 1285
1296 dev_info(&spi->dev, "revision %d, MAC %pM, IRQ %d\n", 1286 netdev_info(ndev, "revision %d, MAC %pM, IRQ %d\n",
1297 CIDER_REV_GET(ks8851_rdreg16(ks, KS_CIDER)), 1287 CIDER_REV_GET(ks8851_rdreg16(ks, KS_CIDER)),
1298 ndev->dev_addr, ndev->irq); 1288 ndev->dev_addr, ndev->irq);
1299 1289
1300 return 0; 1290 return 0;
1301 1291
@@ -1314,7 +1304,7 @@ static int __devexit ks8851_remove(struct spi_device *spi)
1314 struct ks8851_net *priv = dev_get_drvdata(&spi->dev); 1304 struct ks8851_net *priv = dev_get_drvdata(&spi->dev);
1315 1305
1316 if (netif_msg_drv(priv)) 1306 if (netif_msg_drv(priv))
1317 dev_info(&spi->dev, "remove"); 1307 dev_info(&spi->dev, "remove\n");
1318 1308
1319 unregister_netdev(priv->netdev); 1309 unregister_netdev(priv->netdev);
1320 free_irq(spi->irq, priv); 1310 free_irq(spi->irq, priv);