Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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@google.com>
Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
Link: https://lore.kernel.org/linux-mtd/20221010045549.2221965-3-sgzhang@google.com

authored by

Ray Zhang and committed by
Miquel Raynal
340193e0 43cfba56

+27 -22
+27 -22
drivers/mtd/mtdoops.c
··· 108 108 return 0; 109 109 } 110 110 111 - static void mtdoops_inc_counter(struct mtdoops_context *cxt) 111 + static void mtdoops_erase(struct mtdoops_context *cxt) 112 112 { 113 - cxt->nextpage++; 114 - if (cxt->nextpage >= cxt->oops_pages) 115 - cxt->nextpage = 0; 116 - cxt->nextcount++; 117 - if (cxt->nextcount == 0xffffffff) 118 - cxt->nextcount = 0; 119 - 120 - if (page_is_used(cxt, cxt->nextpage)) { 121 - schedule_work(&cxt->work_erase); 122 - return; 123 - } 124 - 125 - pr_debug("ready %d, %d (no erase)\n", 126 - cxt->nextpage, cxt->nextcount); 127 - } 128 - 129 - /* Scheduled work - when we can't proceed without erasing a block */ 130 - static void mtdoops_workfunc_erase(struct work_struct *work) 131 - { 132 - struct mtdoops_context *cxt = 133 - container_of(work, struct mtdoops_context, work_erase); 134 113 struct mtd_info *mtd = cxt->mtd; 135 114 int i = 0, j, ret, mod; 136 115 ··· 160 181 } 161 182 } 162 183 goto badblock; 184 + } 185 + 186 + /* Scheduled work - when we can't proceed without erasing a block */ 187 + static void mtdoops_workfunc_erase(struct work_struct *work) 188 + { 189 + struct mtdoops_context *cxt = 190 + container_of(work, struct mtdoops_context, work_erase); 191 + mtdoops_erase(cxt); 192 + } 193 + 194 + static void mtdoops_inc_counter(struct mtdoops_context *cxt) 195 + { 196 + cxt->nextpage++; 197 + if (cxt->nextpage >= cxt->oops_pages) 198 + cxt->nextpage = 0; 199 + cxt->nextcount++; 200 + if (cxt->nextcount == 0xffffffff) 201 + cxt->nextcount = 0; 202 + 203 + if (page_is_used(cxt, cxt->nextpage)) { 204 + schedule_work(&cxt->work_erase); 205 + return; 206 + } 207 + 208 + pr_debug("ready %d, %d (no erase)\n", 209 + cxt->nextpage, cxt->nextcount); 163 210 } 164 211 165 212 static void mtdoops_write(struct mtdoops_context *cxt, int panic)