Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

[POWERPC] bootwrapper: Add find_node_by_alias and dt_fixup_mac_address_by_alias

Add the ability to set the mac address given the alias for the device.
Removes the need for having a linux,network-index property.

Signed-off-by: Kumar Gala <galak@kernel.crashing.org>

+28
+14
arch/powerpc/boot/devtree.c
··· 88 88 } 89 89 } 90 90 91 + void dt_fixup_mac_address_by_alias(const char *alias, const u8 *addr) 92 + { 93 + void *devp = find_node_by_alias(alias); 94 + 95 + if (devp) { 96 + printf("%s: local-mac-address <-" 97 + " %02x:%02x:%02x:%02x:%02x:%02x\n\r", alias, 98 + addr[0], addr[1], addr[2], 99 + addr[3], addr[4], addr[5]); 100 + 101 + setprop(devp, "local-mac-address", addr, 6); 102 + } 103 + } 104 + 91 105 void dt_fixup_mac_address(u32 index, const u8 *addr) 92 106 { 93 107 void *devp = find_node_by_prop_value(NULL, "linux,network-index",
+14
arch/powerpc/boot/ops.h
··· 159 159 return find_node_by_prop_value_str(prev, "device_type", type); 160 160 } 161 161 162 + static inline void *find_node_by_alias(const char *alias) 163 + { 164 + void *devp = finddevice("/aliases"); 165 + 166 + if (devp) { 167 + char path[MAX_PATH_LEN]; 168 + if (getprop(devp, alias, path, MAX_PATH_LEN) > 0) 169 + return finddevice(path); 170 + } 171 + 172 + return NULL; 173 + } 174 + 162 175 void dt_fixup_memory(u64 start, u64 size); 163 176 void dt_fixup_cpu_clocks(u32 cpufreq, u32 tbfreq, u32 busfreq); 164 177 void dt_fixup_clock(const char *path, u32 freq); 178 + void dt_fixup_mac_address_by_alias(const char *alias, const u8 *addr); 165 179 void dt_fixup_mac_address(u32 index, const u8 *addr); 166 180 void __dt_fixup_mac_addresses(u32 startindex, ...); 167 181 #define dt_fixup_mac_addresses(...) \