
From: Werner Almesberger <werner@almesberger.net>

Allow prio_tree_next to be used as the only function for tree traversal,
similar to how vma_prio_tree_next works.

This patch isn't needed for the generalization, but since it affects the API,
it's better to include it first.

Signed-off-by: Werner Almesberger <werner@almesberger.net>
Signed-off-by: Andrew Morton <akpm@osdl.org>
---

 25-akpm/include/linux/prio_tree.h |    1 +
 25-akpm/mm/prio_tree.c            |    5 ++++-
 2 files changed, 5 insertions(+), 1 deletion(-)

diff -puN include/linux/prio_tree.h~prio_tree-roll-call-to-prio_tree_first-into-prio_tree_next include/linux/prio_tree.h
--- 25/include/linux/prio_tree.h~prio_tree-roll-call-to-prio_tree_first-into-prio_tree_next	Fri Dec 17 15:37:25 2004
+++ 25-akpm/include/linux/prio_tree.h	Fri Dec 17 15:37:25 2004
@@ -29,6 +29,7 @@ static inline void prio_tree_iter_init(s
 	iter->root = root;
 	iter->r_index = r_index;
 	iter->h_index = h_index;
+	iter->cur = NULL;
 }
 
 #define INIT_PRIO_TREE_ROOT(ptr)	\
diff -puN mm/prio_tree.c~prio_tree-roll-call-to-prio_tree_first-into-prio_tree_next mm/prio_tree.c
--- 25/mm/prio_tree.c~prio_tree-roll-call-to-prio_tree_first-into-prio_tree_next	Fri Dec 17 15:37:25 2004
+++ 25-akpm/mm/prio_tree.c	Fri Dec 17 15:37:25 2004
@@ -457,6 +457,9 @@ static struct prio_tree_node *prio_tree_
 {
 	unsigned long r_index, h_index;
 
+	if (iter->cur == NULL)
+		return prio_tree_first(iter);
+
 repeat:
 	while (prio_tree_left(iter, &r_index, &h_index))
 		if (overlap(iter, r_index, h_index))
@@ -620,7 +623,7 @@ struct vm_area_struct *vma_prio_tree_nex
 		/*
 		 * First call is with NULL vma
 		 */
-		ptr = prio_tree_first(iter);
+		ptr = prio_tree_next(iter);
 		if (ptr) {
 			next = prio_tree_entry(ptr, struct vm_area_struct,
 						shared.prio_tree_node);
_
