summaryrefslogtreecommitdiffstats
path: root/drivers/net
diff options
context:
space:
mode:
authorDavid S. Miller <davem@davemloft.net>2017-09-03 20:16:56 -0700
committerDavid S. Miller <davem@davemloft.net>2017-09-03 20:16:56 -0700
commit45f7929194148866c679c78f774d74e808feb6a4 (patch)
tree1ce56c330ce8a96fc55fd4eee29261231e55ca5e /drivers/net
parentb63f6044d8e43e4a1eef8b0a2310cec872fd1d38 (diff)
parent688cbaf202df8b4a69f5ccd39e0027f179852d44 (diff)
downloadlinux-45f7929194148866c679c78f774d74e808feb6a4.tar.bz2
Merge branch 'mvpp2-improve-the-mac-address-retrieval-logic'
Antoine Tenart says: ==================== net: mvpp2: improve the mac address retrieval logic This series aims at fixing the logic behind the MAC address retrieval in the PPv2 driver. A possible issue is also fixed in patch 3/3 to introduce fallbacks when the address given in the device tree isn't valid. Thanks! Antoine Since v2: - Patch 1/4 from v2 was applied on net (and net was merged in net-next). - Rebased on net-next. Since v1: - Rebased onto net (was on net-next). ==================== Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'drivers/net')
-rw-r--r--drivers/net/ethernet/marvell/mvpp2.c48
1 files changed, 30 insertions, 18 deletions
diff --git a/drivers/net/ethernet/marvell/mvpp2.c b/drivers/net/ethernet/marvell/mvpp2.c
index d5624894152e..dd0ee2691c86 100644
--- a/drivers/net/ethernet/marvell/mvpp2.c
+++ b/drivers/net/ethernet/marvell/mvpp2.c
@@ -7465,6 +7465,34 @@ static bool mvpp2_port_has_tx_irqs(struct mvpp2 *priv,
return true;
}
+static void mvpp2_port_copy_mac_addr(struct net_device *dev, struct mvpp2 *priv,
+ struct device_node *port_node,
+ char **mac_from)
+{
+ struct mvpp2_port *port = netdev_priv(dev);
+ char hw_mac_addr[ETH_ALEN] = {0};
+ const char *dt_mac_addr;
+
+ dt_mac_addr = of_get_mac_address(port_node);
+ if (dt_mac_addr && is_valid_ether_addr(dt_mac_addr)) {
+ *mac_from = "device tree";
+ ether_addr_copy(dev->dev_addr, dt_mac_addr);
+ return;
+ }
+
+ if (priv->hw_version == MVPP21) {
+ mvpp21_get_mac_address(port, hw_mac_addr);
+ if (is_valid_ether_addr(hw_mac_addr)) {
+ *mac_from = "hardware";
+ ether_addr_copy(dev->dev_addr, hw_mac_addr);
+ return;
+ }
+ }
+
+ *mac_from = "random";
+ eth_hw_addr_random(dev);
+}
+
/* Ports initialization */
static int mvpp2_port_probe(struct platform_device *pdev,
struct device_node *port_node,
@@ -7476,9 +7504,7 @@ static int mvpp2_port_probe(struct platform_device *pdev,
struct mvpp2_port_pcpu *port_pcpu;
struct net_device *dev;
struct resource *res;
- const char *dt_mac_addr;
- const char *mac_from;
- char hw_mac_addr[ETH_ALEN] = {0};
+ char *mac_from = "";
unsigned int ntxqs, nrxqs;
bool has_tx_irqs;
u32 id;
@@ -7587,21 +7613,7 @@ static int mvpp2_port_probe(struct platform_device *pdev,
goto err_free_irq;
}
- dt_mac_addr = of_get_mac_address(port_node);
- if (dt_mac_addr && is_valid_ether_addr(dt_mac_addr)) {
- mac_from = "device tree";
- ether_addr_copy(dev->dev_addr, dt_mac_addr);
- } else {
- if (priv->hw_version == MVPP21)
- mvpp21_get_mac_address(port, hw_mac_addr);
- if (is_valid_ether_addr(hw_mac_addr)) {
- mac_from = "hardware";
- ether_addr_copy(dev->dev_addr, hw_mac_addr);
- } else {
- mac_from = "random";
- eth_hw_addr_random(dev);
- }
- }
+ mvpp2_port_copy_mac_addr(dev, priv, port_node, &mac_from);
port->tx_ring_size = MVPP2_MAX_TXD;
port->rx_ring_size = MVPP2_MAX_RXD;