freemyipod r201 - Code Review

Jump to: navigation, search
Repository:freemyipod
Revision:r200‎ | r201 | r202 >
Date:15:12, 6 September 2010
Author:theseven
Status:new
Tags:
Comment:
Eliminate some evil tabs
Modified paths:
  • /embios/trunk/target/ipodnano2g/ftl.c (modified) (history)

Diff [purge]

Index: embios/trunk/target/ipodnano2g/ftl.c
@@ -703,11 +703,11 @@
704704 uint32_t spareused = ftl_vfl_cxt[bank].spareused;
705705 for (spareindex = 0; spareindex < spareused; spareindex++)
706706 if (ftl_vfl_cxt[bank].remaptable[spareindex] == block)
707 - {
 707+ {
708708 DEBUGF("FTL: VFL: Following remapped block: %d => %d",
709709 block, ftl_vfl_cxt[bank].firstspare + spareindex);
710710 return ftl_vfl_cxt[bank].firstspare + spareindex;
711 - }
 711+ }
712712 return block;
713713 }
714714
@@ -730,7 +730,7 @@
731731 {
732732 if (ftl_vfl_check_remap_scheduled(bank, block) == 1) return;
733733 panicf(PANIC_FATAL, "FTL: Scheduling bank %u block %u for remap!",
734 - (unsigned)bank, (unsigned)block);
 734+ (unsigned)bank, (unsigned)block);
735735 if (ftl_vfl_cxt[bank].scheduledstart == ftl_vfl_cxt[bank].spareused)
736736 return;
737737 ftl_vfl_cxt[bank].remaptable[--ftl_vfl_cxt[bank].scheduledstart] = block;
@@ -817,7 +817,7 @@
818818 uint32_t i;
819819 uint32_t newblock = 0, newidx;
820820 panicf(PANIC_FATAL, "FTL: Remapping bank %u block %u!",
821 - (unsigned)bank, (unsigned)block);
 821+ (unsigned)bank, (unsigned)block);
822822 if (bank >= ftl_banks || block >= ftl_nand_type->blocks) return 0;
823823 for (i = 0; i < ftl_vfl_cxt[bank].sparecount; i++)
824824 if (ftl_vfl_cxt[bank].remaptable[i] == 0)
@@ -904,10 +904,10 @@
905905 - ftl_nand_type->userblocks - 0x17;
906906 uint32_t abspage = vpage + ppb * syshyperblocks;
907907 if (abspage + ftl_banks - 1 >= ftl_nand_type->blocks * ppb || abspage < ppb)
908 - {
 908+ {
909909 DEBUGF("FTL: Trying to read out-of-bounds vPage %u", (unsigned)vpage);
910910 return 4;
911 - }
 911+ }
912912
913913 uint32_t bank = abspage % ftl_banks;
914914 uint32_t block = abspage / (ftl_nand_type->pagesperblock * ftl_banks);
@@ -980,11 +980,11 @@
981981 - ftl_nand_type->userblocks - 0x17;
982982 uint32_t abspage = vpage + ppb * syshyperblocks;
983983 if (abspage + count > ftl_nand_type->blocks * ppb || abspage < ppb)
984 - {
 984+ {
985985 DEBUGF("FTL: Trying to write out-of-bounds vPage %u",
986986 (unsigned)vpage);
987987 return 4;
988 - }
 988+ }
989989
990990 uint32_t bank[5];
991991 uint32_t block[5];
@@ -1095,11 +1095,11 @@
10961096 vflcxtidx = k;
10971097 }
10981098 if (vflcxtidx == 4)
1099 - {
 1099+ {
11001100 DEBUGF("FTL: No VFL CXT block found on bank %u!",
11011101 (unsigned)i);
1102 - return 1;
1103 - }
 1102+ return 1;
 1103+ }
11041104 last = 0;
11051105 uint32_t max = ftl_nand_type->pagesperblock;
11061106 for (k = 8; k < max; k += 8)
@@ -1126,10 +1126,10 @@
11271127 }
11281128 }
11291129 else
1130 - {
 1130+ {
11311131 DEBUGF("FTL: Couldn't load bank %u lowlevel BBT!", (unsigned)i);
1132 - return 1;
1133 - }
 1132+ return 1;
 1133+ }
11341134 cxt = ftl_vfl_get_newest_cxt();
11351135 for (i = 0; i < ftl_banks; i++)
11361136 memcpy(ftl_vfl_cxt[i].ftlctrlblocks, cxt->ftlctrlblocks, 6);
@@ -1192,10 +1192,10 @@
11931193 }
11941194
11951195 if (ftlcxtfound == 0)
1196 - {
 1196+ {
11971197 DEBUGF("FTL: Couldn't find FTL CXT page!");
1198 - return 1;
1199 - }
 1198+ return 1;
 1199+ }
12001200
12011201 DEBUGF("FTL: Successfully read FTL context block");
12021202 uint32_t pagestoread = ftl_nand_type->userblocks >> 10;
@@ -1205,10 +1205,10 @@
12061206 {
12071207 if ((ftl_vfl_read(ftl_cxt.ftl_map_pages[i],
12081208 ftl_buffer, &ftl_sparebuffer[0], 1, 1) & 0x11F) != 0)
1209 - {
 1209+ {
12101210 DEBUGF("FTL: Failed to read block map page %u", (unsigned)i);
12111211 return 1;
1212 - }
 1212+ }
12131213
12141214 uint32_t toread = 2048;
12151215 if (toread > (ftl_nand_type->userblocks << 1) - (i << 11))
@@ -1225,10 +1225,10 @@
12261226 {
12271227 if ((ftl_vfl_read(ftl_cxt.ftl_erasectr_pages[i],
12281228 ftl_buffer, &ftl_sparebuffer[0], 1, 1) & 0x11F) != 0)
1229 - {
 1229+ {
12301230 DEBUGF("FTL: Failed to read erase counter page %u", (unsigned)i);
12311231 return 1;
1232 - }
 1232+ }
12331233
12341234 uint32_t toread = 2048;
12351235 if (toread > ((ftl_nand_type->userblocks + 23) << 1) - (i << 11))
@@ -1316,10 +1316,10 @@
13171317 DEBUGF("FTL: Reading %d sectors starting at %d", count, sector);
13181318 #endif
13191319
1320 - if ((uint32_t)buffer & (CACHEALIGN_SIZE - 1))
1321 - panicf(PANIC_KILLTHREAD,
1322 - "ftl_read: Misaligned data buffer at %08X (sector %lu, count %lu)",
1323 - (unsigned int)buffer, sector, count);
 1320+ if ((uint32_t)buffer & (CACHEALIGN_SIZE - 1))
 1321+ panicf(PANIC_KILLTHREAD,
 1322+ "ftl_read: Misaligned data buffer at %08X (sector %lu, count %lu)",
 1323+ (unsigned int)buffer, sector, count);
13241324
13251325 if (sector + count > ftl_nand_type->userblocks * ppb)
13261326 {
@@ -1341,14 +1341,14 @@
13421342 if (logentry != NULL)
13431343 {
13441344 #ifdef FTL_TRACE
1345 - DEBUGF("FTL: Block %d has a log entry", block);
 1345+ DEBUGF("FTL: Block %d has a log entry", block);
13461346 #endif
13471347 if (logentry->scatteredvblock != 0xFFFF
13481348 && logentry->pageoffsets[page] != 0xFFFF)
13491349 {
13501350 #ifdef FTL_TRACE
1351 - DEBUGF("FTL: Found page %d at block %d, page %d", page,
1352 - (*logentry).scatteredvblock, (*logentry).pageoffsets[page]);
 1351+ DEBUGF("FTL: Found page %d at block %d, page %d", page,
 1352+ (*logentry).scatteredvblock, (*logentry).pageoffsets[page]);
13531353 #endif
13541354 abspage = logentry->scatteredvblock * ppb
13551355 + logentry->pageoffsets[page];
@@ -1370,7 +1370,7 @@
13711371 memset(&((uint8_t*)buffer)[(i + j) << 11], 0, 0x800);
13721372 else if ((ret & (0xd << (j << 2))) || ftl_sparebuffer[j].user.eccmark != 0xFF)
13731373 {
1374 - DEBUGF("FTL: Error while reading sector %d!", (sector + i));
 1374+ DEBUGF("FTL: Error while reading sector %d!", (sector + i));
13751375 error = -3;
13761376 memset(&((uint8_t*)buffer)[(i + j) << 11], 0, 0x800);
13771377 }
@@ -1383,7 +1383,7 @@
13841384 if (ret & 2) memset(&((uint8_t*)buffer)[i << 11], 0, 0x800);
13851385 else if ((ret & 0x11D) != 0 || ftl_sparebuffer[0].user.eccmark != 0xFF)
13861386 {
1387 - DEBUGF("FTL: Error while reading sector %d!", (sector + i));
 1387+ DEBUGF("FTL: Error while reading sector %d!", (sector + i));
13881388 error = -4;
13891389 memset(&((uint8_t*)buffer)[i << 11], 0, 0x800);
13901390 }
@@ -1981,10 +1981,10 @@
19821982 DEBUGF("FTL: Writing %d sectors starting at %d", count, sector);
19831983 #endif
19841984
1985 - if ((uint32_t)buffer & (CACHEALIGN_SIZE - 1))
1986 - panicf(PANIC_KILLTHREAD,
1987 - "ftl_write: Misaligned data buffer at %08X (sector %lu, count %lu)",
1988 - (unsigned int)buffer, sector, count);
 1985+ if ((uint32_t)buffer & (CACHEALIGN_SIZE - 1))
 1986+ panicf(PANIC_KILLTHREAD,
 1987+ "ftl_write: Misaligned data buffer at %08X (sector %lu, count %lu)",
 1988+ (unsigned int)buffer, sector, count);
19891989
19901990 if (sector + count > ftl_nand_type->userblocks * ppb)
19911991 {
@@ -1999,7 +1999,7 @@
20002000 {
20012001 for (i = 0; i < 3; i++)
20022002 {
2003 - DEBUGF("FTL: Marking dirty, try %d", i);
 2003+ DEBUGF("FTL: Marking dirty, try %d", i);
20042004 if (ftl_next_ctrl_pool_page() != 0)
20052005 {
20062006 mutex_unlock(&ftl_mtx);
@@ -2018,7 +2018,7 @@
20192019 mutex_unlock(&ftl_mtx);
20202020 return -4;
20212021 }
2022 - DEBUGF("FTL: Wrote dirty mark to %d", ftl_cxt.ftlctrlpage);
 2022+ DEBUGF("FTL: Wrote dirty mark to %d", ftl_cxt.ftlctrlpage);
20232023 ftl_cxt.clean_flag = 0;
20242024 }
20252025
@@ -2036,7 +2036,7 @@
20372037 if (page == 0 && count - i >= ppb)
20382038 {
20392039 #ifdef FTL_TRACE
2040 - DEBUGF("FTL: Going to write a full hyperblock in one shot");
 2040+ DEBUGF("FTL: Going to write a full hyperblock in one shot");
20412041 #endif
20422042 uint32_t vblock = logentry->scatteredvblock;
20432043 logentry->scatteredvblock = 0xFFFF;
@@ -2043,7 +2043,7 @@
20442044 if (logentry->pagesused != 0)
20452045 {
20462046 #ifdef FTL_TRACE
2047 - DEBUGF("FTL: Scattered block had some pages already used, committing");
 2047+ DEBUGF("FTL: Scattered block had some pages already used, committing");
20482048 #endif
20492049 ftl_release_pool_block(vblock);
20502050 vblock = ftl_allocate_pool_block();
@@ -2085,7 +2085,7 @@
20862086 if (logentry->pagesused == ppb)
20872087 {
20882088 #ifdef FTL_TRACE
2089 - DEBUGF("FTL: Scattered block is full, committing");
 2089+ DEBUGF("FTL: Scattered block is full, committing");
20902090 #endif
20912091 ftl_remove_scattered_block(logentry);
20922092 logentry = ftl_allocate_log_entry(block);
@@ -2166,7 +2166,7 @@
21672167 if (ftl_cxt.clean_flag == 1) return 0;
21682168
21692169 mutex_lock(&ftl_mtx, TIMEOUT_BLOCK);
2170 -
 2170+
21712171 #ifdef FTL_TRACE
21722172 DEBUGF("FTL: Syncing");
21732173 #endif
@@ -2549,7 +2549,7 @@
25502550 skip = 0;
25512551 if (founddevinfo == 0)
25522552 {
2553 - DEBUGF("FTL: No DEVICEINFO found!");
 2553+ DEBUGF("FTL: No DEVICEINFO found!");
25542554 return -1;
25552555 }
25562556 if (foundsignature != 0 && (result & 0x11F) != 0)
@@ -2558,27 +2558,27 @@
25592559 return -2;
25602560 }
25612561 if (ftl_vfl_open() == 0)
2562 - {
 2562+ {
25632563 if (ftl_open() == 0)
25642564 {
25652565 ftl_initialized = true;
25662566 return 0;
25672567 }
2568 - cprintf(CONSOLE_BOOT, "The FTL seems to be damaged. Forcing check.\n");
2569 - if (ftl_repair() != 0)
2570 - cprintf(CONSOLE_BOOT, "FTL recovery failed. Use disk mode to recover.\n");
2571 - else
2572 - {
2573 - cprintf(CONSOLE_BOOT, "FTL recovery finished. Trying to mount again...\n");
2574 - if (ftl_open() == 0)
 2568+ cprintf(CONSOLE_BOOT, "The FTL seems to be damaged. Forcing check.\n");
 2569+ if (ftl_repair() != 0)
 2570+ cprintf(CONSOLE_BOOT, "FTL recovery failed. Use disk mode to recover.\n");
 2571+ else
 2572+ {
 2573+ cprintf(CONSOLE_BOOT, "FTL recovery finished. Trying to mount again...\n");
 2574+ if (ftl_open() == 0)
25752575 {
2576 - cprintf(CONSOLE_BOOT, "Mount succeeded.\n");
 2576+ cprintf(CONSOLE_BOOT, "Mount succeeded.\n");
25772577 ftl_initialized = true;
25782578 return 0;
25792579 }
2580 - cprintf(CONSOLE_BOOT, "Mounting FTL failed again, use disk mode to recover.\n");
2581 - }
2582 - }
 2580+ cprintf(CONSOLE_BOOT, "Mounting FTL failed again, use disk mode to recover.\n");
 2581+ }
 2582+ }
25832583
25842584 DEBUGF("FTL: Initialization failed!");
25852585