Commit 97e873e5c8ad8711ce4cca080cff4eb5d21b3aeb
1 parent
76c1ce7870
Exists in
master
and in
39 other branches
Start split out of common open firmware code
This creates drivers/of/base.c (depending on CONFIG_OF) and puts the first trivially common bits from the prom.c files into it. Signed-off-by: Stephen Rothwell <sfr@canb.auug.org.au> Acked-by: Paul Mackerras <paulus@samba.org> Acked-by: David S. Miller <davem@davemloft.net>
Showing 12 changed files with 85 additions and 125 deletions Side-by-side Diff
arch/powerpc/Kconfig
arch/powerpc/kernel/prom.c
... | ... | @@ -1056,36 +1056,7 @@ |
1056 | 1056 | DBG(" <- early_init_devtree()\n"); |
1057 | 1057 | } |
1058 | 1058 | |
1059 | -int of_n_addr_cells(struct device_node* np) | |
1060 | -{ | |
1061 | - const int *ip; | |
1062 | - do { | |
1063 | - if (np->parent) | |
1064 | - np = np->parent; | |
1065 | - ip = of_get_property(np, "#address-cells", NULL); | |
1066 | - if (ip != NULL) | |
1067 | - return *ip; | |
1068 | - } while (np->parent); | |
1069 | - /* No #address-cells property for the root node, default to 1 */ | |
1070 | - return 1; | |
1071 | -} | |
1072 | -EXPORT_SYMBOL(of_n_addr_cells); | |
1073 | 1059 | |
1074 | -int of_n_size_cells(struct device_node* np) | |
1075 | -{ | |
1076 | - const int* ip; | |
1077 | - do { | |
1078 | - if (np->parent) | |
1079 | - np = np->parent; | |
1080 | - ip = of_get_property(np, "#size-cells", NULL); | |
1081 | - if (ip != NULL) | |
1082 | - return *ip; | |
1083 | - } while (np->parent); | |
1084 | - /* No #size-cells property for the root node, default to 1 */ | |
1085 | - return 1; | |
1086 | -} | |
1087 | -EXPORT_SYMBOL(of_n_size_cells); | |
1088 | - | |
1089 | 1060 | /** Checks if the given "compat" string matches one of the strings in |
1090 | 1061 | * the device's "compatible" property |
1091 | 1062 | */ |
... | ... | @@ -1561,18 +1532,6 @@ |
1561 | 1532 | return pp; |
1562 | 1533 | } |
1563 | 1534 | EXPORT_SYMBOL(of_find_property); |
1564 | - | |
1565 | -/* | |
1566 | - * Find a property with a given name for a given node | |
1567 | - * and return the value. | |
1568 | - */ | |
1569 | -const void *of_get_property(const struct device_node *np, const char *name, | |
1570 | - int *lenp) | |
1571 | -{ | |
1572 | - struct property *pp = of_find_property(np,name,lenp); | |
1573 | - return pp ? pp->value : NULL; | |
1574 | -} | |
1575 | -EXPORT_SYMBOL(of_get_property); | |
1576 | 1535 | |
1577 | 1536 | /* |
1578 | 1537 | * Add a property to a node |
arch/sparc/Kconfig
arch/sparc/kernel/prom.c
... | ... | @@ -168,18 +168,6 @@ |
168 | 168 | } |
169 | 169 | EXPORT_SYMBOL(of_find_property); |
170 | 170 | |
171 | -/* | |
172 | - * Find a property with a given name for a given node | |
173 | - * and return the value. | |
174 | - */ | |
175 | -const void *of_get_property(const struct device_node *np, const char *name, | |
176 | - int *lenp) | |
177 | -{ | |
178 | - struct property *pp = of_find_property(np,name,lenp); | |
179 | - return pp ? pp->value : NULL; | |
180 | -} | |
181 | -EXPORT_SYMBOL(of_get_property); | |
182 | - | |
183 | 171 | int of_getintprop_default(struct device_node *np, const char *name, int def) |
184 | 172 | { |
185 | 173 | struct property *prop; |
... | ... | @@ -192,36 +180,6 @@ |
192 | 180 | return *(int *) prop->value; |
193 | 181 | } |
194 | 182 | EXPORT_SYMBOL(of_getintprop_default); |
195 | - | |
196 | -int of_n_addr_cells(struct device_node *np) | |
197 | -{ | |
198 | - const int* ip; | |
199 | - do { | |
200 | - if (np->parent) | |
201 | - np = np->parent; | |
202 | - ip = of_get_property(np, "#address-cells", NULL); | |
203 | - if (ip != NULL) | |
204 | - return *ip; | |
205 | - } while (np->parent); | |
206 | - /* No #address-cells property for the root node, default to 2 */ | |
207 | - return 2; | |
208 | -} | |
209 | -EXPORT_SYMBOL(of_n_addr_cells); | |
210 | - | |
211 | -int of_n_size_cells(struct device_node *np) | |
212 | -{ | |
213 | - const int* ip; | |
214 | - do { | |
215 | - if (np->parent) | |
216 | - np = np->parent; | |
217 | - ip = of_get_property(np, "#size-cells", NULL); | |
218 | - if (ip != NULL) | |
219 | - return *ip; | |
220 | - } while (np->parent); | |
221 | - /* No #size-cells property for the root node, default to 1 */ | |
222 | - return 1; | |
223 | -} | |
224 | -EXPORT_SYMBOL(of_n_size_cells); | |
225 | 183 | |
226 | 184 | int of_set_property(struct device_node *dp, const char *name, void *val, int len) |
227 | 185 | { |
arch/sparc64/Kconfig
arch/sparc64/kernel/prom.c
... | ... | @@ -173,18 +173,6 @@ |
173 | 173 | } |
174 | 174 | EXPORT_SYMBOL(of_find_property); |
175 | 175 | |
176 | -/* | |
177 | - * Find a property with a given name for a given node | |
178 | - * and return the value. | |
179 | - */ | |
180 | -const void *of_get_property(const struct device_node *np, const char *name, | |
181 | - int *lenp) | |
182 | -{ | |
183 | - struct property *pp = of_find_property(np,name,lenp); | |
184 | - return pp ? pp->value : NULL; | |
185 | -} | |
186 | -EXPORT_SYMBOL(of_get_property); | |
187 | - | |
188 | 176 | int of_getintprop_default(struct device_node *np, const char *name, int def) |
189 | 177 | { |
190 | 178 | struct property *prop; |
... | ... | @@ -197,36 +185,6 @@ |
197 | 185 | return *(int *) prop->value; |
198 | 186 | } |
199 | 187 | EXPORT_SYMBOL(of_getintprop_default); |
200 | - | |
201 | -int of_n_addr_cells(struct device_node *np) | |
202 | -{ | |
203 | - const int* ip; | |
204 | - do { | |
205 | - if (np->parent) | |
206 | - np = np->parent; | |
207 | - ip = of_get_property(np, "#address-cells", NULL); | |
208 | - if (ip != NULL) | |
209 | - return *ip; | |
210 | - } while (np->parent); | |
211 | - /* No #address-cells property for the root node, default to 2 */ | |
212 | - return 2; | |
213 | -} | |
214 | -EXPORT_SYMBOL(of_n_addr_cells); | |
215 | - | |
216 | -int of_n_size_cells(struct device_node *np) | |
217 | -{ | |
218 | - const int* ip; | |
219 | - do { | |
220 | - if (np->parent) | |
221 | - np = np->parent; | |
222 | - ip = of_get_property(np, "#size-cells", NULL); | |
223 | - if (ip != NULL) | |
224 | - return *ip; | |
225 | - } while (np->parent); | |
226 | - /* No #size-cells property for the root node, default to 1 */ | |
227 | - return 1; | |
228 | -} | |
229 | -EXPORT_SYMBOL(of_n_size_cells); | |
230 | 188 | |
231 | 189 | int of_set_property(struct device_node *dp, const char *name, void *val, int len) |
232 | 190 | { |
drivers/Makefile
drivers/of/Makefile
1 | +obj-y = base.o |
drivers/of/base.c
1 | +/* | |
2 | + * Procedures for creating, accessing and interpreting the device tree. | |
3 | + * | |
4 | + * Paul Mackerras August 1996. | |
5 | + * Copyright (C) 1996-2005 Paul Mackerras. | |
6 | + * | |
7 | + * Adapted for 64bit PowerPC by Dave Engebretsen and Peter Bergner. | |
8 | + * {engebret|bergner}@us.ibm.com | |
9 | + * | |
10 | + * Adapted for sparc and sparc64 by David S. Miller davem@davemloft.net | |
11 | + * | |
12 | + * Reconsolidated from arch/x/kernel/prom.c by Stephen Rothwell. | |
13 | + * | |
14 | + * This program is free software; you can redistribute it and/or | |
15 | + * modify it under the terms of the GNU General Public License | |
16 | + * as published by the Free Software Foundation; either version | |
17 | + * 2 of the License, or (at your option) any later version. | |
18 | + */ | |
19 | +#include <linux/module.h> | |
20 | +#include <linux/of.h> | |
21 | + | |
22 | +int of_n_addr_cells(struct device_node *np) | |
23 | +{ | |
24 | + const int *ip; | |
25 | + | |
26 | + do { | |
27 | + if (np->parent) | |
28 | + np = np->parent; | |
29 | + ip = of_get_property(np, "#address-cells", NULL); | |
30 | + if (ip) | |
31 | + return *ip; | |
32 | + } while (np->parent); | |
33 | + /* No #address-cells property for the root node */ | |
34 | + return OF_ROOT_NODE_ADDR_CELLS_DEFAULT; | |
35 | +} | |
36 | +EXPORT_SYMBOL(of_n_addr_cells); | |
37 | + | |
38 | +int of_n_size_cells(struct device_node *np) | |
39 | +{ | |
40 | + const int *ip; | |
41 | + | |
42 | + do { | |
43 | + if (np->parent) | |
44 | + np = np->parent; | |
45 | + ip = of_get_property(np, "#size-cells", NULL); | |
46 | + if (ip) | |
47 | + return *ip; | |
48 | + } while (np->parent); | |
49 | + /* No #size-cells property for the root node */ | |
50 | + return OF_ROOT_NODE_SIZE_CELLS_DEFAULT; | |
51 | +} | |
52 | +EXPORT_SYMBOL(of_n_size_cells); | |
53 | + | |
54 | +/* | |
55 | + * Find a property with a given name for a given node | |
56 | + * and return the value. | |
57 | + */ | |
58 | +const void *of_get_property(const struct device_node *np, const char *name, | |
59 | + int *lenp) | |
60 | +{ | |
61 | + struct property *pp = of_find_property(np, name, lenp); | |
62 | + | |
63 | + return pp ? pp->value : NULL; | |
64 | +} | |
65 | +EXPORT_SYMBOL(of_get_property); |
include/asm-powerpc/prom.h
... | ... | @@ -21,6 +21,9 @@ |
21 | 21 | #include <asm/irq.h> |
22 | 22 | #include <asm/atomic.h> |
23 | 23 | |
24 | +#define OF_ROOT_NODE_ADDR_CELLS_DEFAULT 1 | |
25 | +#define OF_ROOT_NODE_SIZE_CELLS_DEFAULT 1 | |
26 | + | |
24 | 27 | /* Definitions used by the flattened device tree */ |
25 | 28 | #define OF_DT_HEADER 0xd00dfeed /* marker */ |
26 | 29 | #define OF_DT_BEGIN_NODE 0x1 /* Start of node, full name */ |
include/asm-sparc/prom.h
include/asm-sparc64/prom.h