mtdoops: find_next_position() explained?

Rick Ramstetter rick.ramstetter at gmail.com
Fri Apr 15 05:54:58 EDT 2011


Hello,

Can anyone explain the logic behind the following block of code from
mtdoops' find_next_position()?

+	for (page = 0; page < cxt->oops_pages; page++) {
+		mtd->read(mtd, page * OOPS_PAGE_SIZE, 4, &retlen, (u_char *) &count);
+		if (count == 0xffffffff)
+			continue;
+		if (maxcount == 0xffffffff) {
+			maxcount = count;
+			maxpos = page;
+		} else if ((count < 0x40000000) && (maxcount > 0xc0000000)) {
+			maxcount = count;
+			maxpos = page;
+		} else if ((count > maxcount) && (count < 0xc0000000)) {
+			maxcount = count;
+			maxpos = page;
+		} else if ((count > maxcount) && (count > 0xc0000000)
+					&& (maxcount > 0x80000000)) {
+			maxcount = count;
+			maxpos = page;
+		}


I expected to see something along the lines of the following:
+		if (maxcount == 0xffffffff || count > maxcount) {
+			maxcount = count;
+			maxpos = page;
+		}


Thank you,
-Rick



More information about the linux-mtd mailing list