diff options
Diffstat (limited to 'packages/linux/nslu2-kernel/2.6.15/mtd-unaligned-read-fix')
-rw-r--r-- | packages/linux/nslu2-kernel/2.6.15/mtd-unaligned-read-fix | 40 |
1 files changed, 40 insertions, 0 deletions
diff --git a/packages/linux/nslu2-kernel/2.6.15/mtd-unaligned-read-fix b/packages/linux/nslu2-kernel/2.6.15/mtd-unaligned-read-fix new file mode 100644 index 0000000000..f4f468ce85 --- /dev/null +++ b/packages/linux/nslu2-kernel/2.6.15/mtd-unaligned-read-fix @@ -0,0 +1,40 @@ +diff -u linux-2.6-working/drivers/mtd/maps/ixp4xx.c linux-2.6-working/drivers/mtd/maps/ixp4xx.c +--- linux-2.6.15/drivers/mtd/maps/ixp4xx.c 1970-01-01 00:00:00.000000000 +0000 ++++ linux-2.6.15/drivers/mtd/maps/ixp4xx.c 1970-01-01 00:00:00.000000000 +0000 +@@ -53,19 +53,28 @@ + static void ixp4xx_copy_from(struct map_info *map, void *to, + unsigned long from, ssize_t len) + { +- int i; + u8 *dest = (u8 *) to; + void __iomem *src = map->virt + from; +- u16 data; + +- for (i = 0; i < (len / 2); i++) { +- data = le16_to_cpu(readw(src + 2*i)); +- dest[i * 2] = BYTE0(data); +- dest[i * 2 + 1] = BYTE1(data); ++ if (len <= 0) ++ return; ++ ++ if (from & 1) { ++ *dest++ = BYTE1(le16_to_cpu(readw(src))); ++ src++; ++ --len; ++ } ++ ++ while (len >= 2) { ++ u16 data = le16_to_cpu(readw(src)); ++ *dest++ = BYTE0(data); ++ *dest++ = BYTE1(data); ++ src += 2; ++ len -= 2; + } + +- if (len & 1) +- dest[len - 1] = BYTE0(le16_to_cpu(readw(src + 2*i))); ++ if (len > 0) ++ *dest++ = BYTE0(le16_to_cpu(readw(src))); + } + + /* |