From mboxrd@z Thu Jan 1 00:00:00 1970 From: joe@perches.com (Joe Perches) Date: Mon, 03 Jun 2013 09:52:59 -0700 Subject: [PATCH] net: mvneta: read MAC address from hardware when available In-Reply-To: <1370277707-2468-1-git-send-email-thomas.petazzoni@free-electrons.com> References: <1370277707-2468-1-git-send-email-thomas.petazzoni@free-electrons.com> Message-ID: <1370278379.2025.40.camel@joe-AO722> To: linux-arm-kernel@lists.infradead.org List-Id: linux-arm-kernel.lists.infradead.org On Mon, 2013-06-03 at 18:41 +0200, Thomas Petazzoni wrote: > This patch improves the logic used by the mvneta driver to find a MAC > address for a particular interface. Until now, it was only looking at > the Device Tree, and if no address was found, was falling back to > generating a random MAC address. [] > diff --git a/drivers/net/ethernet/marvell/mvneta.c b/drivers/net/ethernet/marvell/mvneta.c [] > @@ -2740,6 +2748,17 @@ static int mvneta_probe(struct platform_device *pdev) [] > + dt_mac_addr = of_get_mac_address(dn); > + if (dt_mac_addr && is_valid_ether_addr(dt_mac_addr)) > + memcpy(dev->dev_addr, dt_mac_addr, ETH_ALEN); > + else { > + mvneta_get_mac_addr(pp, hw_mac_addr); > + if (is_valid_ether_addr(hw_mac_addr)) > + memcpy(dev->dev_addr, hw_mac_addr, ETH_ALEN); > + else > + eth_hw_addr_random(dev); > + } maybe there could be a dmesg line like: const char *mac_from; [...] mac_from = "device tree" else [...] mac_from = "hardware" else mac_from = "random" [...] netdev_info(dev, "Using %s mac address %pM\n", mac_from, dev->dev_addr);