Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1720103

[PATCH net v2 4/4] net: mvpp2: fallback using h/w and random mac if the dt one isn't valid

From Antoine Tenart <antoine.tenart@free-electrons.com>
Newsgroups linux.kernel
Subject [PATCH net v2 4/4] net: mvpp2: fallback using h/w and random mac if the dt one isn't valid
Date 2017-08-25 16:20 +0200
Message-ID <uinCO-556-23@gated-at.bofh.it> (permalink)
References <uinCN-556-7@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


When using a mac address described in the device tree, a check is made
to see if it is valid. When it's not, no fallback is defined. This
patches tries to get the mac address from h/w (or use a random one if
the h/w one isn't valid) when the dt mac address isn't valid.

Signed-off-by: Antoine Tenart <antoine.tenart@free-electrons.com>
---
 drivers/net/ethernet/marvell/mvpp2.c | 23 ++++++++++++-----------
 1 file changed, 12 insertions(+), 11 deletions(-)

diff --git a/drivers/net/ethernet/marvell/mvpp2.c b/drivers/net/ethernet/marvell/mvpp2.c
index 162e334fda37..2f1284f23e66 100644
--- a/drivers/net/ethernet/marvell/mvpp2.c
+++ b/drivers/net/ethernet/marvell/mvpp2.c
@@ -6504,19 +6504,20 @@ static void mvpp2_port_copy_mac_addr(struct net_device *dev, struct mvpp2 *priv,
 	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);
-				return;
-			}
-		}
+		return;
+	}
 
-		*mac_from = "random";
-		eth_hw_addr_random(dev);
+	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 */
-- 
2.13.5

Back to linux.kernel | Previous | NextPrevious in thread | Find similar | Unroll thread


Thread

[PATCH net v2 0/4] net: mvpp2: fix the mac address retrieval logic Antoine Tenart <antoine.tenart@free-electrons.com> - 2017-08-25 16:20 +0200
  [PATCH net v2 3/4] net: mvpp2: fix use of the random mac address for PPv2.2 Antoine Tenart <antoine.tenart@free-electrons.com> - 2017-08-25 16:20 +0200
  [PATCH net v2 2/4] net: mvpp2: move the mac retrieval/copy logic into its own function Antoine Tenart <antoine.tenart@free-electrons.com> - 2017-08-25 16:20 +0200
  [PATCH net v2 4/4] net: mvpp2: fallback using h/w and random mac if the dt one isn't valid Antoine Tenart <antoine.tenart@free-electrons.com> - 2017-08-25 16:20 +0200

csiph-web