--- nftl.c.orig Sun Oct 1 11:52:19 2000 +++ nftl.c Wed Oct 4 03:46:17 2000 @@ -237,10 +237,11 @@ nftl->lastEUN = le16_to_cpu(nftl->MediaHdr.NumEraseUnits) + le16_to_cpu(nftl->MediaHdr.FirstPhysicalEUN) - 1; nftl->numfreeEUNs = 0; + nftl->LastFreeEUN = le16_to_cpu(nftl->MediaHdr.FirstPhysicalEUN)+2; /* Scan each physical Erase Unit for validity and to find the Virtual Erase Unit Chain to which it belongs */ - for (i = le16_to_cpu(nftl->MediaHdr.FirstPhysicalEUN); i <= nftl->lastEUN; i++) { + for (i = le16_to_cpu(nftl->MediaHdr.FirstPhysicalEUN)+2; i <= nftl->lastEUN; i++) { union nftl_uci uci; unsigned long ofs; size_t retlen; @@ -277,6 +278,10 @@ nftl->VirtualUnitTable[i] = le16_to_cpu(uci.a.VirtUnitNum); nftl->ReplUnitTable[i] = le16_to_cpu(uci.a.ReplUnitNum); + if (nftl->ReplUnitTable[i] < le16_to_cpu(nftl->MediaHdr.FirstPhysicalEUN)+2) + printk(KERN_WARNING "EUN %d: is replaced by HDR EUN (%x)\n", i, + le16_to_cpu(uci.a.ReplUnitNum)); + /* if (!(VUN & 0x8000) && VUN < (arraybounds)).. optimises to: */ if (le16_to_cpu(uci.a.VirtUnitNum) < nftl->numvunits) nftl->EUNtable[le16_to_cpu(uci.a.VirtUnitNum) & 0x7fff] = i; @@ -288,7 +293,6 @@ } } NFTLs[firstfree] = nftl; - nftl->LastFreeEUN = le16_to_cpu(nftl->MediaHdr.FirstPhysicalEUN); #ifdef PSYCHO_DEBUG for (i=0; i < 10/* nftl->numvunits*/; i++) { @@ -377,17 +381,24 @@ } if (!strncmp(hdr.DataOrgID, "ANAND", 6)) { DEBUG(MTD_DEBUG_LEVEL2, "Valid NFTL partition at ofs 0x%lx\n", ofs); + DEBUG(MTD_DEBUG_LEVEL2,"Erase Units: %d, FirstPhysicalEUN: %d, FormattedSize: %d, UnitSizeFactor: 0x%0x\n", + hdr.NumEraseUnits, hdr.FirstPhysicalEUN, + hdr.FormattedSize, hdr.UnitSizeFactor); NFTL_setup(mtd, ofs, &hdr); - } else { - DEBUG(MTD_DEBUG_LEVEL3,"No valid NFTL Partition at ofs 0x%lx\n", ofs); - for (i = 0; i < 6; i++) { - DEBUG(MTD_DEBUG_LEVEL3,"%x, ", hdr.DataOrgID[i]); - } + } /* else { + DEBUG(MTD_DEBUG_LEVEL3, + "No valid NFTL Partition at ofs 0x%lx" + ", DataOrgId %02.2x,%02.2x,%02.2x,%02.2x,%02.2x,%02.2x (%6.6s)\n", + ofs, hdr.DataOrgID[0], hdr.DataOrgID[1], hdr.DataOrgID[2], + hdr.DataOrgID[4], hdr.DataOrgID[5], hdr.DataOrgID[6], + hdr.DataOrgID); + DEBUG(MTD_DEBUG_LEVEL3," = %s\n", hdr.DataOrgID); DEBUG(MTD_DEBUG_LEVEL3,"%d, %d, %d, %d\n", hdr.NumEraseUnits, hdr.FirstPhysicalEUN, hdr.FormattedSize, hdr.UnitSizeFactor); } + */ } return; } @@ -430,7 +441,7 @@ } if (++pot > nftl->lastEUN) - pot = le16_to_cpu(nftl->MediaHdr.FirstPhysicalEUN); + pot = le16_to_cpu(nftl->MediaHdr.FirstPhysicalEUN)+2; if (!silly--) { printk("Tell Dave he fucked up. LastFreeEUN = %d, "