xref: /kernel/linux/linux-6.6/drivers/mtd/ubi/wl.h (revision 62306a36)
162306a36Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0 */
262306a36Sopenharmony_ci#ifndef UBI_WL_H
362306a36Sopenharmony_ci#define UBI_WL_H
462306a36Sopenharmony_ci#ifdef CONFIG_MTD_UBI_FASTMAP
562306a36Sopenharmony_cistatic void update_fastmap_work_fn(struct work_struct *wrk);
662306a36Sopenharmony_cistatic struct ubi_wl_entry *find_anchor_wl_entry(struct rb_root *root);
762306a36Sopenharmony_cistatic struct ubi_wl_entry *get_peb_for_wl(struct ubi_device *ubi);
862306a36Sopenharmony_cistatic struct ubi_wl_entry *next_peb_for_wl(struct ubi_device *ubi);
962306a36Sopenharmony_cistatic bool need_wear_leveling(struct ubi_device *ubi);
1062306a36Sopenharmony_cistatic void ubi_fastmap_close(struct ubi_device *ubi);
1162306a36Sopenharmony_cistatic inline void ubi_fastmap_init(struct ubi_device *ubi, int *count)
1262306a36Sopenharmony_ci{
1362306a36Sopenharmony_ci	/* Reserve enough LEBs to store two fastmaps. */
1462306a36Sopenharmony_ci	*count += (ubi->fm_size / ubi->leb_size) * 2;
1562306a36Sopenharmony_ci	INIT_WORK(&ubi->fm_work, update_fastmap_work_fn);
1662306a36Sopenharmony_ci}
1762306a36Sopenharmony_cistatic struct ubi_wl_entry *may_reserve_for_fm(struct ubi_device *ubi,
1862306a36Sopenharmony_ci					       struct ubi_wl_entry *e,
1962306a36Sopenharmony_ci					       struct rb_root *root);
2062306a36Sopenharmony_ci#else /* !CONFIG_MTD_UBI_FASTMAP */
2162306a36Sopenharmony_cistatic struct ubi_wl_entry *get_peb_for_wl(struct ubi_device *ubi);
2262306a36Sopenharmony_cistatic inline void ubi_fastmap_close(struct ubi_device *ubi) { }
2362306a36Sopenharmony_cistatic inline void ubi_fastmap_init(struct ubi_device *ubi, int *count) { }
2462306a36Sopenharmony_cistatic struct ubi_wl_entry *may_reserve_for_fm(struct ubi_device *ubi,
2562306a36Sopenharmony_ci					       struct ubi_wl_entry *e,
2662306a36Sopenharmony_ci					       struct rb_root *root) {
2762306a36Sopenharmony_ci	return e;
2862306a36Sopenharmony_ci}
2962306a36Sopenharmony_ci#endif /* CONFIG_MTD_UBI_FASTMAP */
3062306a36Sopenharmony_ci#endif /* UBI_WL_H */
31