aboutsummaryrefslogtreecommitdiffstats
path: root/include/linux/of.h
diff options
context:
space:
mode:
authorPantelis Antoniou <panto@antoniou-consulting.com>2013-12-13 13:08:59 -0500
committerGrant Likely <grant.likely@linaro.org>2014-03-19 10:58:40 -0400
commit0829f6d1f69e4f2fae4062987ae6531a9af1a2e3 (patch)
tree4081a4bee4a9e193b4de690735b5a3782d100eac /include/linux/of.h
parent8357041a69b368991d1b04d9f1d297f8d71e1314 (diff)
of: device_node kobject lifecycle fixes
After the move to having device nodes be proper kobjects the lifecycle of the node needs to be controlled better. At first convert of_add_node() in the unflattened functions to of_init_node() which initializes the kobject so that of_node_get/put work correctly even before of_init is called. Afterwards introduce of_node_is_initialized & of_node_is_attached that query the underlying kobject about the state (attached means kobj is visible in sysfs) Using that make sure the lifecycle of the tree is correct at all times. Signed-off-by: Pantelis Antoniou <panto@antoniou-consulting.com> [grant.likely: moved of_node_init() calls, fixed up locking, and dropped __of_populate() hunks] Signed-off-by: Grant Likely <grant.likely@linaro.org>
Diffstat (limited to 'include/linux/of.h')
-rw-r--r--include/linux/of.h19
1 files changed, 19 insertions, 0 deletions
diff --git a/include/linux/of.h b/include/linux/of.h
index 257994a420f3..a8b9dad90c64 100644
--- a/include/linux/of.h
+++ b/include/linux/of.h
@@ -76,6 +76,25 @@ struct of_phandle_args {
76 76
77extern int of_node_add(struct device_node *node); 77extern int of_node_add(struct device_node *node);
78 78
79/* initialize a node */
80extern struct kobj_type of_node_ktype;
81static inline void of_node_init(struct device_node *node)
82{
83 kobject_init(&node->kobj, &of_node_ktype);
84}
85
86/* true when node is initialized */
87static inline int of_node_is_initialized(struct device_node *node)
88{
89 return node && node->kobj.state_initialized;
90}
91
92/* true when node is attached (i.e. present on sysfs) */
93static inline int of_node_is_attached(struct device_node *node)
94{
95 return node && node->kobj.state_in_sysfs;
96}
97
79#ifdef CONFIG_OF_DYNAMIC 98#ifdef CONFIG_OF_DYNAMIC
80extern struct device_node *of_node_get(struct device_node *node); 99extern struct device_node *of_node_get(struct device_node *node);
81extern void of_node_put(struct device_node *node); 100extern void of_node_put(struct device_node *node);