[U-Boot] [PATCH] Using I/O accessor instead of volatile pointers in SMC911x driver
Matthias Weisser
matthias.weisser at graf-syteco.de
Wed Jul 22 10:14:33 CEST 2009
Volatile pointer usage caused lockup with arm-gcc 4.3.2
Using I/O accessor fixed that.
Signed-off-by: Matthias Weisser <matthias.weisser at graf-syteco.de>
---
drivers/net/smc911x.h | 17 +++++++++++------
1 files changed, 11 insertions(+), 6 deletions(-)
diff --git a/drivers/net/smc911x.h b/drivers/net/smc911x.h
index 80d2ce0..877b905 100644
--- a/drivers/net/smc911x.h
+++ b/drivers/net/smc911x.h
@@ -26,6 +26,7 @@
#define _SMC911X_H_
#include <linux/types.h>
+#include <asm/io.h>
#if defined (CONFIG_DRIVER_SMC911X_32_BIT) && \
defined (CONFIG_DRIVER_SMC911X_16_BIT)
@@ -36,25 +37,29 @@
#if defined (CONFIG_DRIVER_SMC911X_32_BIT)
static inline u32 __smc911x_reg_read(u32 addr)
{
- return *(volatile u32*)addr;
+ return readl(addr);
}
u32 smc911x_reg_read(u32 addr) __attribute__((weak, alias("__smc911x_reg_read")));
static inline void __smc911x_reg_write(u32 addr, u32 val)
{
- *(volatile u32*)addr = val;
+ writel(val, addr);
}
void smc911x_reg_write(u32 addr, u32 val) __attribute__((weak, alias("__smc911x_reg_write")));
#elif defined (CONFIG_DRIVER_SMC911X_16_BIT)
static inline u32 smc911x_reg_read(u32 addr)
{
- volatile u16 *addr_16 = (u16 *)addr;
- return ((*addr_16 & 0x0000ffff) | (*(addr_16 + 1) << 16));
+ u32 res;
+
+ res = readw(addr) & 0xFFFF;
+ res |= ((u32)(readw(addr + 2) & 0xFFFF) << 16);
+
+ return res;
}
static inline void smc911x_reg_write(u32 addr, u32 val)
{
- *(volatile u16*)addr = (u16)val;
- *(volatile u16*)(addr + 2) = (u16)(val >> 16);
+ writew(val & 0xFFFF, addr);
+ writew(val >> 16, addr + 2);
}
#else
#error "SMC911X: undefined bus width"
--
1.5.6.3
More information about the U-Boot
mailing list