xref: /linux/drivers/mtd/ubi/wl.h (revision 3c4fc7bf4c9e66fe71abcbf93f62f4ddb89b7f15)
1 /* SPDX-License-Identifier: GPL-2.0 */
2 #ifndef UBI_WL_H
3 #define UBI_WL_H
4 #ifdef CONFIG_MTD_UBI_FASTMAP
5 static void update_fastmap_work_fn(struct work_struct *wrk);
6 static struct ubi_wl_entry *find_anchor_wl_entry(struct rb_root *root);
7 static struct ubi_wl_entry *get_peb_for_wl(struct ubi_device *ubi);
8 static struct ubi_wl_entry *next_peb_for_wl(struct ubi_device *ubi);
9 static bool need_wear_leveling(struct ubi_device *ubi);
10 static void ubi_fastmap_close(struct ubi_device *ubi);
11 static inline void ubi_fastmap_init(struct ubi_device *ubi, int *count)
12 {
13 	/* Reserve enough LEBs to store two fastmaps. */
14 	*count += (ubi->fm_size / ubi->leb_size) * 2;
15 	INIT_WORK(&ubi->fm_work, update_fastmap_work_fn);
16 }
17 static struct ubi_wl_entry *may_reserve_for_fm(struct ubi_device *ubi,
18 					       struct ubi_wl_entry *e,
19 					       struct rb_root *root);
20 #else /* !CONFIG_MTD_UBI_FASTMAP */
21 static struct ubi_wl_entry *get_peb_for_wl(struct ubi_device *ubi);
22 static inline void ubi_fastmap_close(struct ubi_device *ubi) { }
23 static inline void ubi_fastmap_init(struct ubi_device *ubi, int *count) { }
24 static struct ubi_wl_entry *may_reserve_for_fm(struct ubi_device *ubi,
25 					       struct ubi_wl_entry *e,
26 					       struct rb_root *root) {
27 	return e;
28 }
29 #endif /* CONFIG_MTD_UBI_FASTMAP */
30 #endif /* UBI_WL_H */
31