Lines Matching refs:ai

136 static int add_aeb(struct ubi_attach_info *ai, struct list_head *list,  in add_aeb()  argument
141 aeb = ubi_alloc_aeb(ai, pnum, ec); in add_aeb()
149 ai->ec_sum += aeb->ec; in add_aeb()
150 ai->ec_count++; in add_aeb()
152 if (ai->max_ec < aeb->ec) in add_aeb()
153 ai->max_ec = aeb->ec; in add_aeb()
155 if (ai->min_ec > aeb->ec) in add_aeb()
156 ai->min_ec = aeb->ec; in add_aeb()
175 static struct ubi_ainf_volume *add_vol(struct ubi_attach_info *ai, int vol_id, in add_vol() argument
181 av = ubi_add_av(ai, vol_id); in add_vol()
203 static void assign_aeb_to_av(struct ubi_attach_info *ai, in assign_aeb_to_av() argument
242 static int update_vol(struct ubi_device *ubi, struct ubi_attach_info *ai, in update_vol() argument
269 ubi_free_aeb(ai, new_aeb); in update_vol()
280 victim = ubi_alloc_aeb(ai, aeb->pnum, aeb->ec); in update_vol()
284 list_add_tail(&victim->u.list, &ai->erase); in update_vol()
298 ubi_free_aeb(ai, new_aeb); in update_vol()
304 list_add_tail(&new_aeb->u.list, &ai->erase); in update_vol()
336 static int process_pool_aeb(struct ubi_device *ubi, struct ubi_attach_info *ai, in process_pool_aeb() argument
344 ubi_free_aeb(ai, new_aeb); in process_pool_aeb()
350 av = ubi_find_av(ai, vol_id); in process_pool_aeb()
353 ubi_free_aeb(ai, new_aeb); in process_pool_aeb()
359 return update_vol(ubi, ai, av, new_vh, new_aeb); in process_pool_aeb()
370 static void unmap_peb(struct ubi_attach_info *ai, int pnum) in unmap_peb() argument
376 ubi_rb_for_each_entry(node, av, &ai->volumes, rb) { in unmap_peb()
381 ubi_free_aeb(ai, aeb); in unmap_peb()
400 static int scan_pool(struct ubi_device *ubi, struct ubi_attach_info *ai, in scan_pool() argument
465 unmap_peb(ai, pnum); in scan_pool()
471 add_aeb(ai, free, pnum, ec, scrub); in scan_pool()
479 new_aeb = ubi_alloc_aeb(ai, pnum, be64_to_cpu(ech->ec)); in scan_pool()
493 err = process_pool_aeb(ubi, ai, vh, new_aeb); in scan_pool()
517 static int count_fastmap_pebs(struct ubi_attach_info *ai) in count_fastmap_pebs() argument
524 list_for_each_entry(aeb, &ai->erase, u.list) in count_fastmap_pebs()
527 list_for_each_entry(aeb, &ai->free, u.list) in count_fastmap_pebs()
530 ubi_rb_for_each_entry(rb1, av, &ai->volumes, rb) in count_fastmap_pebs()
547 struct ubi_attach_info *ai, in ubi_attach_fastmap() argument
566 ai->min_ec = UBI_MAX_ERASECOUNTER; in ubi_attach_fastmap()
569 ai->max_sqnum = fmsb->sqnum; in ubi_attach_fastmap()
641 add_aeb(ai, &ai->free, be32_to_cpu(fmec->pnum), in ubi_attach_fastmap()
652 add_aeb(ai, &used, be32_to_cpu(fmec->pnum), in ubi_attach_fastmap()
663 add_aeb(ai, &used, be32_to_cpu(fmec->pnum), in ubi_attach_fastmap()
674 add_aeb(ai, &ai->erase, be32_to_cpu(fmec->pnum), in ubi_attach_fastmap()
678 ai->mean_ec = div_u64(ai->ec_sum, ai->ec_count); in ubi_attach_fastmap()
679 ai->bad_peb_count = be32_to_cpu(fmhdr->bad_peb_count); in ubi_attach_fastmap()
694 av = add_vol(ai, be32_to_cpu(fmvhdr->vol_id), in ubi_attach_fastmap()
708 ai->vols_found++; in ubi_attach_fastmap()
709 if (ai->highest_vol_id < be32_to_cpu(fmvhdr->vol_id)) in ubi_attach_fastmap()
710 ai->highest_vol_id = be32_to_cpu(fmvhdr->vol_id); in ubi_attach_fastmap()
748 assign_aeb_to_av(ai, aeb, av); in ubi_attach_fastmap()
755 ret = scan_pool(ubi, ai, fmpl->pebs, pool_size, &max_sqnum, &free); in ubi_attach_fastmap()
759 ret = scan_pool(ubi, ai, fmpl_wl->pebs, wl_pool_size, &max_sqnum, &free); in ubi_attach_fastmap()
763 if (max_sqnum > ai->max_sqnum) in ubi_attach_fastmap()
764 ai->max_sqnum = max_sqnum; in ubi_attach_fastmap()
767 list_move_tail(&tmp_aeb->u.list, &ai->free); in ubi_attach_fastmap()
770 list_move_tail(&tmp_aeb->u.list, &ai->erase); in ubi_attach_fastmap()
780 if (WARN_ON(count_fastmap_pebs(ai) != ubi->peb_count - in ubi_attach_fastmap()
781 ai->bad_peb_count - fm->used_blocks)) in ubi_attach_fastmap()
791 ubi_free_aeb(ai, tmp_aeb); in ubi_attach_fastmap()
795 ubi_free_aeb(ai, tmp_aeb); in ubi_attach_fastmap()
805 static int find_fm_anchor(struct ubi_attach_info *ai) in find_fm_anchor() argument
811 list_for_each_entry(aeb, &ai->fastmap, u.list) { in find_fm_anchor()
821 static struct ubi_ainf_peb *clone_aeb(struct ubi_attach_info *ai, in clone_aeb() argument
826 new = ubi_alloc_aeb(ai, old->pnum, old->ec); in clone_aeb()
850 int ubi_scan_fastmap(struct ubi_device *ubi, struct ubi_attach_info *ai, in ubi_scan_fastmap() argument
872 new = clone_aeb(ai, aeb); in ubi_scan_fastmap()
876 list_add(&new->u.list, &ai->fastmap); in ubi_scan_fastmap()
1043 ret = ubi_attach_fastmap(ubi, ai, fm); in ubi_scan_fastmap()