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

powerpc: Fix _ALIGN_* errors due to type difference.

This avoid errors like

unsigned int usize = 1 << 30;
int size = 1 << 30;
unsigned long addr = 64UL << 30 ;

value = _ALIGN_DOWN(addr, usize); -> 0
value = _ALIGN_DOWN(addr, size); -> 0x1000000000

Signed-off-by: Aneesh Kumar K.V <aneesh.kumar@linux.vnet.ibm.com>
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>

authored by

Aneesh Kumar K.V and committed by
Michael Ellerman
f78f7ed7 1b70386c

+5 -4
+2 -2
arch/powerpc/boot/page.h
··· 22 22 #define PAGE_MASK (~(PAGE_SIZE-1)) 23 23 24 24 /* align addr on a size boundary - adjust address up/down if needed */ 25 - #define _ALIGN_UP(addr,size) (((addr)+((size)-1))&(~((size)-1))) 26 - #define _ALIGN_DOWN(addr,size) ((addr)&(~((size)-1))) 25 + #define _ALIGN_UP(addr, size) (((addr)+((size)-1))&(~((typeof(addr))(size)-1))) 26 + #define _ALIGN_DOWN(addr, size) ((addr)&(~((typeof(addr))(size)-1))) 27 27 28 28 /* align addr on a size boundary - adjust address up if needed */ 29 29 #define _ALIGN(addr,size) _ALIGN_UP(addr,size)
+3 -2
arch/powerpc/include/asm/page.h
··· 12 12 13 13 #ifndef __ASSEMBLY__ 14 14 #include <linux/types.h> 15 + #include <linux/kernel.h> 15 16 #else 16 17 #include <asm/types.h> 17 18 #endif ··· 242 241 #endif 243 242 244 243 /* align addr on a size boundary - adjust address up/down if needed */ 245 - #define _ALIGN_UP(addr,size) (((addr)+((size)-1))&(~((size)-1))) 246 - #define _ALIGN_DOWN(addr,size) ((addr)&(~((size)-1))) 244 + #define _ALIGN_UP(addr, size) __ALIGN_KERNEL(addr, size) 245 + #define _ALIGN_DOWN(addr, size) ((addr)&(~((typeof(addr))(size)-1))) 247 246 248 247 /* align addr on a size boundary - adjust address up if needed */ 249 248 #define _ALIGN(addr,size) _ALIGN_UP(addr,size)