/* Returns 0 on success, < 0 indicates an internal error.  */
static int add_aeb(struct ubi_attach_info *ai, struct list_head *list, int pnum, int ec, int scrub)
/* Returns 0 on success, < 0 indicates an internal error.  */
static int add_aeb(struct ubi_attach_info *ai, struct list_head *list, int pnum, int ec, int scrub)
{
	struct ubi_ainf_peb *aeb;
	aeb = kmem_cache_alloc(ai->aeb_slab_cache, GFP_KERNEL);
	if (!aeb)
		return -ENOMEM;
	aeb->pnum = pnum;
	aeb->ec = ec;
	aeb->lnum = -1;
	aeb->scrub = scrub;
	aeb->copy_flag = aeb->sqnum = 0;
	ai->ec_sum += aeb->ec;
	ai->ec_count++;
	if (ai->max_ec < aeb->ec)
		ai->max_ec = aeb->ec;
	if (ai->min_ec > aeb->ec)
		ai->min_ec = aeb->ec;
	list_add_tail(&aeb->u.list, list);
	return 0;
}