Fixed some mutex issues in the iPod Nano 2G NAND driver and FTL.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@23066 a1c6a512-1295-4272-9138-f99709370657
This commit is contained in:
parent
46a0db45dd
commit
51b00c9b0b
2 changed files with 17 additions and 6 deletions
|
@ -1778,6 +1778,8 @@ uint32_t ftl_sync(void)
|
|||
uint32_t ppb = (*ftl_nand_type).pagesperblock * ftl_banks;
|
||||
if (ftl_cxt.clean_flag == 1) return 0;
|
||||
|
||||
mutex_lock(&ftl_mtx);
|
||||
|
||||
if (ftl_cxt.swapcounter >= 20)
|
||||
for (i = 0; i < 4; i++)
|
||||
if (ftl_swap_blocks() == 0)
|
||||
|
@ -1793,10 +1795,19 @@ uint32_t ftl_sync(void)
|
|||
rc |= ftl_commit_sequential(&ftl_log[i]);
|
||||
else rc |= ftl_commit_scattered(&ftl_log[i]);
|
||||
}
|
||||
if (rc != 0) return 1;
|
||||
if (rc != 0)
|
||||
{
|
||||
mutex_unlock(&ftl_mtx);
|
||||
return 1;
|
||||
}
|
||||
for (i = 0; i < 5; i++)
|
||||
if (ftl_commit_cxt() == 0) return 0;
|
||||
if (ftl_commit_cxt() == 0)
|
||||
{
|
||||
mutex_unlock(&ftl_mtx);
|
||||
return 0;
|
||||
}
|
||||
else ftl_cxt.ftlctrlpage |= ppb - 1;
|
||||
mutex_unlock(&ftl_mtx);
|
||||
return 1;
|
||||
}
|
||||
#endif
|
||||
|
|
|
@ -312,6 +312,7 @@ uint32_t nand_read_page(uint32_t bank, uint32_t page, void* databuffer,
|
|||
if (databuffer != 0)
|
||||
if (nand_transfer_data(bank, 0, nand_uncached_data, 0x800) != 0)
|
||||
return nand_unlock(1);
|
||||
rc = 0;
|
||||
if (doecc == 0)
|
||||
{
|
||||
memcpy(databuffer, nand_uncached_data, 0x800);
|
||||
|
@ -321,11 +322,10 @@ uint32_t nand_read_page(uint32_t bank, uint32_t page, void* databuffer,
|
|||
return nand_unlock(1);
|
||||
memcpy(sparebuffer, nand_uncached_spare, 0x800);
|
||||
if (checkempty != 0)
|
||||
return nand_check_empty((uint8_t*)sparebuffer) << 1;
|
||||
rc = nand_check_empty((uint8_t*)sparebuffer) << 1;
|
||||
}
|
||||
return nand_unlock(0);
|
||||
return nand_unlock(rc);
|
||||
}
|
||||
rc = 0;
|
||||
if (nand_transfer_data(bank, 0, nand_uncached_spare, 0x40) != 0)
|
||||
return nand_unlock(1);
|
||||
memcpy(nand_uncached_ecc, &nand_uncached_spare[0xC], 0x28);
|
||||
|
@ -377,7 +377,7 @@ uint32_t nand_write_page(uint32_t bank, uint32_t page, void* databuffer,
|
|||
if (nand_transfer_data(bank, 1, nand_uncached_spare, 0x40) != 0)
|
||||
return nand_unlock(1);
|
||||
if (nand_send_cmd(NAND_CMD_PROGCNFRM) != 0) return nand_unlock(1);
|
||||
return nand_wait_status_ready(bank);
|
||||
return nand_unlock(nand_wait_status_ready(bank));
|
||||
}
|
||||
|
||||
uint32_t nand_block_erase(uint32_t bank, uint32_t page)
|
||||
|
|
Loading…
Reference in a new issue