MLK-13782 net: fec_mxc: specify the registered eth index by dev_id
authorAndy Duan <fugang.duan@nxp.com>
Thu, 19 Jan 2017 06:22:29 +0000 (14:22 +0800)
committerYe Li <ye.li@nxp.com>
Wed, 5 Apr 2017 06:04:37 +0000 (14:04 +0800)
Specify the registered eth index by dev_id.

Signed-off-by: Fugang Duan <fugang.duan@nxp.com>
(cherry picked from commit df42b7b0c5e6847f32419075eb25f274ed039d6f)

drivers/net/fec_mxc.c

index 93c0993..2430f09 100644 (file)
@@ -1025,6 +1025,7 @@ static int fec_probe(bd_t *bd, int dev_id, uint32_t base_addr,
        struct eth_device *edev;
        struct fec_priv *fec;
        unsigned char ethaddr[6];
+       char mac[16];
        uint32_t start;
        int ret = 0;
 
@@ -1087,12 +1088,18 @@ static int fec_probe(bd_t *bd, int dev_id, uint32_t base_addr,
        fec->phy_id = phy_id;
 #endif
        eth_register(edev);
+       /* only support one eth device, the index number pointed by dev_id */
+       edev->index = fec->dev_id;
 
        if (fec_get_hwaddr(fec->dev_id, ethaddr) == 0) {
                debug("got MAC%d address from fuse: %pM\n", fec->dev_id, ethaddr);
                memcpy(edev->enetaddr, ethaddr, 6);
-               if (!getenv("ethaddr"))
-                       eth_setenv_enetaddr("ethaddr", ethaddr);
+               if (fec->dev_id)
+                       sprintf(mac, "eth%daddr", fec->dev_id);
+               else
+                       strcpy(mac, "ethaddr");
+               if (!getenv(mac))
+                       eth_setenv_enetaddr(mac, ethaddr);
        }
        return ret;
 err4: