diff options
Diffstat (limited to 'drivers/net/ethernet/marvell/sky2.c')
-rw-r--r-- | drivers/net/ethernet/marvell/sky2.c | 28 |
1 files changed, 21 insertions, 7 deletions
diff --git a/drivers/net/ethernet/marvell/sky2.c b/drivers/net/ethernet/marvell/sky2.c index 55a37ae11440..b81106451a0a 100644 --- a/drivers/net/ethernet/marvell/sky2.c +++ b/drivers/net/ethernet/marvell/sky2.c | |||
@@ -44,6 +44,8 @@ | |||
44 | #include <linux/prefetch.h> | 44 | #include <linux/prefetch.h> |
45 | #include <linux/debugfs.h> | 45 | #include <linux/debugfs.h> |
46 | #include <linux/mii.h> | 46 | #include <linux/mii.h> |
47 | #include <linux/of_device.h> | ||
48 | #include <linux/of_net.h> | ||
47 | 49 | ||
48 | #include <asm/irq.h> | 50 | #include <asm/irq.h> |
49 | 51 | ||
@@ -2000,7 +2002,7 @@ mapping_unwind: | |||
2000 | mapping_error: | 2002 | mapping_error: |
2001 | if (net_ratelimit()) | 2003 | if (net_ratelimit()) |
2002 | dev_warn(&hw->pdev->dev, "%s: tx mapping error\n", dev->name); | 2004 | dev_warn(&hw->pdev->dev, "%s: tx mapping error\n", dev->name); |
2003 | dev_kfree_skb(skb); | 2005 | dev_kfree_skb_any(skb); |
2004 | return NETDEV_TX_OK; | 2006 | return NETDEV_TX_OK; |
2005 | } | 2007 | } |
2006 | 2008 | ||
@@ -2733,6 +2735,9 @@ static int sky2_status_intr(struct sky2_hw *hw, int to_do, u16 idx) | |||
2733 | unsigned int total_bytes[2] = { 0 }; | 2735 | unsigned int total_bytes[2] = { 0 }; |
2734 | unsigned int total_packets[2] = { 0 }; | 2736 | unsigned int total_packets[2] = { 0 }; |
2735 | 2737 | ||
2738 | if (to_do <= 0) | ||
2739 | return work_done; | ||
2740 | |||
2736 | rmb(); | 2741 | rmb(); |
2737 | do { | 2742 | do { |
2738 | struct sky2_port *sky2; | 2743 | struct sky2_port *sky2; |
@@ -3906,19 +3911,19 @@ static struct rtnl_link_stats64 *sky2_get_stats(struct net_device *dev, | |||
3906 | u64 _bytes, _packets; | 3911 | u64 _bytes, _packets; |
3907 | 3912 | ||
3908 | do { | 3913 | do { |
3909 | start = u64_stats_fetch_begin_bh(&sky2->rx_stats.syncp); | 3914 | start = u64_stats_fetch_begin_irq(&sky2->rx_stats.syncp); |
3910 | _bytes = sky2->rx_stats.bytes; | 3915 | _bytes = sky2->rx_stats.bytes; |
3911 | _packets = sky2->rx_stats.packets; | 3916 | _packets = sky2->rx_stats.packets; |
3912 | } while (u64_stats_fetch_retry_bh(&sky2->rx_stats.syncp, start)); | 3917 | } while (u64_stats_fetch_retry_irq(&sky2->rx_stats.syncp, start)); |
3913 | 3918 | ||
3914 | stats->rx_packets = _packets; | 3919 | stats->rx_packets = _packets; |
3915 | stats->rx_bytes = _bytes; | 3920 | stats->rx_bytes = _bytes; |
3916 | 3921 | ||
3917 | do { | 3922 | do { |
3918 | start = u64_stats_fetch_begin_bh(&sky2->tx_stats.syncp); | 3923 | start = u64_stats_fetch_begin_irq(&sky2->tx_stats.syncp); |
3919 | _bytes = sky2->tx_stats.bytes; | 3924 | _bytes = sky2->tx_stats.bytes; |
3920 | _packets = sky2->tx_stats.packets; | 3925 | _packets = sky2->tx_stats.packets; |
3921 | } while (u64_stats_fetch_retry_bh(&sky2->tx_stats.syncp, start)); | 3926 | } while (u64_stats_fetch_retry_irq(&sky2->tx_stats.syncp, start)); |
3922 | 3927 | ||
3923 | stats->tx_packets = _packets; | 3928 | stats->tx_packets = _packets; |
3924 | stats->tx_bytes = _bytes; | 3929 | stats->tx_bytes = _bytes; |
@@ -4748,6 +4753,7 @@ static struct net_device *sky2_init_netdev(struct sky2_hw *hw, unsigned port, | |||
4748 | { | 4753 | { |
4749 | struct sky2_port *sky2; | 4754 | struct sky2_port *sky2; |
4750 | struct net_device *dev = alloc_etherdev(sizeof(*sky2)); | 4755 | struct net_device *dev = alloc_etherdev(sizeof(*sky2)); |
4756 | const void *iap; | ||
4751 | 4757 | ||
4752 | if (!dev) | 4758 | if (!dev) |
4753 | return NULL; | 4759 | return NULL; |
@@ -4805,8 +4811,16 @@ static struct net_device *sky2_init_netdev(struct sky2_hw *hw, unsigned port, | |||
4805 | 4811 | ||
4806 | dev->features |= dev->hw_features; | 4812 | dev->features |= dev->hw_features; |
4807 | 4813 | ||
4808 | /* read the mac address */ | 4814 | /* try to get mac address in the following order: |
4809 | memcpy_fromio(dev->dev_addr, hw->regs + B2_MAC_1 + port * 8, ETH_ALEN); | 4815 | * 1) from device tree data |
4816 | * 2) from internal registers set by bootloader | ||
4817 | */ | ||
4818 | iap = of_get_mac_address(hw->pdev->dev.of_node); | ||
4819 | if (iap) | ||
4820 | memcpy(dev->dev_addr, iap, ETH_ALEN); | ||
4821 | else | ||
4822 | memcpy_fromio(dev->dev_addr, hw->regs + B2_MAC_1 + port * 8, | ||
4823 | ETH_ALEN); | ||
4810 | 4824 | ||
4811 | return dev; | 4825 | return dev; |
4812 | } | 4826 | } |