/* leb_write_unlock - unlock logical eraseblock. @ubi: UBI device description object @vol_id: volume ID @lnum: logical eraseblock number  */
static void leb_write_unlock(struct ubi_device *ubi, int vol_id, int lnum)
/* leb_write_unlock - unlock logical eraseblock. @ubi: UBI device description object @vol_id: volume ID @lnum: logical eraseblock number  */
static void leb_write_unlock(struct ubi_device *ubi, int vol_id, int lnum)
{
	int _free;
	struct ubi_ltree_entry *le;
	spin_lock(&ubi->ltree_lock);
	le = ltree_lookup(ubi, vol_id, lnum);
	le->users -= 1;
	ubi_assert(le->users >= 0);
	if (le->users == 0) {
		rb_erase(&le->rb, &ubi->ltree);
		_free = 1;
	} else
		_free = 0;
	spin_unlock(&ubi->ltree_lock);
	up_write(&le->mutex);
	if (_free)
		kfree(le);
}