]> www.pilppa.org Git - linux-2.6-omap-h63xx.git/commitdiff
Merge git://git.infradead.org/mtd-2.6
authorLinus Torvalds <torvalds@linux-foundation.org>
Thu, 6 Nov 2008 23:43:13 +0000 (15:43 -0800)
committerLinus Torvalds <torvalds@linux-foundation.org>
Thu, 6 Nov 2008 23:43:13 +0000 (15:43 -0800)
* git://git.infradead.org/mtd-2.6:
  [JFFS2] fix race condition in jffs2_lzo_compress()
  [MTD] [NOR] Fix cfi_send_gen_cmd handling of x16 devices in x8 mode (v4)
  [JFFS2] Fix lack of locking in thread_should_wake()
  [JFFS2] Fix build failure with !CONFIG_JFFS2_FS_WRITEBUFFER
  [MTD] [NAND] OMAP2: remove duplicated #include

drivers/mtd/chips/cfi_cmdset_0002.c
drivers/mtd/chips/jedec_probe.c
fs/jffs2/background.c
fs/jffs2/compr_lzo.c
fs/jffs2/nodemgmt.c
include/linux/mtd/cfi.h

index 3e6f5d8609e8e513b38e5110bc7719a3fce5c1d0..d74ec46aa032220f3159739667b6f039620f77a8 100644 (file)
@@ -406,19 +406,6 @@ struct mtd_info *cfi_cmdset_0002(struct map_info *map, int primary)
                /* Set the default CFI lock/unlock addresses */
                cfi->addr_unlock1 = 0x555;
                cfi->addr_unlock2 = 0x2aa;
-               /* Modify the unlock address if we are in compatibility mode */
-               if (    /* x16 in x8 mode */
-                       ((cfi->device_type == CFI_DEVICETYPE_X8) &&
-                               (cfi->cfiq->InterfaceDesc ==
-                                       CFI_INTERFACE_X8_BY_X16_ASYNC)) ||
-                       /* x32 in x16 mode */
-                       ((cfi->device_type == CFI_DEVICETYPE_X16) &&
-                               (cfi->cfiq->InterfaceDesc ==
-                                       CFI_INTERFACE_X16_BY_X32_ASYNC)))
-               {
-                       cfi->addr_unlock1 = 0xaaa;
-                       cfi->addr_unlock2 = 0x555;
-               }
 
        } /* CFI mode */
        else if (cfi->cfi_mode == CFI_MODE_JEDEC) {
index f84ab6182148a97976262097fa5d0692b6080883..2f3f2f719ba497026a7a6f304fdcab4d03bbe5bd 100644 (file)
@@ -1808,9 +1808,7 @@ static inline u32 jedec_read_mfr(struct map_info *map, uint32_t base,
         * several first banks can contain 0x7f instead of actual ID
         */
        do {
-               uint32_t ofs = cfi_build_cmd_addr(0 + (bank << 8),
-                                                 cfi_interleave(cfi),
-                                                 cfi->device_type);
+               uint32_t ofs = cfi_build_cmd_addr(0 + (bank << 8), map, cfi);
                mask = (1 << (cfi->device_type * 8)) - 1;
                result = map_read(map, base + ofs);
                bank++;
@@ -1824,7 +1822,7 @@ static inline u32 jedec_read_id(struct map_info *map, uint32_t base,
 {
        map_word result;
        unsigned long mask;
-       u32 ofs = cfi_build_cmd_addr(1, cfi_interleave(cfi), cfi->device_type);
+       u32 ofs = cfi_build_cmd_addr(1, map, cfi);
        mask = (1 << (cfi->device_type * 8)) -1;
        result = map_read(map, base + ofs);
        return result.x[0] & mask;
@@ -2067,8 +2065,8 @@ static int jedec_probe_chip(struct map_info *map, __u32 base,
 
        }
        /* Ensure the unlock addresses we try stay inside the map */
-       probe_offset1 = cfi_build_cmd_addr(cfi->addr_unlock1, cfi_interleave(cfi), cfi->device_type);
-       probe_offset2 = cfi_build_cmd_addr(cfi->addr_unlock2, cfi_interleave(cfi), cfi->device_type);
+       probe_offset1 = cfi_build_cmd_addr(cfi->addr_unlock1, map, cfi);
+       probe_offset2 = cfi_build_cmd_addr(cfi->addr_unlock2, map, cfi);
        if (    ((base + probe_offset1 + map_bankwidth(map)) >= map->size) ||
                ((base + probe_offset2 + map_bankwidth(map)) >= map->size))
                goto retry;
index 8adebd3e43c690fbf0469cf9b235279998c252c8..3cceef4ad2b7df413e98b8171cadf074de83ad2d 100644 (file)
@@ -85,15 +85,15 @@ static int jffs2_garbage_collect_thread(void *_c)
        for (;;) {
                allow_signal(SIGHUP);
        again:
+               spin_lock(&c->erase_completion_lock);
                if (!jffs2_thread_should_wake(c)) {
                        set_current_state (TASK_INTERRUPTIBLE);
+                       spin_unlock(&c->erase_completion_lock);
                        D1(printk(KERN_DEBUG "jffs2_garbage_collect_thread sleeping...\n"));
-                       /* Yes, there's a race here; we checked jffs2_thread_should_wake()
-                          before setting current->state to TASK_INTERRUPTIBLE. But it doesn't
-                          matter - We don't care if we miss a wakeup, because the GC thread
-                          is only an optimisation anyway. */
                        schedule();
-               }
+               } else
+                       spin_unlock(&c->erase_completion_lock);
+                       
 
                /* This thread is purely an optimisation. But if it runs when
                   other things could be running, it actually makes things a
index 47b045797e42ff99a568279cfe6cf6dbc285cf5d..90cb60d0978767c305ce1ed888e712471b72b0d3 100644 (file)
@@ -19,7 +19,7 @@
 
 static void *lzo_mem;
 static void *lzo_compress_buf;
-static DEFINE_MUTEX(deflate_mutex);
+static DEFINE_MUTEX(deflate_mutex);    /* for lzo_mem and lzo_compress_buf */
 
 static void free_workspace(void)
 {
@@ -49,18 +49,21 @@ static int jffs2_lzo_compress(unsigned char *data_in, unsigned char *cpage_out,
 
        mutex_lock(&deflate_mutex);
        ret = lzo1x_1_compress(data_in, *sourcelen, lzo_compress_buf, &compress_size, lzo_mem);
-       mutex_unlock(&deflate_mutex);
-
        if (ret != LZO_E_OK)
-               return -1;
+               goto fail;
 
        if (compress_size > *dstlen)
-               return -1;
+               goto fail;
 
        memcpy(cpage_out, lzo_compress_buf, compress_size);
-       *dstlen = compress_size;
+       mutex_unlock(&deflate_mutex);
 
+       *dstlen = compress_size;
        return 0;
+
+ fail:
+       mutex_unlock(&deflate_mutex);
+       return -1;
 }
 
 static int jffs2_lzo_decompress(unsigned char *data_in, unsigned char *cpage_out,
index 0875b60b4bf700cc8fda2fad76437d0dc9ea7420..21a052915aa9363acb0cd1e2b34567ef782b57f5 100644 (file)
@@ -261,9 +261,11 @@ static int jffs2_find_nextblock(struct jffs2_sb_info *c)
 
        jffs2_sum_reset_collected(c->summary); /* reset collected summary */
 
+#ifdef CONFIG_JFFS2_FS_WRITEBUFFER
        /* adjust write buffer offset, else we get a non contiguous write bug */
        if (!(c->wbuf_ofs % c->sector_size) && !c->wbuf_len)
                c->wbuf_ofs = 0xffffffff;
+#endif
 
        D1(printk(KERN_DEBUG "jffs2_find_nextblock(): new nextblock = 0x%08x\n", c->nextblock->offset));
 
index ee5124ec319e4e036f1f139dff39c428c6732190..00e2b575021f6d8f6ee1fd819cf18137baf3fcd5 100644 (file)
@@ -282,9 +282,25 @@ struct cfi_private {
 /*
  * Returns the command address according to the given geometry.
  */
-static inline uint32_t cfi_build_cmd_addr(uint32_t cmd_ofs, int interleave, int type)
+static inline uint32_t cfi_build_cmd_addr(uint32_t cmd_ofs,
+                               struct map_info *map, struct cfi_private *cfi)
 {
-       return (cmd_ofs * type) * interleave;
+       unsigned bankwidth = map_bankwidth(map);
+       unsigned interleave = cfi_interleave(cfi);
+       unsigned type = cfi->device_type;
+       uint32_t addr;
+       
+       addr = (cmd_ofs * type) * interleave;
+
+       /* Modify the unlock address if we are in compatiblity mode.
+        * For 16bit devices on 8 bit busses
+        * and 32bit devices on 16 bit busses
+        * set the low bit of the alternating bit sequence of the address.
+        */
+       if (((type * interleave) > bankwidth) && ((uint8_t)cmd_ofs == 0xaa))
+               addr |= (type >> 1)*interleave;
+
+       return  addr;
 }
 
 /*
@@ -430,7 +446,7 @@ static inline uint32_t cfi_send_gen_cmd(u_char cmd, uint32_t cmd_addr, uint32_t
                                int type, map_word *prev_val)
 {
        map_word val;
-       uint32_t addr = base + cfi_build_cmd_addr(cmd_addr, cfi_interleave(cfi), type);
+       uint32_t addr = base + cfi_build_cmd_addr(cmd_addr, map, cfi);
        val = cfi_build_cmd(cmd, map, cfi);
 
        if (prev_val)