aboutsummaryrefslogtreecommitdiffstats
path: root/arch/powerpc
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
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')
-rw-r--r--arch/powerpc/include/asm/prom.h3
-rw-r--r--arch/powerpc/kernel/prom_parse.c38
-rw-r--r--arch/powerpc/sysdev/mv64x60_dev.c1
-rw-r--r--arch/powerpc/sysdev/tsi108_dev.c1
4 files changed, 2 insertions, 41 deletions
diff --git a/arch/powerpc/include/asm/prom.h b/arch/powerpc/include/asm/prom.h
index ae26f2efd089..98264bf0a433 100644
--- a/arch/powerpc/include/asm/prom.h
+++ b/arch/powerpc/include/asm/prom.h
@@ -63,9 +63,6 @@ struct device_node *of_get_cpu_node(int cpu, unsigned int *thread);
63/* cache lookup */ 63/* cache lookup */
64struct device_node *of_find_next_cache_node(struct device_node *np); 64struct device_node *of_find_next_cache_node(struct device_node *np);
65 65
66/* Get the MAC address */
67extern const void *of_get_mac_address(struct device_node *np);
68
69#ifdef CONFIG_NUMA 66#ifdef CONFIG_NUMA
70extern int of_node_to_nid(struct device_node *device); 67extern int of_node_to_nid(struct device_node *device);
71#else 68#else
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);
diff --git a/arch/powerpc/sysdev/mv64x60_dev.c b/arch/powerpc/sysdev/mv64x60_dev.c
index 1398bc454999..feaee402e2d6 100644
--- a/arch/powerpc/sysdev/mv64x60_dev.c
+++ b/arch/powerpc/sysdev/mv64x60_dev.c
@@ -16,6 +16,7 @@
16#include <linux/mv643xx.h> 16#include <linux/mv643xx.h>
17#include <linux/platform_device.h> 17#include <linux/platform_device.h>
18#include <linux/of_platform.h> 18#include <linux/of_platform.h>
19#include <linux/of_net.h>
19#include <linux/dma-mapping.h> 20#include <linux/dma-mapping.h>
20 21
21#include <asm/prom.h> 22#include <asm/prom.h>
diff --git a/arch/powerpc/sysdev/tsi108_dev.c b/arch/powerpc/sysdev/tsi108_dev.c
index d4d15aaf18fa..c2d675b6392c 100644
--- a/arch/powerpc/sysdev/tsi108_dev.c
+++ b/arch/powerpc/sysdev/tsi108_dev.c
@@ -19,6 +19,7 @@
19#include <linux/module.h> 19#include <linux/module.h>
20#include <linux/device.h> 20#include <linux/device.h>
21#include <linux/platform_device.h> 21#include <linux/platform_device.h>
22#include <linux/of_net.h>
22#include <asm/tsi108.h> 23#include <asm/tsi108.h>
23 24
24#include <asm/system.h> 25#include <asm/system.h>