diff options
author | Grant Likely <grant.likely@secretlab.ca> | 2012-06-04 01:04:33 -0400 |
---|---|---|
committer | Grant Likely <grant.likely@secretlab.ca> | 2012-06-15 13:44:03 -0400 |
commit | efd68e7254503f3207805f674a1ea1d743f5dfe2 (patch) | |
tree | d5d0dc0b2b6fdf41ff57eb4b21501fbfe3a56d64 /include/linux/of.h | |
parent | cfaf025112d3856637ff34a767ef785ef5cf2ca9 (diff) |
devicetree: add helper inline for retrieving a node's full name
The pattern (np ? np->full_name : "<none>") is rather common in the
kernel, but can also make for quite long lines. This patch adds a new
inline function, of_node_full_name() so that the test for a valid node
pointer doesn't need to be open coded at all call sites.
Signed-off-by: Grant Likely <grant.likely@secretlab.ca>
Cc: Paul Mundt <lethal@linux-sh.org>
Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org>
Cc: Thomas Gleixner <tglx@linutronix.de>
Diffstat (limited to 'include/linux/of.h')
-rw-r--r-- | include/linux/of.h | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/include/linux/of.h b/include/linux/of.h index 2ec1083af7ff..1012377cae92 100644 --- a/include/linux/of.h +++ b/include/linux/of.h | |||
@@ -163,6 +163,11 @@ static inline int of_node_to_nid(struct device_node *np) { return -1; } | |||
163 | #define of_node_to_nid of_node_to_nid | 163 | #define of_node_to_nid of_node_to_nid |
164 | #endif | 164 | #endif |
165 | 165 | ||
166 | static inline const char* of_node_full_name(struct device_node *np) | ||
167 | { | ||
168 | return np ? np->full_name : "<no-node>"; | ||
169 | } | ||
170 | |||
166 | extern struct device_node *of_find_node_by_name(struct device_node *from, | 171 | extern struct device_node *of_find_node_by_name(struct device_node *from, |
167 | const char *name); | 172 | const char *name); |
168 | #define for_each_node_by_name(dn, name) \ | 173 | #define for_each_node_by_name(dn, name) \ |
@@ -303,6 +308,11 @@ const char *of_prop_next_string(struct property *prop, const char *cur); | |||
303 | 308 | ||
304 | #else /* CONFIG_OF */ | 309 | #else /* CONFIG_OF */ |
305 | 310 | ||
311 | static inline const char* of_node_full_name(struct device_node *np) | ||
312 | { | ||
313 | return "<no-node>"; | ||
314 | } | ||
315 | |||
306 | static inline bool of_have_populated_dt(void) | 316 | static inline bool of_have_populated_dt(void) |
307 | { | 317 | { |
308 | return false; | 318 | return false; |