diff options
-rw-r--r-- | firmware/target/arm/sandisk/sansa-e200/ata-e200.c | 29 |
1 files changed, 8 insertions, 21 deletions
diff --git a/firmware/target/arm/sandisk/sansa-e200/ata-e200.c b/firmware/target/arm/sandisk/sansa-e200/ata-e200.c index b94363e6b1..bfb0d27f97 100644 --- a/firmware/target/arm/sandisk/sansa-e200/ata-e200.c +++ b/firmware/target/arm/sandisk/sansa-e200/ata-e200.c | |||
@@ -267,27 +267,14 @@ static void copy_write_sectors(const unsigned char* buf, int wordcount) | |||
267 | 267 | ||
268 | static void copy_write_sectors(const unsigned char* buf, int wordcount) | 268 | static void copy_write_sectors(const unsigned char* buf, int wordcount) |
269 | { | 269 | { |
270 | if ( (unsigned long)buf & 1) | 270 | unsigned short tmp = 0; |
271 | { /* not 16-bit aligned, copy byte by byte */ | 271 | const unsigned char* bufend = buf + wordcount*2; |
272 | unsigned short tmp = 0; | 272 | do |
273 | const unsigned char* bufend = buf + wordcount*2; | 273 | { |
274 | do | 274 | tmp = (unsigned short) *buf++; |
275 | { | 275 | tmp |= (unsigned short) *buf++ << 8; |
276 | tmp = (unsigned short) *buf++; | 276 | DATA_REG = tmp; |
277 | tmp |= (unsigned short) *buf++ << 8; | 277 | } while (buf < bufend); /* tail loop is faster */ |
278 | DATA_REG = tmp; | ||
279 | } while (buf < bufend); /* tail loop is faster */ | ||
280 | } | ||
281 | else | ||
282 | { /* 16-bit aligned, can do faster copy */ | ||
283 | unsigned short* wbuf = (unsigned short*)buf; | ||
284 | unsigned short* wbufend = wbuf + wordcount; | ||
285 | do | ||
286 | { | ||
287 | DATA_REG = *wbuf; | ||
288 | asm volatile("nop\n\t"); | ||
289 | } while (++wbuf < wbufend); /* tail loop is faster */ | ||
290 | } | ||
291 | } | 278 | } |
292 | 279 | ||
293 | 280 | ||