Skip to contentSkip to conversation

jffs2: use rb_first() and rb_last() cleanup

PATCH New Akinobu Mita 1 participant 1 message Oct 12, 2006 Journalling flash file system V2 (JFFS2)

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 jffs2: use rb_first() and rb_last() cleanup

Use rb_first() and rb_last() to implement frag_first() and frag_last().

Cc David Woodhouse <[email protected]>
 fs/jffs2/nodelist.h |   10 ++++------
 1 file changed, 4 insertions(+), 6 deletions(-)
fs/jffs2/nodelist.h +4 -6
Index: work-fault-inject/fs/jffs2/nodelist.h
===================================================================
@@ -294,23 +294,21 @@ static inline int jffs2_encode_dev(union
 
 static inline struct jffs2_node_frag *frag_first(struct rb_root *root)
 {
-	struct rb_node *node = root->rb_node;
+	struct rb_node *node = rb_first(root);
 
 	if (!node)
 		return NULL;
-	while(node->rb_left)
-		node = node->rb_left;
+
 	return rb_entry(node, struct jffs2_node_frag, rb);
 }
 
 static inline struct jffs2_node_frag *frag_last(struct rb_root *root)
 {
-	struct rb_node *node = root->rb_node;
+	struct rb_node *node = rb_last(root);
 
 	if (!node)
 		return NULL;
-	while(node->rb_right)
-		node = node->rb_right;
+
 	return rb_entry(node, struct jffs2_node_frag, rb);
 }