/* This function returns a pointer to the corresponding &struct ubi_ltree_entry object if the logical eraseblock is locked and NULL if it is not. @ubi->ltree_lock has to be locked.  */
static struct ubi_ltree_entry* ltree_lookup(struct ubi_device *ubi, int vol_id, int lnum)
/* This function returns a pointer to the corresponding &struct ubi_ltree_entry object if the logical eraseblock is locked and NULL if it is not. @ubi->ltree_lock has to be locked.  */
static struct ubi_ltree_entry* ltree_lookup(struct ubi_device *ubi, int vol_id, int lnum)
{
	struct rb_node *p;
	p = ubi->ltree.rb_node;
	while (p) {
		struct ubi_ltree_entry *le;
		le = rb_entry(p, struct ubi_ltree_entry, rb);
		if (vol_id < le->vol_id)
			p = p->rb_left;
		else if (vol_id > le->vol_id)
			p = p->rb_right;
		else {
			if (lnum < le->lnum)
				p = p->rb_left;
			else if (lnum > le->lnum)
				p = p->rb_right;
			else
				return le;
		}
	}
	return NULL;
}