aboutsummaryrefslogtreecommitdiffstats
path: root/include/linux/of.h
diff options
context:
space:
mode:
Diffstat (limited to 'include/linux/of.h')
-rw-r--r--include/linux/of.h57
1 files changed, 49 insertions, 8 deletions
diff --git a/include/linux/of.h b/include/linux/of.h
index b4e50d56fc74..60053bd7e79a 100644
--- a/include/linux/of.h
+++ b/include/linux/of.h
@@ -46,7 +46,7 @@ struct device_node {
46 const char *name; 46 const char *name;
47 const char *type; 47 const char *type;
48 phandle phandle; 48 phandle phandle;
49 char *full_name; 49 const char *full_name;
50 50
51 struct property *properties; 51 struct property *properties;
52 struct property *deadprops; /* removed properties */ 52 struct property *deadprops; /* removed properties */
@@ -60,7 +60,7 @@ struct device_node {
60 unsigned long _flags; 60 unsigned long _flags;
61 void *data; 61 void *data;
62#if defined(CONFIG_SPARC) 62#if defined(CONFIG_SPARC)
63 char *path_component_name; 63 const char *path_component_name;
64 unsigned int unique_id; 64 unsigned int unique_id;
65 struct of_irq_controller *irq_trans; 65 struct of_irq_controller *irq_trans;
66#endif 66#endif
@@ -88,14 +88,14 @@ static inline void of_node_put(struct device_node *node) { }
88#ifdef CONFIG_OF 88#ifdef CONFIG_OF
89 89
90/* Pointer for first entry in chain of all nodes. */ 90/* Pointer for first entry in chain of all nodes. */
91extern struct device_node *allnodes; 91extern struct device_node *of_allnodes;
92extern struct device_node *of_chosen; 92extern struct device_node *of_chosen;
93extern struct device_node *of_aliases; 93extern struct device_node *of_aliases;
94extern rwlock_t devtree_lock; 94extern rwlock_t devtree_lock;
95 95
96static inline bool of_have_populated_dt(void) 96static inline bool of_have_populated_dt(void)
97{ 97{
98 return allnodes != NULL; 98 return of_allnodes != NULL;
99} 99}
100 100
101static inline bool of_node_is_root(const struct device_node *node) 101static inline bool of_node_is_root(const struct device_node *node)
@@ -179,11 +179,22 @@ extern struct device_node *of_find_compatible_node(struct device_node *from,
179#define for_each_compatible_node(dn, type, compatible) \ 179#define for_each_compatible_node(dn, type, compatible) \
180 for (dn = of_find_compatible_node(NULL, type, compatible); dn; \ 180 for (dn = of_find_compatible_node(NULL, type, compatible); dn; \
181 dn = of_find_compatible_node(dn, type, compatible)) 181 dn = of_find_compatible_node(dn, type, compatible))
182extern struct device_node *of_find_matching_node(struct device_node *from, 182extern struct device_node *of_find_matching_node_and_match(
183 const struct of_device_id *matches); 183 struct device_node *from,
184 const struct of_device_id *matches,
185 const struct of_device_id **match);
186static inline struct device_node *of_find_matching_node(
187 struct device_node *from,
188 const struct of_device_id *matches)
189{
190 return of_find_matching_node_and_match(from, matches, NULL);
191}
184#define for_each_matching_node(dn, matches) \ 192#define for_each_matching_node(dn, matches) \
185 for (dn = of_find_matching_node(NULL, matches); dn; \ 193 for (dn = of_find_matching_node(NULL, matches); dn; \
186 dn = of_find_matching_node(dn, matches)) 194 dn = of_find_matching_node(dn, matches))
195#define for_each_matching_node_and_match(dn, matches, match) \
196 for (dn = of_find_matching_node_and_match(NULL, matches, match); \
197 dn; dn = of_find_matching_node_and_match(dn, matches, match))
187extern struct device_node *of_find_node_by_path(const char *path); 198extern struct device_node *of_find_node_by_path(const char *path);
188extern struct device_node *of_find_node_by_phandle(phandle handle); 199extern struct device_node *of_find_node_by_phandle(phandle handle);
189extern struct device_node *of_get_parent(const struct device_node *node); 200extern struct device_node *of_get_parent(const struct device_node *node);
@@ -223,6 +234,10 @@ extern struct device_node *of_find_node_with_property(
223extern struct property *of_find_property(const struct device_node *np, 234extern struct property *of_find_property(const struct device_node *np,
224 const char *name, 235 const char *name,
225 int *lenp); 236 int *lenp);
237extern int of_property_read_u8_array(const struct device_node *np,
238 const char *propname, u8 *out_values, size_t sz);
239extern int of_property_read_u16_array(const struct device_node *np,
240 const char *propname, u16 *out_values, size_t sz);
226extern int of_property_read_u32_array(const struct device_node *np, 241extern int of_property_read_u32_array(const struct device_node *np,
227 const char *propname, 242 const char *propname,
228 u32 *out_values, 243 u32 *out_values,
@@ -255,7 +270,7 @@ extern int of_n_size_cells(struct device_node *np);
255extern const struct of_device_id *of_match_node( 270extern const struct of_device_id *of_match_node(
256 const struct of_device_id *matches, const struct device_node *node); 271 const struct of_device_id *matches, const struct device_node *node);
257extern int of_modalias_node(struct device_node *node, char *modalias, int len); 272extern int of_modalias_node(struct device_node *node, char *modalias, int len);
258extern struct device_node *of_parse_phandle(struct device_node *np, 273extern struct device_node *of_parse_phandle(const struct device_node *np,
259 const char *phandle_name, 274 const char *phandle_name,
260 int index); 275 int index);
261extern int of_parse_phandle_with_args(struct device_node *np, 276extern int of_parse_phandle_with_args(struct device_node *np,
@@ -364,6 +379,18 @@ static inline struct device_node *of_find_compatible_node(
364 return NULL; 379 return NULL;
365} 380}
366 381
382static inline int of_property_read_u8_array(const struct device_node *np,
383 const char *propname, u8 *out_values, size_t sz)
384{
385 return -ENOSYS;
386}
387
388static inline int of_property_read_u16_array(const struct device_node *np,
389 const char *propname, u16 *out_values, size_t sz)
390{
391 return -ENOSYS;
392}
393
367static inline int of_property_read_u32_array(const struct device_node *np, 394static inline int of_property_read_u32_array(const struct device_node *np,
368 const char *propname, 395 const char *propname,
369 u32 *out_values, size_t sz) 396 u32 *out_values, size_t sz)
@@ -411,7 +438,7 @@ static inline int of_property_match_string(struct device_node *np,
411 return -ENOSYS; 438 return -ENOSYS;
412} 439}
413 440
414static inline struct device_node *of_parse_phandle(struct device_node *np, 441static inline struct device_node *of_parse_phandle(const struct device_node *np,
415 const char *phandle_name, 442 const char *phandle_name,
416 int index) 443 int index)
417{ 444{
@@ -470,6 +497,20 @@ static inline bool of_property_read_bool(const struct device_node *np,
470 return prop ? true : false; 497 return prop ? true : false;
471} 498}
472 499
500static inline int of_property_read_u8(const struct device_node *np,
501 const char *propname,
502 u8 *out_value)
503{
504 return of_property_read_u8_array(np, propname, out_value, 1);
505}
506
507static inline int of_property_read_u16(const struct device_node *np,
508 const char *propname,
509 u16 *out_value)
510{
511 return of_property_read_u16_array(np, propname, out_value, 1);
512}
513
473static inline int of_property_read_u32(const struct device_node *np, 514static inline int of_property_read_u32(const struct device_node *np,
474 const char *propname, 515 const char *propname,
475 u32 *out_value) 516 u32 *out_value)