forked from len0rd/rockbox
Work around a bug in the Sansa flash driver
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@12187 a1c6a512-1295-4272-9138-f99709370657
This commit is contained in:
parent
a7af649766
commit
67ec6177a7
1 changed files with 8 additions and 21 deletions
|
|
@ -267,27 +267,14 @@ static void copy_write_sectors(const unsigned char* buf, int wordcount)
|
||||||
|
|
||||||
static void copy_write_sectors(const unsigned char* buf, int wordcount)
|
static void copy_write_sectors(const unsigned char* buf, int wordcount)
|
||||||
{
|
{
|
||||||
if ( (unsigned long)buf & 1)
|
unsigned short tmp = 0;
|
||||||
{ /* not 16-bit aligned, copy byte by byte */
|
const unsigned char* bufend = buf + wordcount*2;
|
||||||
unsigned short tmp = 0;
|
do
|
||||||
const unsigned char* bufend = buf + wordcount*2;
|
{
|
||||||
do
|
tmp = (unsigned short) *buf++;
|
||||||
{
|
tmp |= (unsigned short) *buf++ << 8;
|
||||||
tmp = (unsigned short) *buf++;
|
DATA_REG = tmp;
|
||||||
tmp |= (unsigned short) *buf++ << 8;
|
} while (buf < bufend); /* tail loop is faster */
|
||||||
DATA_REG = tmp;
|
|
||||||
} while (buf < bufend); /* tail loop is faster */
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{ /* 16-bit aligned, can do faster copy */
|
|
||||||
unsigned short* wbuf = (unsigned short*)buf;
|
|
||||||
unsigned short* wbufend = wbuf + wordcount;
|
|
||||||
do
|
|
||||||
{
|
|
||||||
DATA_REG = *wbuf;
|
|
||||||
asm volatile("nop\n\t");
|
|
||||||
} while (++wbuf < wbufend); /* tail loop is faster */
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue