[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20221007065042.700761-3-sgzhang@google.com>
Date: Fri, 7 Oct 2022 06:50:41 +0000
From: Ray Zhang <sgzhang@...gle.com>
To: Miquel Raynal <miquel.raynal@...tlin.com>,
Richard Weinberger <richard@....at>,
Vignesh Raghavendra <vigneshr@...com>
Cc: linux-mtd@...ts.infradead.org, linux-kernel@...r.kernel.org,
Ray Zhang <sgzhang@...gle.com>
Subject: [PATCH v2 2/3] mtd: mtdoops: add mtdoops_erase function and move
mtdoops_inc_counter to after it
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@...gle.com>
---
drivers/mtd/mtdoops.c | 49 ++++++++++++++++++++++++-------------------
1 file changed, 27 insertions(+), 22 deletions(-)
diff --git a/drivers/mtd/mtdoops.c b/drivers/mtd/mtdoops.c
index 84b21be347f6..eca48dff9b53 100644
--- a/drivers/mtd/mtdoops.c
+++ b/drivers/mtd/mtdoops.c
@@ -106,29 +106,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("mtdoops: 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;
@@ -181,6 +160,32 @@ static void mtdoops_workfunc_erase(struct work_struct *work)
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("mtdoops: 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;
--
2.38.0.rc1.362.ged0d419d3c-goog
Powered by blists - more mailing lists