[PATCH] net: mvneta: read MAC address from hardware when available

Joe Perches joe at perches.com
Mon Jun 3 12:52:59 EDT 2013


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);





More information about the linux-arm-kernel mailing list