From: Gabor Juhos Date: Mon, 26 Jan 2009 14:55:09 +0000 (+0000) Subject: move random MAC address generation into the platform initialization code X-Git-Tag: reboot~24684 X-Git-Url: http://git.lede-project.org./?a=commitdiff_plain;h=6bea544949ce683dfb1d95bbc8510a397e0e1dd2;p=openwrt%2Fstaging%2Fblogic.git move random MAC address generation into the platform initialization code SVN-Revision: 14204 --- diff --git a/target/linux/ar71xx/files/arch/mips/ar71xx/platform.c b/target/linux/ar71xx/files/arch/mips/ar71xx/platform.c index ef70867a2b7c..a01aecbd99ce 100644 --- a/target/linux/ar71xx/files/arch/mips/ar71xx/platform.c +++ b/target/linux/ar71xx/files/arch/mips/ar71xx/platform.c @@ -15,6 +15,7 @@ #include #include #include +#include #include #include #include @@ -456,8 +457,15 @@ void __init ar71xx_add_device_eth(unsigned int id) break; } - memcpy(pdata->mac_addr, ar71xx_mac_base, ETH_ALEN); - pdata->mac_addr[5] += ar71xx_eth_instance; + if (is_valid_ether_addr(ar71xx_mac_base)) { + memcpy(pdata->mac_addr, ar71xx_mac_base, ETH_ALEN); + pdata->mac_addr[5] += ar71xx_eth_instance; + } else { + random_ether_addr(pdata->mac_addr); + printk(KERN_DEBUG + "ar71xx: using random MAC address for eth%d\n", + ar71xx_eth_instance); + } platform_device_register(pdev); ar71xx_eth_instance++; diff --git a/target/linux/ar71xx/files/drivers/net/ag71xx/ag71xx.h b/target/linux/ar71xx/files/drivers/net/ag71xx/ag71xx.h index 2db35ec12e0c..2bbc7486e21f 100644 --- a/target/linux/ar71xx/files/drivers/net/ag71xx/ag71xx.h +++ b/target/linux/ar71xx/files/drivers/net/ag71xx/ag71xx.h @@ -38,7 +38,7 @@ #define ETH_FCS_LEN 4 #define AG71XX_DRV_NAME "ag71xx" -#define AG71XX_DRV_VERSION "0.5.16" +#define AG71XX_DRV_VERSION "0.5.17" #define AG71XX_NAPI_WEIGHT 64 #define AG71XX_OOM_REFILL (1 + HZ/10) diff --git a/target/linux/ar71xx/files/drivers/net/ag71xx/ag71xx_main.c b/target/linux/ar71xx/files/drivers/net/ag71xx/ag71xx_main.c index 58e3b1151898..8921639ab89e 100644 --- a/target/linux/ar71xx/files/drivers/net/ag71xx/ag71xx_main.c +++ b/target/linux/ar71xx/files/drivers/net/ag71xx/ag71xx_main.c @@ -868,16 +868,9 @@ static int __init ag71xx_probe(struct platform_device *pdev) ag->oom_timer.data = (unsigned long) dev; ag->oom_timer.function = ag71xx_oom_timer_handler; - netif_napi_add(dev, &ag->napi, ag71xx_poll, AG71XX_NAPI_WEIGHT); + memcpy(dev->dev_addr, pdata->mac_addr, ETH_ALEN); - if (is_valid_ether_addr(pdata->mac_addr)) - memcpy(dev->dev_addr, pdata->mac_addr, ETH_ALEN); - else { - dev->dev_addr[0] = 0xde; - dev->dev_addr[1] = 0xad; - get_random_bytes(&dev->dev_addr[2], 3); - dev->dev_addr[5] = pdev->id & 0xff; - } + netif_napi_add(dev, &ag->napi, ag71xx_poll, AG71XX_NAPI_WEIGHT); err = register_netdev(dev); if (err) {