diff options
author | David Daney <ddaney@caviumnetworks.com> | 2010-10-26 18:07:13 -0400 |
---|---|---|
committer | Grant Likely <grant.likely@secretlab.ca> | 2010-11-01 01:08:14 -0400 |
commit | 4b6ba8aacbb3185703b797286547d0f8f3859b02 (patch) | |
tree | f4e04c3b19d6bf7c7429c0cf678c534838e2990d /arch/microblaze | |
parent | 3985c7ce85039adacdf882904ca096f091d39346 (diff) |
of/net: Move of_get_mac_address() to a common source file.
There are two identical implementations of of_get_mac_address(), one
each in arch/powerpc/kernel/prom_parse.c and
arch/microblaze/kernel/prom_parse.c. Move this function to a new
common file of_net.{c,h} and adjust all the callers to include the new
header.
Signed-off-by: David Daney <ddaney@caviumnetworks.com>
[grant.likely@secretlab.ca: protect header with #ifdef]
Signed-off-by: Grant Likely <grant.likely@secretlab.ca>
Diffstat (limited to 'arch/microblaze')
-rw-r--r-- | arch/microblaze/include/asm/prom.h | 3 | ||||
-rw-r--r-- | arch/microblaze/kernel/prom_parse.c | 38 |
2 files changed, 0 insertions, 41 deletions
diff --git a/arch/microblaze/include/asm/prom.h b/arch/microblaze/include/asm/prom.h index bdc38312ae4..2e72af078b0 100644 --- a/arch/microblaze/include/asm/prom.h +++ b/arch/microblaze/include/asm/prom.h | |||
@@ -64,9 +64,6 @@ extern void kdump_move_device_tree(void); | |||
64 | /* CPU OF node matching */ | 64 | /* CPU OF node matching */ |
65 | struct device_node *of_get_cpu_node(int cpu, unsigned int *thread); | 65 | struct device_node *of_get_cpu_node(int cpu, unsigned int *thread); |
66 | 66 | ||
67 | /* Get the MAC address */ | ||
68 | extern const void *of_get_mac_address(struct device_node *np); | ||
69 | |||
70 | /** | 67 | /** |
71 | * of_irq_map_pci - Resolve the interrupt for a PCI device | 68 | * of_irq_map_pci - Resolve the interrupt for a PCI device |
72 | * @pdev: the device whose interrupt is to be resolved | 69 | * @pdev: the device whose interrupt is to be resolved |
diff --git a/arch/microblaze/kernel/prom_parse.c b/arch/microblaze/kernel/prom_parse.c index 99d9b61cccb..9ae24f4b882 100644 --- a/arch/microblaze/kernel/prom_parse.c +++ b/arch/microblaze/kernel/prom_parse.c | |||
@@ -110,41 +110,3 @@ void of_parse_dma_window(struct device_node *dn, const void *dma_window_prop, | |||
110 | cells = prop ? *(u32 *)prop : of_n_size_cells(dn); | 110 | cells = prop ? *(u32 *)prop : of_n_size_cells(dn); |
111 | *size = of_read_number(dma_window, cells); | 111 | *size = of_read_number(dma_window, cells); |
112 | } | 112 | } |
113 | |||
114 | /** | ||
115 | * Search the device tree for the best MAC address to use. 'mac-address' is | ||
116 | * checked first, because that is supposed to contain to "most recent" MAC | ||
117 | * address. If that isn't set, then 'local-mac-address' is checked next, | ||
118 | * because that is the default address. If that isn't set, then the obsolete | ||
119 | * 'address' is checked, just in case we're using an old device tree. | ||
120 | * | ||
121 | * Note that the 'address' property is supposed to contain a virtual address of | ||
122 | * the register set, but some DTS files have redefined that property to be the | ||
123 | * MAC address. | ||
124 | * | ||
125 | * All-zero MAC addresses are rejected, because those could be properties that | ||
126 | * exist in the device tree, but were not set by U-Boot. For example, the | ||
127 | * DTS could define 'mac-address' and 'local-mac-address', with zero MAC | ||
128 | * addresses. Some older U-Boots only initialized 'local-mac-address'. In | ||
129 | * this case, the real MAC is in 'local-mac-address', and 'mac-address' exists | ||
130 | * but is all zeros. | ||
131 | */ | ||
132 | const void *of_get_mac_address(struct device_node *np) | ||
133 | { | ||
134 | struct property *pp; | ||
135 | |||
136 | pp = of_find_property(np, "mac-address", NULL); | ||
137 | if (pp && (pp->length == 6) && is_valid_ether_addr(pp->value)) | ||
138 | return pp->value; | ||
139 | |||
140 | pp = of_find_property(np, "local-mac-address", NULL); | ||
141 | if (pp && (pp->length == 6) && is_valid_ether_addr(pp->value)) | ||
142 | return pp->value; | ||
143 | |||
144 | pp = of_find_property(np, "address", NULL); | ||
145 | if (pp && (pp->length == 6) && is_valid_ether_addr(pp->value)) | ||
146 | return pp->value; | ||
147 | |||
148 | return NULL; | ||
149 | } | ||
150 | EXPORT_SYMBOL(of_get_mac_address); | ||