linux/drivers/mtd/maps
Andrea Righi 27ac792ca0 PAGE_ALIGN(): correctly handle 64-bit values on 32-bit architectures
On 32-bit architectures PAGE_ALIGN() truncates 64-bit values to the 32-bit
boundary. For example:

	u64 val = PAGE_ALIGN(size);

always returns a value < 4GB even if size is greater than 4GB.

The problem resides in PAGE_MASK definition (from include/asm-x86/page.h for
example):

#define PAGE_SHIFT      12
#define PAGE_SIZE       (_AC(1,UL) << PAGE_SHIFT)
#define PAGE_MASK       (~(PAGE_SIZE-1))
...
#define PAGE_ALIGN(addr)       (((addr)+PAGE_SIZE-1)&PAGE_MASK)

The "~" is performed on a 32-bit value, so everything in "and" with
PAGE_MASK greater than 4GB will be truncated to the 32-bit boundary.
Using the ALIGN() macro seems to be the right way, because it uses
typeof(addr) for the mask.

Also move the PAGE_ALIGN() definitions out of include/asm-*/page.h in
include/linux/mm.h.

See also lkml discussion: http://lkml.org/lkml/2008/6/11/237

[akpm@linux-foundation.org: fix drivers/media/video/uvc/uvc_queue.c]
[akpm@linux-foundation.org: fix v850]
[akpm@linux-foundation.org: fix powerpc]
[akpm@linux-foundation.org: fix arm]
[akpm@linux-foundation.org: fix mips]
[akpm@linux-foundation.org: fix drivers/media/video/pvrusb2/pvrusb2-dvb.c]
[akpm@linux-foundation.org: fix drivers/mtd/maps/uclinux.c]
[akpm@linux-foundation.org: fix powerpc]
Signed-off-by: Andrea Righi <righi.andrea@gmail.com>
Cc: <linux-arch@vger.kernel.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2008-07-24 10:47:21 -07:00
..
alchemy-flash.c
amd76xrom.c
autcpu12-nvram.c
bast-flash.c [MTD] [MAPS] fix platform driver hotplug/coldplug 2008-04-22 14:14:26 +01:00
cdb89712.c
ceiva.c
cfi_flagadm.c
ck804xrom.c ck804rom: fix driver_data in probe table. 2008-05-27 07:34:38 -07:00
dbox2-flash.c
dc21285.c
dilnetpc.c
dmv182.c
ebony.c
edb7312.c
esb2rom.c
fortunet.c
h720x-flash.c
ichxrom.c
impa7.c
integrator-flash.c [MTD] [MAPS] fix platform driver hotplug/coldplug 2008-04-22 14:14:26 +01:00
intel_vr_nor.c
ipaq-flash.c
ixp4xx.c [MTD] [MAPS] fix platform driver hotplug/coldplug 2008-04-22 14:14:26 +01:00
ixp2000.c [MTD] [MAPS] fix platform driver hotplug/coldplug 2008-04-22 14:14:26 +01:00
Kconfig [MIPS] MTX-1 flash partition setup move to platform devices registration 2008-07-15 18:44:38 +01:00
l440gx.c
Makefile [MIPS] MTX-1 flash partition setup move to platform devices registration 2008-07-15 18:44:38 +01:00
map_funcs.c
mbx860.c
netsc520.c
nettel.c
ocotea.c
octagon-5066.c
omap_nor.c ARM: OMAP: Change omap_cf.c and omap_nor.c to use omap_readw/writew instead of __REG 2008-07-03 12:24:41 +03:00
omap-toto-flash.c
pci.c
pcmciamtd.c pcmcia: (re)move {pcmcia,pccard}_get_status 2008-06-24 15:33:44 +02:00
physmap_of.c
physmap.c [MTD] [MAPS] fix platform driver hotplug/coldplug 2008-04-22 14:14:26 +01:00
plat-ram.c drivers: fix integer as NULL pointer warnings 2008-04-28 17:31:13 -07:00
pmcmsp-flash.c [MTD] replace remaining __FUNCTION__ occurrences 2008-04-22 12:36:04 +01:00
pmcmsp-ramroot.c
pxa2xx-flash.c
redwood.c
rpxlite.c
sa1100-flash.c [MTD] [MAPS] fix platform driver hotplug/coldplug 2008-04-22 14:14:26 +01:00
sbc8240.c
sbc_gxx.c
sc520cdp.c
scb2_flash.c
scx200_docflash.c
sharpsl-flash.c [MTD] fix minor typo in the MTD map driver for SHARP SL series 2008-04-22 19:12:44 +01:00
solutionengine.c
sun_uflash.c
tqm8xxl.c [MTD] replace remaining __FUNCTION__ occurrences 2008-04-22 12:36:04 +01:00
ts5500_flash.c
tsunami_flash.c
uclinux.c PAGE_ALIGN(): correctly handle 64-bit values on 32-bit architectures 2008-07-24 10:47:21 -07:00
vmax301.c
walnut.c
wr_sbc82xx_flash.c