diff options
author | Grant Likely <grant.likely@secretlab.ca> | 2010-01-28 15:52:53 -0500 |
---|---|---|
committer | Grant Likely <grant.likely@secretlab.ca> | 2010-01-28 15:52:53 -0500 |
commit | 923f7e30b480438f1e86e01e5cde814248b59a39 (patch) | |
tree | ad9cb0e701b0a8ef2ac5113fbd4a42118039edd6 /arch/microblaze | |
parent | 1f43cfb9474d1c4f22598b6e3213ec035be6dd56 (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/microblaze')
-rw-r--r-- | arch/microblaze/kernel/prom.c | 74 |
1 files changed, 0 insertions, 74 deletions
diff --git a/arch/microblaze/kernel/prom.c b/arch/microblaze/kernel/prom.c index 16a001c71e2e..46407e643926 100644 --- a/arch/microblaze/kernel/prom.c +++ b/arch/microblaze/kernel/prom.c | |||
@@ -350,80 +350,6 @@ struct device_node *of_find_node_by_phandle(phandle handle) | |||
350 | } | 350 | } |
351 | EXPORT_SYMBOL(of_find_node_by_phandle); | 351 | EXPORT_SYMBOL(of_find_node_by_phandle); |
352 | 352 | ||
353 | /** | ||
354 | * of_node_get - Increment refcount of a node | ||
355 | * @node: Node to inc refcount, NULL is supported to | ||
356 | * simplify writing of callers | ||
357 | * | ||
358 | * Returns node. | ||
359 | */ | ||
360 | struct device_node *of_node_get(struct device_node *node) | ||
361 | { | ||
362 | if (node) | ||
363 | kref_get(&node->kref); | ||
364 | return node; | ||
365 | } | ||
366 | EXPORT_SYMBOL(of_node_get); | ||
367 | |||
368 | static inline struct device_node *kref_to_device_node(struct kref *kref) | ||
369 | { | ||
370 | return container_of(kref, struct device_node, kref); | ||
371 | } | ||
372 | |||
373 | /** | ||
374 | * of_node_release - release a dynamically allocated node | ||
375 | * @kref: kref element of the node to be released | ||
376 | * | ||
377 | * In of_node_put() this function is passed to kref_put() | ||
378 | * as the destructor. | ||
379 | */ | ||
380 | static void of_node_release(struct kref *kref) | ||
381 | { | ||
382 | struct device_node *node = kref_to_device_node(kref); | ||
383 | struct property *prop = node->properties; | ||
384 | |||
385 | /* We should never be releasing nodes that haven't been detached. */ | ||
386 | if (!of_node_check_flag(node, OF_DETACHED)) { | ||
387 | printk(KERN_INFO "WARNING: Bad of_node_put() on %s\n", | ||
388 | node->full_name); | ||
389 | dump_stack(); | ||
390 | kref_init(&node->kref); | ||
391 | return; | ||
392 | } | ||
393 | |||
394 | if (!of_node_check_flag(node, OF_DYNAMIC)) | ||
395 | return; | ||
396 | |||
397 | while (prop) { | ||
398 | struct property *next = prop->next; | ||
399 | kfree(prop->name); | ||
400 | kfree(prop->value); | ||
401 | kfree(prop); | ||
402 | prop = next; | ||
403 | |||
404 | if (!prop) { | ||
405 | prop = node->deadprops; | ||
406 | node->deadprops = NULL; | ||
407 | } | ||
408 | } | ||
409 | kfree(node->full_name); | ||
410 | kfree(node->data); | ||
411 | kfree(node); | ||
412 | } | ||
413 | |||
414 | /** | ||
415 | * of_node_put - Decrement refcount of a node | ||
416 | * @node: Node to dec refcount, NULL is supported to | ||
417 | * simplify writing of callers | ||
418 | * | ||
419 | */ | ||
420 | void of_node_put(struct device_node *node) | ||
421 | { | ||
422 | if (node) | ||
423 | kref_put(&node->kref, of_node_release); | ||
424 | } | ||
425 | EXPORT_SYMBOL(of_node_put); | ||
426 | |||
427 | /* | 353 | /* |
428 | * Plug a device node into the tree and global list. | 354 | * Plug a device node into the tree and global list. |
429 | */ | 355 | */ |