aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/ks8851_mll.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/net/ks8851_mll.c')
-rw-r--r--drivers/net/ks8851_mll.c63
1 files changed, 25 insertions, 38 deletions
diff --git a/drivers/net/ks8851_mll.c b/drivers/net/ks8851_mll.c
index 6354ab3a45a6..2e2c69b24062 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>
@@ -361,7 +363,6 @@ static u8 KS_DEFAULT_MAC_ADDRESS[] = { 0x00, 0x10, 0xA1, 0x86, 0x95, 0x11 };
361 363
362#define MAX_MCAST_LST 32 364#define MAX_MCAST_LST 32
363#define HW_MCAST_SIZE 8 365#define HW_MCAST_SIZE 8
364#define MAC_ADDR_LEN 6
365 366
366/** 367/**
367 * union ks_tx_hdr - tx header data 368 * union ks_tx_hdr - tx header data
@@ -449,7 +450,7 @@ struct ks_net {
449 u16 promiscuous; 450 u16 promiscuous;
450 u16 all_mcast; 451 u16 all_mcast;
451 u16 mcast_lst_size; 452 u16 mcast_lst_size;
452 u8 mcast_lst[MAX_MCAST_LST][MAC_ADDR_LEN]; 453 u8 mcast_lst[MAX_MCAST_LST][ETH_ALEN];
453 u8 mcast_bits[HW_MCAST_SIZE]; 454 u8 mcast_bits[HW_MCAST_SIZE];
454 u8 mac_addr[6]; 455 u8 mac_addr[6];
455 u8 fid; 456 u8 fid;
@@ -459,11 +460,6 @@ struct ks_net {
459 460
460static int msg_enable; 461static int msg_enable;
461 462
462#define ks_info(_ks, _msg...) dev_info(&(_ks)->pdev->dev, _msg)
463#define ks_warn(_ks, _msg...) dev_warn(&(_ks)->pdev->dev, _msg)
464#define ks_dbg(_ks, _msg...) dev_dbg(&(_ks)->pdev->dev, _msg)
465#define ks_err(_ks, _msg...) dev_err(&(_ks)->pdev->dev, _msg)
466
467#define BE3 0x8000 /* Byte Enable 3 */ 463#define BE3 0x8000 /* Byte Enable 3 */
468#define BE2 0x4000 /* Byte Enable 2 */ 464#define BE2 0x4000 /* Byte Enable 2 */
469#define BE1 0x2000 /* Byte Enable 1 */ 465#define BE1 0x2000 /* Byte Enable 1 */
@@ -625,8 +621,7 @@ static void ks_set_powermode(struct ks_net *ks, unsigned pwrmode)
625{ 621{
626 unsigned pmecr; 622 unsigned pmecr;
627 623
628 if (netif_msg_hw(ks)) 624 netif_dbg(ks, hw, ks->netdev, "setting power mode %d\n", pwrmode);
629 ks_dbg(ks, "setting power mode %d\n", pwrmode);
630 625
631 ks_rdreg16(ks, KS_GRR); 626 ks_rdreg16(ks, KS_GRR);
632 pmecr = ks_rdreg16(ks, KS_PMECR); 627 pmecr = ks_rdreg16(ks, KS_PMECR);
@@ -806,11 +801,10 @@ static void ks_rcv(struct ks_net *ks, struct net_device *netdev)
806 /* read data block including CRC 4 bytes */ 801 /* read data block including CRC 4 bytes */
807 ks_read_qmu(ks, (u16 *)skb->data, frame_hdr->len); 802 ks_read_qmu(ks, (u16 *)skb->data, frame_hdr->len);
808 skb_put(skb, frame_hdr->len); 803 skb_put(skb, frame_hdr->len);
809 skb->dev = netdev;
810 skb->protocol = eth_type_trans(skb, netdev); 804 skb->protocol = eth_type_trans(skb, netdev);
811 netif_rx(skb); 805 netif_rx(skb);
812 } else { 806 } else {
813 printk(KERN_ERR "%s: err:skb alloc\n", __func__); 807 pr_err("%s: err:skb alloc\n", __func__);
814 ks_wrreg16(ks, KS_RXQCR, (ks->rc_rxqcr | RXQCR_RRXEF)); 808 ks_wrreg16(ks, KS_RXQCR, (ks->rc_rxqcr | RXQCR_RRXEF));
815 if (skb) 809 if (skb)
816 dev_kfree_skb_irq(skb); 810 dev_kfree_skb_irq(skb);
@@ -837,9 +831,8 @@ static void ks_update_link_status(struct net_device *netdev, struct ks_net *ks)
837 netif_carrier_off(netdev); 831 netif_carrier_off(netdev);
838 link_up_status = false; 832 link_up_status = false;
839 } 833 }
840 if (netif_msg_link(ks)) 834 netif_dbg(ks, link, ks->netdev,
841 ks_dbg(ks, "%s: %s\n", 835 "%s: %s\n", __func__, link_up_status ? "UP" : "DOWN");
842 __func__, link_up_status ? "UP" : "DOWN");
843} 836}
844 837
845/** 838/**
@@ -909,15 +902,13 @@ static int ks_net_open(struct net_device *netdev)
909 * else at the moment. 902 * else at the moment.
910 */ 903 */
911 904
912 if (netif_msg_ifup(ks)) 905 netif_dbg(ks, ifup, ks->netdev, "%s - entry\n", __func__);
913 ks_dbg(ks, "%s - entry\n", __func__);
914 906
915 /* reset the HW */ 907 /* reset the HW */
916 err = request_irq(ks->irq, ks_irq, KS_INT_FLAGS, DRV_NAME, netdev); 908 err = request_irq(ks->irq, ks_irq, KS_INT_FLAGS, DRV_NAME, netdev);
917 909
918 if (err) { 910 if (err) {
919 printk(KERN_ERR "Failed to request IRQ: %d: %d\n", 911 pr_err("Failed to request IRQ: %d: %d\n", ks->irq, err);
920 ks->irq, err);
921 return err; 912 return err;
922 } 913 }
923 914
@@ -930,8 +921,7 @@ static int ks_net_open(struct net_device *netdev)
930 ks_enable_qmu(ks); 921 ks_enable_qmu(ks);
931 netif_start_queue(ks->netdev); 922 netif_start_queue(ks->netdev);
932 923
933 if (netif_msg_ifup(ks)) 924 netif_dbg(ks, ifup, ks->netdev, "network device up\n");
934 ks_dbg(ks, "network device %s up\n", netdev->name);
935 925
936 return 0; 926 return 0;
937} 927}
@@ -948,8 +938,7 @@ static int ks_net_stop(struct net_device *netdev)
948{ 938{
949 struct ks_net *ks = netdev_priv(netdev); 939 struct ks_net *ks = netdev_priv(netdev);
950 940
951 if (netif_msg_ifdown(ks)) 941 netif_info(ks, ifdown, netdev, "shutting down\n");
952 ks_info(ks, "%s: shutting down\n", netdev->name);
953 942
954 netif_stop_queue(netdev); 943 netif_stop_queue(netdev);
955 944
@@ -1181,7 +1170,7 @@ static void ks_set_mcast(struct ks_net *ks, u16 mcast)
1181static void ks_set_rx_mode(struct net_device *netdev) 1170static void ks_set_rx_mode(struct net_device *netdev)
1182{ 1171{
1183 struct ks_net *ks = netdev_priv(netdev); 1172 struct ks_net *ks = netdev_priv(netdev);
1184 struct dev_mc_list *ptr; 1173 struct netdev_hw_addr *ha;
1185 1174
1186 /* Turn on/off promiscuous mode. */ 1175 /* Turn on/off promiscuous mode. */
1187 if ((netdev->flags & IFF_PROMISC) == IFF_PROMISC) 1176 if ((netdev->flags & IFF_PROMISC) == IFF_PROMISC)
@@ -1198,13 +1187,12 @@ static void ks_set_rx_mode(struct net_device *netdev)
1198 if (netdev_mc_count(netdev) <= MAX_MCAST_LST) { 1187 if (netdev_mc_count(netdev) <= MAX_MCAST_LST) {
1199 int i = 0; 1188 int i = 0;
1200 1189
1201 netdev_for_each_mc_addr(ptr, netdev) { 1190 netdev_for_each_mc_addr(ha, netdev) {
1202 if (!(*ptr->dmi_addr & 1)) 1191 if (!(*ha->addr & 1))
1203 continue; 1192 continue;
1204 if (i >= MAX_MCAST_LST) 1193 if (i >= MAX_MCAST_LST)
1205 break; 1194 break;
1206 memcpy(ks->mcast_lst[i++], ptr->dmi_addr, 1195 memcpy(ks->mcast_lst[i++], ha->addr, ETH_ALEN);
1207 MAC_ADDR_LEN);
1208 } 1196 }
1209 ks->mcast_lst_size = (u8)i; 1197 ks->mcast_lst_size = (u8)i;
1210 ks_set_grpaddr(ks); 1198 ks_set_grpaddr(ks);
@@ -1430,21 +1418,21 @@ static int ks_read_selftest(struct ks_net *ks)
1430 rd = ks_rdreg16(ks, KS_MBIR); 1418 rd = ks_rdreg16(ks, KS_MBIR);
1431 1419
1432 if ((rd & both_done) != both_done) { 1420 if ((rd & both_done) != both_done) {
1433 ks_warn(ks, "Memory selftest not finished\n"); 1421 netdev_warn(ks->netdev, "Memory selftest not finished\n");
1434 return 0; 1422 return 0;
1435 } 1423 }
1436 1424
1437 if (rd & MBIR_TXMBFA) { 1425 if (rd & MBIR_TXMBFA) {
1438 ks_err(ks, "TX memory selftest fails\n"); 1426 netdev_err(ks->netdev, "TX memory selftest fails\n");
1439 ret |= 1; 1427 ret |= 1;
1440 } 1428 }
1441 1429
1442 if (rd & MBIR_RXMBFA) { 1430 if (rd & MBIR_RXMBFA) {
1443 ks_err(ks, "RX memory selftest fails\n"); 1431 netdev_err(ks->netdev, "RX memory selftest fails\n");
1444 ret |= 2; 1432 ret |= 2;
1445 } 1433 }
1446 1434
1447 ks_info(ks, "the selftest passes\n"); 1435 netdev_info(ks->netdev, "the selftest passes\n");
1448 return ret; 1436 return ret;
1449} 1437}
1450 1438
@@ -1515,7 +1503,7 @@ static int ks_hw_init(struct ks_net *ks)
1515 ks->frame_head_info = (struct type_frame_head *) \ 1503 ks->frame_head_info = (struct type_frame_head *) \
1516 kmalloc(MHEADER_SIZE, GFP_KERNEL); 1504 kmalloc(MHEADER_SIZE, GFP_KERNEL);
1517 if (!ks->frame_head_info) { 1505 if (!ks->frame_head_info) {
1518 printk(KERN_ERR "Error: Fail to allocate frame memory\n"); 1506 pr_err("Error: Fail to allocate frame memory\n");
1519 return false; 1507 return false;
1520 } 1508 }
1521 1509
@@ -1581,7 +1569,7 @@ static int __devinit ks8851_probe(struct platform_device *pdev)
1581 ks->mii.mdio_read = ks_phy_read; 1569 ks->mii.mdio_read = ks_phy_read;
1582 ks->mii.mdio_write = ks_phy_write; 1570 ks->mii.mdio_write = ks_phy_write;
1583 1571
1584 ks_info(ks, "message enable is %d\n", msg_enable); 1572 netdev_info(netdev, "message enable is %d\n", msg_enable);
1585 /* set the default message enable */ 1573 /* set the default message enable */
1586 ks->msg_enable = netif_msg_init(msg_enable, (NETIF_MSG_DRV | 1574 ks->msg_enable = netif_msg_init(msg_enable, (NETIF_MSG_DRV |
1587 NETIF_MSG_PROBE | 1575 NETIF_MSG_PROBE |
@@ -1590,13 +1578,13 @@ static int __devinit ks8851_probe(struct platform_device *pdev)
1590 1578
1591 /* simple check for a valid chip being connected to the bus */ 1579 /* simple check for a valid chip being connected to the bus */
1592 if ((ks_rdreg16(ks, KS_CIDER) & ~CIDER_REV_MASK) != CIDER_ID) { 1580 if ((ks_rdreg16(ks, KS_CIDER) & ~CIDER_REV_MASK) != CIDER_ID) {
1593 ks_err(ks, "failed to read device ID\n"); 1581 netdev_err(netdev, "failed to read device ID\n");
1594 err = -ENODEV; 1582 err = -ENODEV;
1595 goto err_register; 1583 goto err_register;
1596 } 1584 }
1597 1585
1598 if (ks_read_selftest(ks)) { 1586 if (ks_read_selftest(ks)) {
1599 ks_err(ks, "failed to read device ID\n"); 1587 netdev_err(netdev, "failed to read device ID\n");
1600 err = -ENODEV; 1588 err = -ENODEV;
1601 goto err_register; 1589 goto err_register;
1602 } 1590 }
@@ -1627,9 +1615,8 @@ static int __devinit ks8851_probe(struct platform_device *pdev)
1627 1615
1628 id = ks_rdreg16(ks, KS_CIDER); 1616 id = ks_rdreg16(ks, KS_CIDER);
1629 1617
1630 printk(KERN_INFO DRV_NAME 1618 netdev_info(netdev, "Found chip, family: 0x%x, id: 0x%x, rev: 0x%x\n",
1631 " Found chip, family: 0x%x, id: 0x%x, rev: 0x%x\n", 1619 (id >> 8) & 0xff, (id >> 4) & 0xf, (id >> 1) & 0x7);
1632 (id >> 8) & 0xff, (id >> 4) & 0xf, (id >> 1) & 0x7);
1633 return 0; 1620 return 0;
1634 1621
1635err_register: 1622err_register: