From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753217AbcDVKGt (ORCPT ); Fri, 22 Apr 2016 06:06:49 -0400 Received: from mail-out.m-online.net ([212.18.0.10]:48354 "EHLO mail-out.m-online.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751583AbcDVKGr (ORCPT ); Fri, 22 Apr 2016 06:06:47 -0400 X-Auth-Info: ZAVpFo5jgywXSvFRv2aFhmhyeFHlj/f1DdRPZegeZos= From: Heiko Schocher To: linux-mtd@lists.infradead.org Cc: Heiko Schocher , Richard Weinberger , Adrian Hunter , linux-kernel@vger.kernel.org, Brian Norris , Richard Weinberger , David Woodhouse , Artem Bityutskiy Subject: [PATCH] mtd, ubi: set free_count to zero before walking through erase list Date: Fri, 22 Apr 2016 12:06:38 +0200 Message-Id: <1461319598-17157-1-git-send-email-hs@denx.de> X-Mailer: git-send-email 2.5.0 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Set free_count to zero before walking through ai->erase list in wl_init(). Found in U-Boot 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 in U-Boot. Signed-off-by: Heiko Schocher Reviewed-by: Boris Brezillon --- 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. corresponding U-Boot Thread: http://lists.denx.de/pipermail/u-boot/2016-April/252338.html drivers/mtd/ubi/wl.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/mtd/ubi/wl.c b/drivers/mtd/ubi/wl.c index 17ec948..959c7b12 100644 --- a/drivers/mtd/ubi/wl.c +++ b/drivers/mtd/ubi/wl.c @@ -1534,6 +1534,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(); @@ -1552,7 +1553,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(); -- 2.5.0