aboutsummaryrefslogtreecommitdiffstats
path: root/arch/powerpc/kernel/prom.c
diff options
context:
space:
mode:
authorGrant Likely <grant.likely@secretlab.ca>2010-01-28 15:52:53 -0500
committerGrant Likely <grant.likely@secretlab.ca>2010-01-28 15:52:53 -0500
commit923f7e30b480438f1e86e01e5cde814248b59a39 (patch)
treead9cb0e701b0a8ef2ac5113fbd4a42118039edd6 /arch/powerpc/kernel/prom.c
parent1f43cfb9474d1c4f22598b6e3213ec035be6dd56 (diff)
of: Merge of_node_get() and of_node_put()
Merge common code between PowerPC and MicroBlaze Signed-off-by: Grant Likely <grant.likely@secretlab.ca> Tested-by: Wolfram Sang <w.sang@pengutronix.de> Acked-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
Diffstat (limited to 'arch/powerpc/kernel/prom.c')
-rw-r--r--arch/powerpc/kernel/prom.c73
1 files changed, 0 insertions, 73 deletions
diff --git a/arch/powerpc/kernel/prom.c b/arch/powerpc/kernel/prom.c
index caeea9a5fcc2..deccd91d7e81 100644
--- a/arch/powerpc/kernel/prom.c
+++ b/arch/powerpc/kernel/prom.c
@@ -817,79 +817,6 @@ struct device_node *of_find_next_cache_node(struct device_node *np)
817 return NULL; 817 return NULL;
818} 818}
819 819
820/**
821 * of_node_get - Increment refcount of a node
822 * @node: Node to inc refcount, NULL is supported to
823 * simplify writing of callers
824 *
825 * Returns node.
826 */
827struct device_node *of_node_get(struct device_node *node)
828{
829 if (node)
830 kref_get(&node->kref);
831 return node;
832}
833EXPORT_SYMBOL(of_node_get);
834
835static inline struct device_node * kref_to_device_node(struct kref *kref)
836{
837 return container_of(kref, struct device_node, kref);
838}
839
840/**
841 * of_node_release - release a dynamically allocated node
842 * @kref: kref element of the node to be released
843 *
844 * In of_node_put() this function is passed to kref_put()
845 * as the destructor.
846 */
847static void of_node_release(struct kref *kref)
848{
849 struct device_node *node = kref_to_device_node(kref);
850 struct property *prop = node->properties;
851
852 /* We should never be releasing nodes that haven't been detached. */
853 if (!of_node_check_flag(node, OF_DETACHED)) {
854 printk("WARNING: Bad of_node_put() on %s\n", node->full_name);
855 dump_stack();
856 kref_init(&node->kref);
857 return;
858 }
859
860 if (!of_node_check_flag(node, OF_DYNAMIC))
861 return;
862
863 while (prop) {
864 struct property *next = prop->next;
865 kfree(prop->name);
866 kfree(prop->value);
867 kfree(prop);
868 prop = next;
869
870 if (!prop) {
871 prop = node->deadprops;
872 node->deadprops = NULL;
873 }
874 }
875 kfree(node->full_name);
876 kfree(node->data);
877 kfree(node);
878}
879
880/**
881 * of_node_put - Decrement refcount of a node
882 * @node: Node to dec refcount, NULL is supported to
883 * simplify writing of callers
884 *
885 */
886void of_node_put(struct device_node *node)
887{
888 if (node)
889 kref_put(&node->kref, of_node_release);
890}
891EXPORT_SYMBOL(of_node_put);
892
893/* 820/*
894 * Plug a device node into the tree and global list. 821 * Plug a device node into the tree and global list.
895 */ 822 */