]> git.dujemihanovic.xyz Git - u-boot.git/commitdiff
mtd, ubi: set free_count to zero before walking through erase list
authorHeiko Schocher <hs@denx.de>
Tue, 2 Feb 2016 10:54:35 +0000 (11:54 +0100)
committerHeiko Schocher <hs@denx.de>
Fri, 22 Apr 2016 09:47:37 +0000 (11:47 +0200)
Set free_count to zero before walking through ai->erase list
in wl_init().

As U-Boot has no workqueue/threads, it immediately calls
erase_worker(), which increase for each erased block
free_count. Without this patch, free_count gets after
this initialized to zero in wl_init(), so the free_count
variable always has the maybe wrong value 0.

Detected this behaviour on the dxr2 board, where the
UBI fastmap gets not written when attaching/dettaching
on an empty NAND. It drops instead the error message:

could not find any anchor PEB

With this patch, fastmap gets written on dettach.

Signed-off-by: Heiko Schocher <hs@denx.de>
Reviewed-by: Boris Brezillon <boris.brezillon@free-electrons.com>
drivers/mtd/ubi/wl.c

index 507b09172069f62ac621b0322c551ad3610f3081..e823ca56f23a723444c8af6dc494267a355cf418 100644 (file)
@@ -1528,6 +1528,7 @@ int ubi_wl_init(struct ubi_device *ubi, struct ubi_attach_info *ai)
                INIT_LIST_HEAD(&ubi->pq[i]);
        ubi->pq_head = 0;
 
+       ubi->free_count = 0;
        list_for_each_entry_safe(aeb, tmp, &ai->erase, u.list) {
                cond_resched();
 
@@ -1546,7 +1547,6 @@ int ubi_wl_init(struct ubi_device *ubi, struct ubi_attach_info *ai)
                found_pebs++;
        }
 
-       ubi->free_count = 0;
        list_for_each_entry(aeb, &ai->free, u.list) {
                cond_resched();