aboutsummaryrefslogtreecommitdiff
path: root/include/linux
diff options
context:
space:
mode:
authorPantelis Antoniou <panto@antoniou-consulting.com>2013-12-13 20:08:59 +0200
committerMark Brown <broonie@kernel.org>2015-02-16 13:33:47 +0900
commitb74e9e159702d39152b9f270c88db0084486c90c (patch)
treebee8f2b90642b2a9452e6698fb549f5729a32a34 /include/linux
parent43bba285304b662301192d2106cfb8e22d299215 (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> (cherry picked from commit 0829f6d1f69e4f2fae4062987ae6531a9af1a2e3) Signed-off-by: Mark Brown <broonie@kernel.org>
Diffstat (limited to 'include/linux')
-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 4c7fa3b04c05..d629a9dc60ce 100644
--- a/include/linux/of.h
+++ b/include/linux/of.h
@@ -76,6 +76,25 @@ struct of_phandle_args {
extern int of_node_add(struct device_node *node);
+/* initialize a node */
+extern struct kobj_type of_node_ktype;
+static inline void of_node_init(struct device_node *node)
+{
+ kobject_init(&node->kobj, &of_node_ktype);
+}
+
+/* true when node is initialized */
+static inline int of_node_is_initialized(struct device_node *node)
+{
+ return node && node->kobj.state_initialized;
+}
+
+/* true when node is attached (i.e. present on sysfs) */
+static inline int of_node_is_attached(struct device_node *node)
+{
+ return node && node->kobj.state_in_sysfs;
+}
+
#ifdef CONFIG_OF_DYNAMIC
extern struct device_node *of_node_get(struct device_node *node);
extern void of_node_put(struct device_node *node);