OpenWrt – Diff between revs 2 and 3

Subversion Repositories:
Rev:
Show entire fileIgnore whitespace
Rev 2 Rev 3
Line 30... Line 30...
30 -static const void *of_get_mac_addr(struct device_node *np, const char *name) 30 -static const void *of_get_mac_addr(struct device_node *np, const char *name)
31 +static void *of_get_mac_addr(struct device_node *np, const char *name) 31 +static void *of_get_mac_addr(struct device_node *np, const char *name)
32 { 32 {
33 struct property *pp = of_find_property(np, name, NULL); 33 struct property *pp = of_find_property(np, name, NULL);
Line 34... Line 34...
34 34
35 @@ -47,6 +48,79 @@ static const void *of_get_mac_addr(struc 35 @@ -47,6 +48,73 @@ static const void *of_get_mac_addr(struc
36 return NULL; 36 return NULL;
Line 37... Line 37...
37 } 37 }
38 38
Line 48... Line 48...
48 + const __be32 *list; 48 + const __be32 *list;
49 + phandle phandle; 49 + phandle phandle;
50 + u32 mac_inc = 0; 50 + u32 mac_inc = 0;
51 + u8 mac[ETH_ALEN]; 51 + u8 mac[ETH_ALEN];
52 + void *addr; 52 + void *addr;
53 + u32 inc_idx; -  
54 + 53 +
55 + list = of_get_property(np, "mtd-mac-address", &size); 54 + list = of_get_property(np, "mtd-mac-address", &size);
56 + if (!list || (size != (2 * sizeof(*list)))) 55 + if (!list || (size != (2 * sizeof(*list))))
57 + return NULL; 56 + return NULL;
58 + 57 +
Line 72... Line 71...
72 + return NULL; 71 + return NULL;
73 + 72 +
74 + ret = mtd_read(mtd, be32_to_cpup(list), 6, &retlen, mac); 73 + ret = mtd_read(mtd, be32_to_cpup(list), 6, &retlen, mac);
75 + put_mtd_device(mtd); 74 + put_mtd_device(mtd);
76 + 75 +
77 + if (of_property_read_u32(np, "mtd-mac-address-increment-byte", &inc_idx)) -  
78 + inc_idx = 5; -  
79 + if (inc_idx > 5) -  
80 + return NULL; -  
81 + -  
82 + if (!of_property_read_u32(np, "mtd-mac-address-increment", &mac_inc)) 76 + if (!of_property_read_u32(np, "mtd-mac-address-increment", &mac_inc))
83 + mac[inc_idx] += mac_inc; 77 + mac[5] += mac_inc;
84 + 78 +
85 + if (!is_valid_ether_addr(mac)) 79 + if (!is_valid_ether_addr(mac))
86 + return NULL; 80 + return NULL;
87 + 81 +
88 + addr = of_get_mac_addr(np, "mac-address"); 82 + addr = of_get_mac_addr(np, "mac-address");
Line 110... Line 104...
110 +} 104 +}
111 + 105 +
112 /** 106 /**
113 * Search the device tree for the best MAC address to use. 'mac-address' is 107 * Search the device tree for the best MAC address to use. 'mac-address' is
114 * checked first, because that is supposed to contain to "most recent" MAC 108 * checked first, because that is supposed to contain to "most recent" MAC
115 @@ -64,11 +138,18 @@ static const void *of_get_mac_addr(struc 109 @@ -64,11 +132,18 @@ static const void *of_get_mac_addr(struc
116 * addresses. Some older U-Boots only initialized 'local-mac-address'. In 110 * addresses. Some older U-Boots only initialized 'local-mac-address'. In
117 * this case, the real MAC is in 'local-mac-address', and 'mac-address' exists 111 * this case, the real MAC is in 'local-mac-address', and 'mac-address' exists
118 * but is all zeros. 112 * but is all zeros.
119 + * 113 + *
120 + * If a mtd-mac-address property exists, try to fetch the MAC address from the 114 + * If a mtd-mac-address property exists, try to fetch the MAC address from the