aboutsummaryrefslogtreecommitdiffstats
path: root/lib/radix-tree.c
diff options
context:
space:
mode:
authorMarcelo Tosatti <marcelo.tosatti@cyclades.com>2005-09-06 18:16:48 -0400
committerLinus Torvalds <torvalds@g5.osdl.org>2005-09-07 19:57:21 -0400
commit32605a18152b246df483fadc1c23854addde8755 (patch)
treecb13f4d0d9040120b5ef6a90c8b174a0619756d0 /lib/radix-tree.c
parent201b6264ff3865090747f58f48e087c3a35e0dbc (diff)
[PATCH] radix_tag_get(): differentiate between no present node and tag unset cases
Simple patch to radix_tree_tag_get() to return different values for non present node and tag unset. The function is not used by any in-kernel callers (yet), but this information is definitely useful. Signed-off-by: Andrew Morton <akpm@osdl.org> Signed-off-by: Linus Torvalds <torvalds@osdl.org>
Diffstat (limited to 'lib/radix-tree.c')
-rw-r--r--lib/radix-tree.c17
1 files changed, 9 insertions, 8 deletions
diff --git a/lib/radix-tree.c b/lib/radix-tree.c
index 2e9bd54beba4..b972dd29289d 100644
--- a/lib/radix-tree.c
+++ b/lib/radix-tree.c
@@ -418,15 +418,16 @@ EXPORT_SYMBOL(radix_tree_tag_clear);
418 418
419#ifndef __KERNEL__ /* Only the test harness uses this at present */ 419#ifndef __KERNEL__ /* Only the test harness uses this at present */
420/** 420/**
421 * radix_tree_tag_get - get a tag on a radix tree node 421 * radix_tree_tag_get - get a tag on a radix tree node
422 * @root: radix tree root 422 * @root: radix tree root
423 * @index: index key 423 * @index: index key
424 * @tag: tag index 424 * @tag: tag index
425 * 425 *
426 * Return the search tag corresponging to @index in the radix tree. 426 * Return values:
427 * 427 *
428 * Returns zero if the tag is unset, or if there is no corresponding item 428 * 0: tag not present
429 * in the tree. 429 * 1: tag present, set
430 * -1: tag present, unset
430 */ 431 */
431int radix_tree_tag_get(struct radix_tree_root *root, 432int radix_tree_tag_get(struct radix_tree_root *root,
432 unsigned long index, int tag) 433 unsigned long index, int tag)
@@ -460,7 +461,7 @@ int radix_tree_tag_get(struct radix_tree_root *root,
460 int ret = tag_get(slot, tag, offset); 461 int ret = tag_get(slot, tag, offset);
461 462
462 BUG_ON(ret && saw_unset_tag); 463 BUG_ON(ret && saw_unset_tag);
463 return ret; 464 return ret ? 1 : -1;
464 } 465 }
465 slot = slot->slots[offset]; 466 slot = slot->slots[offset];
466 shift -= RADIX_TREE_MAP_SHIFT; 467 shift -= RADIX_TREE_MAP_SHIFT;