/* assign_aeb_to_av - assigns a SEB to a given ainf_volume and removes it from it's original list. @ai: ubi_attach_info object @aeb: the to be assigned SEB @av: target scan volume  */
static void assign_aeb_to_av(struct ubi_attach_info *ai, struct ubi_ainf_peb *aeb, struct ubi_ainf_volume *av)
/* assign_aeb_to_av - assigns a SEB to a given ainf_volume and removes it from it's original list. @ai: ubi_attach_info object @aeb: the to be assigned SEB @av: target scan volume  */
static void assign_aeb_to_av(struct ubi_attach_info *ai, struct ubi_ainf_peb *aeb, struct ubi_ainf_volume *av)
{
	struct ubi_ainf_peb *tmp_aeb;
	struct rb_node **p = &ai->volumes.rb_node, *parent = NULL;
	p = &av->root.rb_node;
	while (*p) {
		parent = *p;
		tmp_aeb = rb_entry(parent, struct ubi_ainf_peb, u.rb);
		if (aeb->lnum != tmp_aeb->lnum) {
			if (aeb->lnum < tmp_aeb->lnum)
				p = &(*p)->rb_left;
			else
				p = &(*p)->rb_right;
			continue;
		} else
			break;
	}
	list_del(&aeb->u.list);
	av->leb_count++;
	rb_link_node(&aeb->u.rb, parent, p);
	rb_insert_color(&aeb->u.rb, &av->root);
}