OpenWrt
/branches/18.06.1/target/linux/generic/pending-4.14/681-NET-add-of_get_mac_address_mtd.patch |
@@ -32,7 +32,7 @@ |
{ |
struct property *pp = of_find_property(np, name, NULL); |
|
@@ -47,6 +48,79 @@ static const void *of_get_mac_addr(struc |
@@ -47,6 +48,73 @@ static const void *of_get_mac_addr(struc |
return NULL; |
} |
|
@@ -50,7 +50,6 @@ |
+ u32 mac_inc = 0; |
+ u8 mac[ETH_ALEN]; |
+ void *addr; |
+ u32 inc_idx; |
+ |
+ list = of_get_property(np, "mtd-mac-address", &size); |
+ if (!list || (size != (2 * sizeof(*list)))) |
@@ -74,13 +73,8 @@ |
+ ret = mtd_read(mtd, be32_to_cpup(list), 6, &retlen, mac); |
+ put_mtd_device(mtd); |
+ |
+ if (of_property_read_u32(np, "mtd-mac-address-increment-byte", &inc_idx)) |
+ inc_idx = 5; |
+ if (inc_idx > 5) |
+ return NULL; |
+ |
+ if (!of_property_read_u32(np, "mtd-mac-address-increment", &mac_inc)) |
+ mac[inc_idx] += mac_inc; |
+ mac[5] += mac_inc; |
+ |
+ if (!is_valid_ether_addr(mac)) |
+ return NULL; |
@@ -112,7 +106,7 @@ |
/** |
* Search the device tree for the best MAC address to use. 'mac-address' is |
* checked first, because that is supposed to contain to "most recent" MAC |
@@ -64,11 +138,18 @@ static const void *of_get_mac_addr(struc |
@@ -64,11 +132,18 @@ static const void *of_get_mac_addr(struc |
* addresses. Some older U-Boots only initialized 'local-mac-address'. In |
* this case, the real MAC is in 'local-mac-address', and 'mac-address' exists |
* but is all zeros. |