Index: embios/trunk/target/ipodnano2g/ftl.c |
— | — | @@ -1310,7 +1310,7 @@ |
1311 | 1311 | uint32_t ppb = ftl_nand_type->pagesperblock * ftl_banks;
|
1312 | 1312 | uint32_t error = 0;
|
1313 | 1313 |
|
1314 | | - if (!ftl_initialized) return 1;
|
| 1314 | + if (!ftl_initialized) return -1;
|
1315 | 1315 |
|
1316 | 1316 | #ifdef FTL_TRACE
|
1317 | 1317 | DEBUGF("FTL: Reading %d sectors starting at %d", count, sector);
|
— | — | @@ -1324,7 +1324,7 @@ |
1325 | 1325 | if (sector + count > ftl_nand_type->userblocks * ppb)
|
1326 | 1326 | {
|
1327 | 1327 | DEBUGF("FTL: Sector %d is out of range!", sector + count - 1);
|
1328 | | - return 1;
|
| 1328 | + return -2;
|
1329 | 1329 | }
|
1330 | 1330 | if (count == 0) return 0;
|
1331 | 1331 |
|
— | — | @@ -1371,7 +1371,7 @@ |
1372 | 1372 | else if ((ret & (0xd << (j << 2))) || ftl_sparebuffer[j].user.eccmark != 0xFF)
|
1373 | 1373 | {
|
1374 | 1374 | DEBUGF("FTL: Error while reading sector %d!", (sector + i));
|
1375 | | - error = 1;
|
| 1375 | + error = -3;
|
1376 | 1376 | memset(&((uint8_t*)buffer)[(i + j) << 11], 0, 0x800);
|
1377 | 1377 | }
|
1378 | 1378 | i += ftl_banks - 1;
|
— | — | @@ -1384,7 +1384,7 @@ |
1385 | 1385 | else if ((ret & 0x11D) != 0 || ftl_sparebuffer[0].user.eccmark != 0xFF)
|
1386 | 1386 | {
|
1387 | 1387 | DEBUGF("FTL: Error while reading sector %d!", (sector + i));
|
1388 | | - error = 1;
|
| 1388 | + error = -4;
|
1389 | 1389 | memset(&((uint8_t*)buffer)[i << 11], 0, 0x800);
|
1390 | 1390 | }
|
1391 | 1391 | }
|
— | — | @@ -1845,8 +1845,11 @@ |
1846 | 1846 | {
|
1847 | 1847 | uint32_t i;
|
1848 | 1848 | struct ftl_log_type* entry = ftl_get_log_entry(block);
|
1849 | | - entry->usn = ftl_cxt.nextblockusn - 1;
|
1850 | | - if (entry != (struct ftl_log_type*)0) return entry;
|
| 1849 | + if (entry != (struct ftl_log_type*)0)
|
| 1850 | + {
|
| 1851 | + entry->usn = ftl_cxt.nextblockusn - 1;
|
| 1852 | + return entry;
|
| 1853 | + }
|
1851 | 1854 |
|
1852 | 1855 | for (i = 0; i < 0x11; i++)
|
1853 | 1856 | {
|
— | — | @@ -1972,7 +1975,7 @@ |
1973 | 1976 | uint32_t i, j, k;
|
1974 | 1977 | uint32_t ppb = ftl_nand_type->pagesperblock * ftl_banks;
|
1975 | 1978 |
|
1976 | | - if (!ftl_initialized) return 1;
|
| 1979 | + if (!ftl_initialized) return -1;
|
1977 | 1980 |
|
1978 | 1981 | #ifdef FTL_TRACE
|
1979 | 1982 | DEBUGF("FTL: Writing %d sectors starting at %d", count, sector);
|
— | — | @@ -1986,7 +1989,7 @@ |
1987 | 1990 | if (sector + count > ftl_nand_type->userblocks * ppb)
|
1988 | 1991 | {
|
1989 | 1992 | DEBUGF("FTL: Sector %d is out of range!", sector + count - 1);
|
1990 | | - return 1;
|
| 1993 | + return -2;
|
1991 | 1994 | }
|
1992 | 1995 | if (count == 0) return 0;
|
1993 | 1996 |
|
— | — | @@ -2000,7 +2003,7 @@ |
2001 | 2004 | if (ftl_next_ctrl_pool_page() != 0)
|
2002 | 2005 | {
|
2003 | 2006 | mutex_unlock(&ftl_mtx);
|
2004 | | - return 1;
|
| 2007 | + return -3;
|
2005 | 2008 | }
|
2006 | 2009 | memset(ftl_buffer, 0xFF, 0x800);
|
2007 | 2010 | memset(&ftl_sparebuffer[0], 0xFF, 0x40);
|
— | — | @@ -2013,7 +2016,7 @@ |
2014 | 2017 | if (i == 3)
|
2015 | 2018 | {
|
2016 | 2019 | mutex_unlock(&ftl_mtx);
|
2017 | | - return 1;
|
| 2020 | + return -4;
|
2018 | 2021 | }
|
2019 | 2022 | DEBUGF("FTL: Wrote dirty mark to %d", ftl_cxt.ftlctrlpage);
|
2020 | 2023 | ftl_cxt.clean_flag = 0;
|
— | — | @@ -2028,7 +2031,7 @@ |
2029 | 2032 | if (logentry == (struct ftl_log_type*)0)
|
2030 | 2033 | {
|
2031 | 2034 | mutex_unlock(&ftl_mtx);
|
2032 | | - return 1;
|
| 2035 | + return -5;
|
2033 | 2036 | }
|
2034 | 2037 | if (page == 0 && count - i >= ppb)
|
2035 | 2038 | {
|
— | — | @@ -2047,7 +2050,7 @@ |
2048 | 2051 | if (vblock == 0xFFFFFFFF)
|
2049 | 2052 | {
|
2050 | 2053 | mutex_unlock(&ftl_mtx);
|
2051 | | - return 1;
|
| 2054 | + return -6;
|
2052 | 2055 | }
|
2053 | 2056 | }
|
2054 | 2057 | ftl_cxt.nextblockusn++;
|
— | — | @@ -2089,7 +2092,7 @@ |
2090 | 2093 | if (logentry == (struct ftl_log_type*)0)
|
2091 | 2094 | {
|
2092 | 2095 | mutex_unlock(&ftl_mtx);
|
2093 | | - return 1;
|
| 2096 | + return -7;
|
2094 | 2097 | }
|
2095 | 2098 | }
|
2096 | 2099 | uint32_t cnt = FTL_WRITESPARE_SIZE;
|
— | — | @@ -2186,7 +2189,7 @@ |
2187 | 2190 | if (rc != 0)
|
2188 | 2191 | {
|
2189 | 2192 | mutex_unlock(&ftl_mtx);
|
2190 | | - return 1;
|
| 2193 | + return -1;
|
2191 | 2194 | }
|
2192 | 2195 | for (i = 0; i < 5; i++)
|
2193 | 2196 | if (ftl_commit_cxt() == 0)
|
— | — | @@ -2196,7 +2199,7 @@ |
2197 | 2200 | }
|
2198 | 2201 | else ftl_cxt.ftlctrlpage |= ppb - 1;
|
2199 | 2202 | mutex_unlock(&ftl_mtx);
|
2200 | | - return 1;
|
| 2203 | + return -2;
|
2201 | 2204 | }
|
2202 | 2205 | #endif
|
2203 | 2206 |
|
— | — | @@ -2547,12 +2550,12 @@ |
2548 | 2551 | if (founddevinfo == 0)
|
2549 | 2552 | {
|
2550 | 2553 | DEBUGF("FTL: No DEVICEINFO found!");
|
2551 | | - return 1;
|
| 2554 | + return -1;
|
2552 | 2555 | }
|
2553 | 2556 | if (foundsignature != 0 && (result & 0x11F) != 0)
|
2554 | 2557 | {
|
2555 | 2558 | DEBUGF("FTL: Problem with the signature!");
|
2556 | | - return 1;
|
| 2559 | + return -2;
|
2557 | 2560 | }
|
2558 | 2561 | if (ftl_vfl_open() == 0)
|
2559 | 2562 | {
|
— | — | @@ -2579,5 +2582,5 @@ |
2580 | 2583 |
|
2581 | 2584 | DEBUGF("FTL: Initialization failed!");
|
2582 | 2585 |
|
2583 | | - return 1;
|
| 2586 | + return -3;
|
2584 | 2587 | }
|