/* Note, we use (erase counter, physical eraseblock number) pairs as keys in the @ubi->used and @ubi->free RB-trees.  */
static void wl_tree_add(struct ubi_wl_entry *e, struct rb_root *root)
/* Note, we use (erase counter, physical eraseblock number) pairs as keys in the @ubi->used and @ubi->free RB-trees.  */
static void wl_tree_add(struct ubi_wl_entry *e, struct rb_root *root)
{
	struct rb_node **p, *parent = NULL;
	p = &root->rb_node;
	while (*p) {
		struct ubi_wl_entry *e1;
		parent = *p;
		e1 = rb_entry(parent, struct ubi_wl_entry, u.rb);
		if (e->ec < e1->ec)
			p = &(*p)->rb_left;
		else if (e->ec > e1->ec)
			p = &(*p)->rb_right;
		else {
			ubi_assert(e->pnum != e1->pnum);
			if (e->pnum < e1->pnum)
				p = &(*p)->rb_left;
			else
				p = &(*p)->rb_right;
		}
	}
	rb_link_node(&e->u.rb, parent, p);
	rb_insert_color(&e->u.rb, root);
}