aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--drivers/mtd/ubi/wl.c30
1 files changed, 23 insertions, 7 deletions
diff --git a/drivers/mtd/ubi/wl.c b/drivers/mtd/ubi/wl.c
index 6f2ac865ff05..ca1b31385eb5 100644
--- a/drivers/mtd/ubi/wl.c
+++ b/drivers/mtd/ubi/wl.c
@@ -278,6 +278,27 @@ static int in_wl_tree(struct ubi_wl_entry *e, struct rb_root *root)
278} 278}
279 279
280/** 280/**
281 * in_pq - check if a wear-leveling entry is present in the protection queue.
282 * @ubi: UBI device description object
283 * @e: the wear-leveling entry to check
284 *
285 * This function returns non-zero if @e is in the protection queue and zero
286 * if it is not.
287 */
288static inline int in_pq(const struct ubi_device *ubi, struct ubi_wl_entry *e)
289{
290 struct ubi_wl_entry *p;
291 int i;
292
293 for (i = 0; i < UBI_PROT_QUEUE_LEN; ++i)
294 list_for_each_entry(p, &ubi->pq[i], u.list)
295 if (p == e)
296 return 1;
297
298 return 0;
299}
300
301/**
281 * prot_queue_add - add physical eraseblock to the protection queue. 302 * prot_queue_add - add physical eraseblock to the protection queue.
282 * @ubi: UBI device description object 303 * @ubi: UBI device description object
283 * @e: the physical eraseblock to add 304 * @e: the physical eraseblock to add
@@ -1848,16 +1869,11 @@ static int self_check_in_wl_tree(const struct ubi_device *ubi,
1848static int self_check_in_pq(const struct ubi_device *ubi, 1869static int self_check_in_pq(const struct ubi_device *ubi,
1849 struct ubi_wl_entry *e) 1870 struct ubi_wl_entry *e)
1850{ 1871{
1851 struct ubi_wl_entry *p;
1852 int i;
1853
1854 if (!ubi_dbg_chk_gen(ubi)) 1872 if (!ubi_dbg_chk_gen(ubi))
1855 return 0; 1873 return 0;
1856 1874
1857 for (i = 0; i < UBI_PROT_QUEUE_LEN; ++i) 1875 if (in_pq(ubi, e))
1858 list_for_each_entry(p, &ubi->pq[i], u.list) 1876 return 0;
1859 if (p == e)
1860 return 0;
1861 1877
1862 ubi_err(ubi, "self-check failed for PEB %d, EC %d, Protect queue", 1878 ubi_err(ubi, "self-check failed for PEB %d, EC %d, Protect queue",
1863 e->pnum, e->ec); 1879 e->pnum, e->ec);