imx6: fix device-tree mac address assignment for ventana sky2/eth1
[openwrt.git] / target / linux / imx6 / patches-4.3 / 208-sky2-allow-mac-to-come-from-dt.patch
1 Index: linux-4.3/drivers/net/ethernet/marvell/sky2.c
2 ===================================================================
3 --- linux-4.3.orig/drivers/net/ethernet/marvell/sky2.c  2015-11-01 16:05:25.000000000 -0800
4 +++ linux-4.3/drivers/net/ethernet/marvell/sky2.c       2015-12-18 10:39:44.983158318 -0800
5 @@ -4812,7 +4812,24 @@
6          * 1) from device tree data
7          * 2) from internal registers set by bootloader
8          */
9 -       iap = of_get_mac_address(hw->pdev->dev.of_node);
10 +
11 +       iap = NULL;
12 +       if (IS_ENABLED(CONFIG_OF)) {
13 +               struct device_node *np;
14 +               np = of_find_node_by_path("/aliases");
15 +               if (np) {
16 +                       const char *path = of_get_property(np, "sky2", NULL);
17 +                       if (path)
18 +                               np = of_find_node_by_path(path);
19 +                       if (np)
20 +                               path = of_get_mac_address(np);
21 +                       if (path)
22 +                               iap = (unsigned char *) path;
23 +               }
24 +       }
25 +
26 +       if (!iap)
27 +               iap = of_get_mac_address(hw->pdev->dev.of_node);
28         if (iap)
29                 memcpy(dev->dev_addr, iap, ETH_ALEN);
30         else