@@ -49,6 +49,20 @@ void of_node_put(struct device_node *node)
}
EXPORT_SYMBOL(of_node_put);
+/**
+ * of_node_read() - read refcount of a node
+ * @node: Node to dec refcount, NULL is supported to simplify writing of
+ * callers
+ */
+unsigned int of_node_read(struct device_node *node)
+{
+ if (node)
+ return kobject_read(&node->kobj);
+
+ return 0;
+}
+EXPORT_SYMBOL(of_node_read);
+
static BLOCKING_NOTIFIER_HEAD(of_reconfig_chain);
int of_reconfig_notifier_register(struct notifier_block *nb)
@@ -122,6 +122,7 @@ static inline void of_node_init(struct device_node *node)
#ifdef CONFIG_OF_DYNAMIC
extern struct device_node *of_node_get(struct device_node *node);
extern void of_node_put(struct device_node *node);
+unsigned int of_node_read(struct device_node *node);
#else /* CONFIG_OF_DYNAMIC */
/* Dummy ref counting routines - to be implemented later */
static inline struct device_node *of_node_get(struct device_node *node)
@@ -129,6 +130,10 @@ static inline struct device_node *of_node_get(struct device_node *node)
return node;
}
static inline void of_node_put(struct device_node *node) { }
+static inline unsigned int of_node_read(struct device_node *node)
+{
+ return 0;
+}
#endif /* !CONFIG_OF_DYNAMIC */
/* Pointer for first entry in chain of all nodes. */