imx233: fix typos and sdmmc bug regarding write buffer
The write buffer should not be modified but the current code does and then forget to restore it to its original content. I'm not sure if any code relies to the write buffer to not be modifies by the write function but this seems like a reasonable assumption in general so it's better not to break it. Change-Id: I449a01db2ec51d2273e59b69c59db0e7d2eed3db
This commit is contained in:
parent
54dd77a5f8
commit
25ecbc5432
1 changed files with 6 additions and 2 deletions
|
@ -648,14 +648,15 @@ static int transfer_sectors(int drive, unsigned long start, int count, void *buf
|
||||||
* Read transfers:
|
* Read transfers:
|
||||||
* If the buffer is already aligned, transfer everything at once.
|
* If the buffer is already aligned, transfer everything at once.
|
||||||
* Otherwise, transfer all sectors but one to the sub-buffer starting
|
* Otherwise, transfer all sectors but one to the sub-buffer starting
|
||||||
* on the next cache ligned and then move the data. Then transfer the
|
* on the next cache line and then move the data. Then transfer the
|
||||||
* last sector to the aligned_buffer and then copy to the buffer.
|
* last sector to the aligned_buffer and then copy to the buffer.
|
||||||
*
|
*
|
||||||
* Write transfers:
|
* Write transfers:
|
||||||
* If the buffer is already aligned, transfer everything at once.
|
* If the buffer is already aligned, transfer everything at once.
|
||||||
* Otherwise, copy the first sector to the aligned_buffer and transfer.
|
* Otherwise, copy the first sector to the aligned_buffer and transfer.
|
||||||
* Then move all other sectors within the buffer to make it cache
|
* Then move all other sectors within the buffer to make it cache
|
||||||
* aligned and transfer it.
|
* aligned and transfer it. Then move data to pretend the buffer was
|
||||||
|
* never modified.
|
||||||
*/
|
*/
|
||||||
if(read)
|
if(read)
|
||||||
{
|
{
|
||||||
|
@ -689,6 +690,9 @@ static int transfer_sectors(int drive, unsigned long start, int count, void *buf
|
||||||
// move within the buffer and transfer
|
// move within the buffer and transfer
|
||||||
memmove(ptr, buf + 512, 512 * (count - 1));
|
memmove(ptr, buf + 512, 512 * (count - 1));
|
||||||
ret = __xfer_sectors(drive, start + 1, count - 1, ptr, read);
|
ret = __xfer_sectors(drive, start + 1, count - 1, ptr, read);
|
||||||
|
// move back
|
||||||
|
memmove(buf + 512, ptr, 512 * (count - 1));
|
||||||
|
memcpy(buf, aligned_buffer[drive], 512);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
|
Loading…
Reference in a new issue