[PATCH 2.4] jffs2 aligment problems

From: Greg Weeks
Date: Mon Jun 07 2004 - 10:11:45 EST


This fixed some jffs2 alignment problems we saw on an IXP425 based XScale board. I just got pinged that I was supposed to post this patch in case anyone else finds it usefull. This was against a modified 2.4.19 kernel.

Greg Weeks

Signed-off-by: Greg Weeks <greg.weeks@xxxxxxxxxxx> under TS0067


--- kernel/drivers/mtd/chips/cfi_cmdset_0001.c-orig
+++ kernel/drivers/mtd/chips/cfi_cmdset_0001.c

@@ -933,7 +933,7 @@
cfi_word status, status_OK;
unsigned long cmd_adr, timeo;
DECLARE_WAITQUEUE(wait, current);
- int wbufsize, z, suspended=0, ret=0;
+ int wbufsize, z, y, suspended=0, ret=0;

wbufsize = CFIDEV_INTERLEAVE << cfi->cfiq->MaxBufWriteSize;
adr += chip->start;
@@ -1064,12 +1064,18 @@

/* Write data */
for (z = 0; z < len; z += CFIDEV_BUSWIDTH) {
+ cfi_word aligned_val;
+ u_char *align_ptr = (u_char *) &aligned_val;
+
+ for (y = 0; y < CFIDEV_BUSWIDTH; y++)
+ align_ptr[y] = *(buf++);
+
if (cfi_buswidth_is_1()) {
- map->write8 (map, *((__u8*)buf)++, adr+z);
+ map->write8 (map, *((__u8 *) &aligned_val), adr+z);
} else if (cfi_buswidth_is_2()) {
- map->write16 (map, *((__u16*)buf)++, adr+z);
+ map->write16 (map, *((__u16 *) &aligned_val), adr+z);
} else if (cfi_buswidth_is_4()) {
- map->write32 (map, *((__u32*)buf)++, adr+z);
+ map->write32 (map, *((__u32 *) &aligned_val), adr+z);
} else {
DISABLE_VPP(map);
ret = -EINVAL;

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/