android_kernel_samsung_msm8976/include/linux/mtd
Wang Haitao 1da42d7c5f mtd: map: fixed bug in 64-bit systems
commit a4d62babf988fe5dfde24437fa135ef147bc7aa0 upstream.

Hardware:
	CPU: XLP832,the 64-bit OS
	NOR Flash:S29GL128S 128M
Software:
	Kernel:2.6.32.41
	Filesystem:JFFS2
When writing files, errors appear:
	Write len 182  but return retlen 180
	Write of 182 bytes at 0x072c815c failed. returned -5, retlen 180
	Write len 186  but return retlen 184
	Write of 186 bytes at 0x072caff4 failed. returned -5, retlen 184
These errors exist only in 64-bit systems,not in 32-bit systems. After analysis, we
found that the left shift operation is wrong in map_word_load_partial. For instance:
	unsigned char buf[3] ={0x9e,0x3a,0xea};
	map_bankwidth(map) is 4;
	for (i=0; i < 3; i++) {
		int bitpos;
		bitpos = (map_bankwidth(map)-1-i)*8;
		orig.x[0] &= ~(0xff << bitpos);
		orig.x[0] |= buf[i] << bitpos;
	}

The value of orig.x[0] is expected to be 0x9e3aeaff, but in this situation(64-bit
System) we'll get the wrong value of 0xffffffff9e3aeaff due to the 64-bit sign
extension:
buf[i] is defined as "unsigned char" and the left-shift operation will convert it
to the type of "signed int", so when left-shift buf[i] by 24 bits, the final result
will get the wrong value: 0xffffffff9e3aeaff.

If the left-shift bits are less than 24, then sign extension will not occur. Whereas
the bankwidth of the nor flash we used is 4, therefore this BUG emerges.

Signed-off-by: Pang Xunlei <pang.xunlei@zte.com.cn>
Signed-off-by: Zhang Yi <zhang.yi20@zte.com.cn>
Signed-off-by: Lu Zhongjun <lu.zhongjun@zte.com.cn>
Signed-off-by: Brian Norris <computersforpeace@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2013-12-04 10:56:22 -08:00
..
bbm.h
blktrans.h mtd_blktrans_ops->release() should return void 2013-05-05 21:31:22 -04:00
cfi.h
cfi_endian.h
concat.h
doc2000.h mtd: diskonchip: use inline functions for DocRead/DocWrite 2012-11-16 10:57:38 +02:00
flashchip.h
fsmc.h
ftl.h
gen_probe.h
inftl.h
latch-addr-flash.h
lpc32xx_mlc.h
lpc32xx_slc.h
map.h mtd: map: fixed bug in 64-bit systems 2013-12-04 10:56:22 -08:00
mtd.h mtd: add 'const' qualifier to a couple of register functions 2013-04-05 13:02:16 +01:00
mtdram.h
nand-gpio.h
nand.h mtd: nand: subpage write support for hardware based ECC schemes 2013-04-05 13:22:59 +01:00
nand_bch.h
nand_ecc.h
ndfc.h
nftl.h
onenand.h
onenand_regs.h
partitions.h
pfow.h
physmap.h mtd: physmap: add const qualifiers 2013-04-05 13:02:40 +01:00
pismo.h
plat-ram.h mtd: plat-ram: add const quilifiers 2013-04-05 13:02:33 +01:00
qinfo.h
sh_flctl.h mtd: sh_flctl: Add DMA capabilty 2012-11-15 15:37:50 +02:00
sharpsl.h
spear_smi.h
super.h
ubi.h
xip.h