public inbox for u-boot@lists.denx.de
 help / color / mirror / Atom feed
* [U-Boot] [PATCH] Using I/O accessor instead of volatile pointers in SMC911x driver
@ 2009-07-22  8:14 Matthias Weisser
  2009-07-22  8:32 ` Mike Frysinger
  2009-07-23 19:54 ` Wolfgang Denk
  0 siblings, 2 replies; 4+ messages in thread
From: Matthias Weisser @ 2009-07-22  8:14 UTC (permalink / raw)
  To: u-boot

Volatile pointer usage caused lockup with arm-gcc 4.3.2
Using I/O accessor fixed that.

Signed-off-by: Matthias Weisser <matthias.weisser@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

^ permalink raw reply related	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2009-07-23 21:25 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-07-22  8:14 [U-Boot] [PATCH] Using I/O accessor instead of volatile pointers in SMC911x driver Matthias Weisser
2009-07-22  8:32 ` Mike Frysinger
2009-07-23 19:54 ` Wolfgang Denk
2009-07-23 21:25   ` Ben Warren

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox