]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
mtd: mtdoops: add mtdoops_erase function and move mtdoops_inc_counter to after it
authorRay Zhang <sgzhang@google.com>
Mon, 10 Oct 2022 04:55:48 +0000 (04:55 +0000)
committerMiquel Raynal <miquel.raynal@bootlin.com>
Mon, 7 Nov 2022 16:07:59 +0000 (17:07 +0100)
Preparing for next patch with minimal code difference, add mtdoops_erase
function and move mtdoops_inc_counter to after it, with no functional
change.

Signed-off-by: Ray Zhang <sgzhang@google.com>
Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
Link: https://lore.kernel.org/linux-mtd/20221010045549.2221965-3-sgzhang@google.com
drivers/mtd/mtdoops.c

index 6b70331da3b62f2eef46341e36b41223bae2bbe7..0226b9e9ea8f4b4b446127c15d505aa9248cfa12 100644 (file)
@@ -108,29 +108,8 @@ static int mtdoops_erase_block(struct mtdoops_context *cxt, int offset)
        return 0;
 }
 
-static void mtdoops_inc_counter(struct mtdoops_context *cxt)
-{
-       cxt->nextpage++;
-       if (cxt->nextpage >= cxt->oops_pages)
-               cxt->nextpage = 0;
-       cxt->nextcount++;
-       if (cxt->nextcount == 0xffffffff)
-               cxt->nextcount = 0;
-
-       if (page_is_used(cxt, cxt->nextpage)) {
-               schedule_work(&cxt->work_erase);
-               return;
-       }
-
-       pr_debug("ready %d, %d (no erase)\n",
-                cxt->nextpage, cxt->nextcount);
-}
-
-/* Scheduled work - when we can't proceed without erasing a block */
-static void mtdoops_workfunc_erase(struct work_struct *work)
+static void mtdoops_erase(struct mtdoops_context *cxt)
 {
-       struct mtdoops_context *cxt =
-                       container_of(work, struct mtdoops_context, work_erase);
        struct mtd_info *mtd = cxt->mtd;
        int i = 0, j, ret, mod;
 
@@ -183,6 +162,32 @@ badblock:
        goto badblock;
 }
 
+/* Scheduled work - when we can't proceed without erasing a block */
+static void mtdoops_workfunc_erase(struct work_struct *work)
+{
+       struct mtdoops_context *cxt =
+                       container_of(work, struct mtdoops_context, work_erase);
+       mtdoops_erase(cxt);
+}
+
+static void mtdoops_inc_counter(struct mtdoops_context *cxt)
+{
+       cxt->nextpage++;
+       if (cxt->nextpage >= cxt->oops_pages)
+               cxt->nextpage = 0;
+       cxt->nextcount++;
+       if (cxt->nextcount == 0xffffffff)
+               cxt->nextcount = 0;
+
+       if (page_is_used(cxt, cxt->nextpage)) {
+               schedule_work(&cxt->work_erase);
+               return;
+       }
+
+       pr_debug("ready %d, %d (no erase)\n",
+                cxt->nextpage, cxt->nextcount);
+}
+
 static void mtdoops_write(struct mtdoops_context *cxt, int panic)
 {
        struct mtd_info *mtd = cxt->mtd;