aboutsummaryrefslogtreecommitdiffstats
path: root/arch/powerpc/kernel/prom_parse.c
diff options
context:
space:
mode:
authorDavid Daney <ddaney@caviumnetworks.com>2010-10-26 18:07:13 -0400
committerGrant Likely <grant.likely@secretlab.ca>2010-11-01 01:08:14 -0400
commit4b6ba8aacbb3185703b797286547d0f8f3859b02 (patch)
treef4e04c3b19d6bf7c7429c0cf678c534838e2990d /arch/powerpc/kernel/prom_parse.c
parent3985c7ce85039adacdf882904ca096f091d39346 (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/powerpc/kernel/prom_parse.c')
-rw-r--r--arch/powerpc/kernel/prom_parse.c38
1 files changed, 0 insertions, 38 deletions
diff --git a/arch/powerpc/kernel/prom_parse.c b/arch/powerpc/kernel/prom_parse.c
index 88334af038e5..c2b7a07cc3d3 100644
--- a/arch/powerpc/kernel/prom_parse.c
+++ b/arch/powerpc/kernel/prom_parse.c
@@ -117,41 +117,3 @@ void of_parse_dma_window(struct device_node *dn, const void *dma_window_prop,
117 cells = prop ? *(u32 *)prop : of_n_size_cells(dn); 117 cells = prop ? *(u32 *)prop : of_n_size_cells(dn);
118 *size = of_read_number(dma_window, cells); 118 *size = of_read_number(dma_window, cells);
119} 119}
120
121/**
122 * Search the device tree for the best MAC address to use. 'mac-address' is
123 * checked first, because that is supposed to contain to "most recent" MAC
124 * address. If that isn't set, then 'local-mac-address' is checked next,
125 * because that is the default address. If that isn't set, then the obsolete
126 * 'address' is checked, just in case we're using an old device tree.
127 *
128 * Note that the 'address' property is supposed to contain a virtual address of
129 * the register set, but some DTS files have redefined that property to be the
130 * MAC address.
131 *
132 * All-zero MAC addresses are rejected, because those could be properties that
133 * exist in the device tree, but were not set by U-Boot. For example, the
134 * DTS could define 'mac-address' and 'local-mac-address', with zero MAC
135 * addresses. Some older U-Boots only initialized 'local-mac-address'. In
136 * this case, the real MAC is in 'local-mac-address', and 'mac-address' exists
137 * but is all zeros.
138*/
139const void *of_get_mac_address(struct device_node *np)
140{
141 struct property *pp;
142
143 pp = of_find_property(np, "mac-address", NULL);
144 if (pp && (pp->length == 6) && is_valid_ether_addr(pp->value))
145 return pp->value;
146
147 pp = of_find_property(np, "local-mac-address", NULL);
148 if (pp && (pp->length == 6) && is_valid_ether_addr(pp->value))
149 return pp->value;
150
151 pp = of_find_property(np, "address", NULL);
152 if (pp && (pp->length == 6) && is_valid_ether_addr(pp->value))
153 return pp->value;
154
155 return NULL;
156}
157EXPORT_SYMBOL(of_get_mac_address);