]> git.karo-electronics.de Git - karo-tx-linux.git/commitdiff
mtdoops: don't erase flash at each boot
authorMatthieu CASTET <matthieu.castet@parrot.com>
Fri, 19 Oct 2012 15:29:33 +0000 (17:29 +0200)
committerArtem Bityutskiy <artem.bityutskiy@linux.intel.com>
Mon, 12 Nov 2012 15:45:15 +0000 (17:45 +0200)
If there is no oops stored (flash is erased), find_next_position will
exit with maxcount == 0xffffffff and erase the first page.

Only erase it if mark_is_used.

Signed-off-by: Matthieu Castet <matthieu.castet@parrot@com>
Signed-off-by: Artem Bityutskiy <artem.bityutskiy@linux.intel.com>
drivers/mtd/mtdoops.c

index f5b3f91fa1cc4d8b885228e995b49ba4073629e9..97bb8f6304d4feebe6f38e357ca39a6a37fc7f71 100644 (file)
@@ -271,7 +271,7 @@ static void find_next_position(struct mtdoops_context *cxt)
 
                if (count[0] == 0xffffffff && count[1] == 0xffffffff)
                        mark_page_unused(cxt, page);
-               if (count[0] == 0xffffffff)
+               if (count[0] == 0xffffffff || count[1] != MTDOOPS_KERNMSG_MAGIC)
                        continue;
                if (maxcount == 0xffffffff) {
                        maxcount = count[0];
@@ -289,14 +289,13 @@ static void find_next_position(struct mtdoops_context *cxt)
                }
        }
        if (maxcount == 0xffffffff) {
-               cxt->nextpage = 0;
-               cxt->nextcount = 1;
-               schedule_work(&cxt->work_erase);
-               return;
+               cxt->nextpage = cxt->oops_pages - 1;
+               cxt->nextcount = 0;
+       }
+       else {
+               cxt->nextpage = maxpos;
+               cxt->nextcount = maxcount;
        }
-
-       cxt->nextpage = maxpos;
-       cxt->nextcount = maxcount;
 
        mtdoops_inc_counter(cxt);
 }