1
0
Fork 0
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:
Daniel Ankers 2007-02-04 03:20:36 +00:00
parent a7af649766
commit 67ec6177a7

View file

@ -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)
{
if ( (unsigned long)buf & 1)
{ /* not 16-bit aligned, copy byte by byte */
unsigned short tmp = 0;
const unsigned char* bufend = buf + wordcount*2;
do
{
tmp = (unsigned short) *buf++;
tmp |= (unsigned short) *buf++ << 8;
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 */
}
unsigned short tmp = 0;
const unsigned char* bufend = buf + wordcount*2;
do
{
tmp = (unsigned short) *buf++;
tmp |= (unsigned short) *buf++ << 8;
DATA_REG = tmp;
} while (buf < bufend); /* tail loop is faster */
}