From 6bbb073cf6d910e3e6af0c3bfd44e7afe55612fc Mon Sep 17 00:00:00 2001 From: Gabe Black Date: Thu, 12 Sep 2013 01:38:16 -0700 Subject: [PATCH] libpayload: Use the same type for 32 bit data in readl as in uint32_t. The compiler gets mad when the types are equivalent size but not necessarily interchangeable because of strict aliasing checks. Since uint32_t is likely to be used when trying to read 32 bit data, it makes sense for them to be the compatible. This change was originally written for ARM but applies to x86 as well. BUG=None TEST=Built and booted on link. BRANCH=None Change-Id: I91b5e39f40e516405b9802032c87d3b15ed52c23 Signed-off-by: Gabe Black Reviewed-on: https://chromium-review.googlesource.com/169121 Reviewed-by: Ronald Minnich Reviewed-by: Stefan Reinauer Commit-Queue: Gabe Black Tested-by: Gabe Black --- payloads/libpayload/include/x86/arch/io.h | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/payloads/libpayload/include/x86/arch/io.h b/payloads/libpayload/include/x86/arch/io.h index 31a8f88410..ebed906aea 100644 --- a/payloads/libpayload/include/x86/arch/io.h +++ b/payloads/libpayload/include/x86/arch/io.h @@ -33,13 +33,13 @@ #define readb(_a) (*(volatile unsigned char *) (_a)) #define readw(_a) (*(volatile unsigned short *) (_a)) -#define readl(_a) (*(volatile unsigned long *) (_a)) +#define readl(_a) (*(volatile unsigned int *) (_a)) #define writeb(_v, _a) (*(volatile unsigned char *) (_a) = (_v)) #define writew(_v, _a) (*(volatile unsigned short *) (_a) = (_v)) -#define writel(_v, _a) (*(volatile unsigned long *) (_a) = (_v)) +#define writel(_v, _a) (*(volatile unsigned int *) (_a) = (_v)) -static inline unsigned long inl(int port) +static inline unsigned int inl(int port) { unsigned long val; __asm__ __volatile__("inl %w1, %0" : "=a"(val) : "Nd"(port)); @@ -60,7 +60,7 @@ static inline unsigned char inb(int port) return val; } -static inline void outl(unsigned long val, int port) +static inline void outl(unsigned int val, int port) { __asm__ __volatile__("outl %0, %w1" : : "a"(val), "Nd"(port)); }