Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

Merge git://git.infradead.org/mtd-2.6

* 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

+39 -33
-13
drivers/mtd/chips/cfi_cmdset_0002.c
··· 406 406 /* Set the default CFI lock/unlock addresses */ 407 407 cfi->addr_unlock1 = 0x555; 408 408 cfi->addr_unlock2 = 0x2aa; 409 - /* Modify the unlock address if we are in compatibility mode */ 410 - if ( /* x16 in x8 mode */ 411 - ((cfi->device_type == CFI_DEVICETYPE_X8) && 412 - (cfi->cfiq->InterfaceDesc == 413 - CFI_INTERFACE_X8_BY_X16_ASYNC)) || 414 - /* x32 in x16 mode */ 415 - ((cfi->device_type == CFI_DEVICETYPE_X16) && 416 - (cfi->cfiq->InterfaceDesc == 417 - CFI_INTERFACE_X16_BY_X32_ASYNC))) 418 - { 419 - cfi->addr_unlock1 = 0xaaa; 420 - cfi->addr_unlock2 = 0x555; 421 - } 422 409 423 410 } /* CFI mode */ 424 411 else if (cfi->cfi_mode == CFI_MODE_JEDEC) {
+4 -6
drivers/mtd/chips/jedec_probe.c
··· 1808 1808 * several first banks can contain 0x7f instead of actual ID 1809 1809 */ 1810 1810 do { 1811 - uint32_t ofs = cfi_build_cmd_addr(0 + (bank << 8), 1812 - cfi_interleave(cfi), 1813 - cfi->device_type); 1811 + uint32_t ofs = cfi_build_cmd_addr(0 + (bank << 8), map, cfi); 1814 1812 mask = (1 << (cfi->device_type * 8)) - 1; 1815 1813 result = map_read(map, base + ofs); 1816 1814 bank++; ··· 1822 1824 { 1823 1825 map_word result; 1824 1826 unsigned long mask; 1825 - u32 ofs = cfi_build_cmd_addr(1, cfi_interleave(cfi), cfi->device_type); 1827 + u32 ofs = cfi_build_cmd_addr(1, map, cfi); 1826 1828 mask = (1 << (cfi->device_type * 8)) -1; 1827 1829 result = map_read(map, base + ofs); 1828 1830 return result.x[0] & mask; ··· 2065 2067 2066 2068 } 2067 2069 /* Ensure the unlock addresses we try stay inside the map */ 2068 - probe_offset1 = cfi_build_cmd_addr(cfi->addr_unlock1, cfi_interleave(cfi), cfi->device_type); 2069 - probe_offset2 = cfi_build_cmd_addr(cfi->addr_unlock2, cfi_interleave(cfi), cfi->device_type); 2070 + probe_offset1 = cfi_build_cmd_addr(cfi->addr_unlock1, map, cfi); 2071 + probe_offset2 = cfi_build_cmd_addr(cfi->addr_unlock2, map, cfi); 2070 2072 if ( ((base + probe_offset1 + map_bankwidth(map)) >= map->size) || 2071 2073 ((base + probe_offset2 + map_bankwidth(map)) >= map->size)) 2072 2074 goto retry;
+5 -5
fs/jffs2/background.c
··· 85 85 for (;;) { 86 86 allow_signal(SIGHUP); 87 87 again: 88 + spin_lock(&c->erase_completion_lock); 88 89 if (!jffs2_thread_should_wake(c)) { 89 90 set_current_state (TASK_INTERRUPTIBLE); 91 + spin_unlock(&c->erase_completion_lock); 90 92 D1(printk(KERN_DEBUG "jffs2_garbage_collect_thread sleeping...\n")); 91 - /* Yes, there's a race here; we checked jffs2_thread_should_wake() 92 - before setting current->state to TASK_INTERRUPTIBLE. But it doesn't 93 - matter - We don't care if we miss a wakeup, because the GC thread 94 - is only an optimisation anyway. */ 95 93 schedule(); 96 - } 94 + } else 95 + spin_unlock(&c->erase_completion_lock); 96 + 97 97 98 98 /* This thread is purely an optimisation. But if it runs when 99 99 other things could be running, it actually makes things a
+9 -6
fs/jffs2/compr_lzo.c
··· 19 19 20 20 static void *lzo_mem; 21 21 static void *lzo_compress_buf; 22 - static DEFINE_MUTEX(deflate_mutex); 22 + static DEFINE_MUTEX(deflate_mutex); /* for lzo_mem and lzo_compress_buf */ 23 23 24 24 static void free_workspace(void) 25 25 { ··· 49 49 50 50 mutex_lock(&deflate_mutex); 51 51 ret = lzo1x_1_compress(data_in, *sourcelen, lzo_compress_buf, &compress_size, lzo_mem); 52 - mutex_unlock(&deflate_mutex); 53 - 54 52 if (ret != LZO_E_OK) 55 - return -1; 53 + goto fail; 56 54 57 55 if (compress_size > *dstlen) 58 - return -1; 56 + goto fail; 59 57 60 58 memcpy(cpage_out, lzo_compress_buf, compress_size); 61 - *dstlen = compress_size; 59 + mutex_unlock(&deflate_mutex); 62 60 61 + *dstlen = compress_size; 63 62 return 0; 63 + 64 + fail: 65 + mutex_unlock(&deflate_mutex); 66 + return -1; 64 67 } 65 68 66 69 static int jffs2_lzo_decompress(unsigned char *data_in, unsigned char *cpage_out,
+2
fs/jffs2/nodemgmt.c
··· 261 261 262 262 jffs2_sum_reset_collected(c->summary); /* reset collected summary */ 263 263 264 + #ifdef CONFIG_JFFS2_FS_WRITEBUFFER 264 265 /* adjust write buffer offset, else we get a non contiguous write bug */ 265 266 if (!(c->wbuf_ofs % c->sector_size) && !c->wbuf_len) 266 267 c->wbuf_ofs = 0xffffffff; 268 + #endif 267 269 268 270 D1(printk(KERN_DEBUG "jffs2_find_nextblock(): new nextblock = 0x%08x\n", c->nextblock->offset)); 269 271
+19 -3
include/linux/mtd/cfi.h
··· 282 282 /* 283 283 * Returns the command address according to the given geometry. 284 284 */ 285 - static inline uint32_t cfi_build_cmd_addr(uint32_t cmd_ofs, int interleave, int type) 285 + static inline uint32_t cfi_build_cmd_addr(uint32_t cmd_ofs, 286 + struct map_info *map, struct cfi_private *cfi) 286 287 { 287 - return (cmd_ofs * type) * interleave; 288 + unsigned bankwidth = map_bankwidth(map); 289 + unsigned interleave = cfi_interleave(cfi); 290 + unsigned type = cfi->device_type; 291 + uint32_t addr; 292 + 293 + addr = (cmd_ofs * type) * interleave; 294 + 295 + /* Modify the unlock address if we are in compatiblity mode. 296 + * For 16bit devices on 8 bit busses 297 + * and 32bit devices on 16 bit busses 298 + * set the low bit of the alternating bit sequence of the address. 299 + */ 300 + if (((type * interleave) > bankwidth) && ((uint8_t)cmd_ofs == 0xaa)) 301 + addr |= (type >> 1)*interleave; 302 + 303 + return addr; 288 304 } 289 305 290 306 /* ··· 446 430 int type, map_word *prev_val) 447 431 { 448 432 map_word val; 449 - uint32_t addr = base + cfi_build_cmd_addr(cmd_addr, cfi_interleave(cfi), type); 433 + uint32_t addr = base + cfi_build_cmd_addr(cmd_addr, map, cfi); 450 434 val = cfi_build_cmd(cmd, map, cfi); 451 435 452 436 if (prev_val)