net: ethernet: ax88796: support generating a random mac address
authorUwe Kleine-König <u.kleine-koenig@pengutronix.de>
Thu, 25 May 2017 20:55:11 +0000 (22:55 +0200)
committerDavid S. Miller <davem@davemloft.net>
Fri, 26 May 2017 18:56:19 +0000 (14:56 -0400)
Instead of falling back to 00:00:00:00:00:00 generate a random address
if none is provided via platform data or from the device's register
space.

Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
Reviewed-by: Andrew Lunn <andrew@lunn.ch>
Signed-off-by: David S. Miller <davem@davemloft.net>
drivers/net/ethernet/8390/ax88796.c

index b0a3b85fc6f8d346f3a7d421b094b491d022dd12..2f0ee3d7ceb1b0c967ec35e1c95a5cfe423e1dda 100644 (file)
@@ -723,6 +723,12 @@ static int ax_init_dev(struct net_device *dev)
            ax->plat->mac_addr)
                memcpy(dev->dev_addr, ax->plat->mac_addr, ETH_ALEN);
 
+       if (!is_valid_ether_addr(dev->dev_addr)) {
+               eth_hw_addr_random(dev);
+               dev_info(&dev->dev, "Using random MAC address: %pM\n",
+                        dev->dev_addr);
+       }
+
        ax_reset_8390(dev);
 
        ei_local->name = "AX88796";