Skip to contentSkip to conversation

sh: fix readsl/writesl argument

PATCH In review Magnus Damm 3 participants 5 messages Feb 20, 2008 – Feb 26, 2008 SuperH

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 sh: fix readsl/writesl argument

writesl() and readsl() use void __iomem * as argument but the current sh version of __raw_writesl()/__rawreadsl() takes unsigned long. Casting the pointer fixes smc91x warnings.

---

 include/asm-sh/io.h |    4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
include/asm-sh/io.h +2 -2
@@ -162,8 +162,8 @@ static inline void reads##bwlq(volatile 
 
 __BUILD_MEMORY_STRING(b, u8)
 __BUILD_MEMORY_STRING(w, u16)
-#define writesl __raw_writesl
-#define readsl  __raw_readsl
+#define writesl(m, a, c) __raw_writesl((unsigned long)(m), (a), (c))
+#define readsl(m, a, c)  __raw_readsl((unsigned long)(m), (a), (c))
 
 #define readb_relaxed(a) readb(a)
 #define readw_relaxed(a) readw(a)
#1 lore raw

Magnus

Quoted 3 lines · Magnus Damm

writesl() and readsl() use void __iomem * as argument but the current sh version of __raw_writesl()/__rawreadsl() takes unsigned long. Casting the pointer fixes smc91x warnings.

...

include/asm-sh/io.h static inline void reads##bwlq(volatile · line 166

Quoted 6 lines
include/asm-sh/io.h +2 -2
-#define writesl __raw_writesl
-#define readsl  __raw_readsl
+#define writesl(m, a, c) __raw_writesl((unsigned long)(m), (a), (c))
+#define readsl(m, a, c)  __raw_readsl((unsigned long)(m), (a), (c))

Wouldn't it be better to do this as inline functions, that way we don't loose the type checking?

Stuart

#2 lore raw
In reply to Magnus Damm

Hi Stuart,

Quoted 9 lines · Stuart MENEFY
Quoted 3 lines · Magnus Damm

writesl() and readsl() use void __iomem * as argument but the current sh version of __raw_writesl()/__rawreadsl() takes unsigned long. Casting the pointer fixes smc91x warnings.

...

Quoted 2 lines
include/asm-sh/io.h 2008-02-20 16:34:28.000000000 +0900 renamed from include/asm-sh/io.h +0 -0
Quoted 7 lines

include/asm-sh/io.h 2008-02-20 16:34:28.000000000 +0900

Quoted 4 lines
include/asm-sh/io.h 2008-02-20 16:34:28.000000000 +0900 renamed from include/asm-sh/io.h +2 -2
-#define writesl __raw_writesl
-#define readsl  __raw_readsl
+#define writesl(m, a, c) __raw_writesl((unsigned long)(m), (a), (c))
+#define readsl(m, a, c)  __raw_readsl((unsigned long)(m), (a), (c))

Wouldn't it be better to do this as inline functions, that way we don't loose the type checking?

Yes, I think so too. But step by step. =) I'm planning on replacing a lot of code in io.h actually, and I'll use inlines and avoid casting to get proper type checking then. Thanks!

/ magnus

#3 lore raw
In reply to Magnus Damm
Quoted 17 lines · Magnus Damm

Hi Stuart,

Quoted 14 lines · Stuart MENEFY
Quoted 3 lines · Magnus Damm

writesl() and readsl() use void __iomem * as argument but the current sh version of __raw_writesl()/__rawreadsl() takes unsigned long. Casting the pointer fixes smc91x warnings.

...

Quoted 7 lines
include/asm-sh/io.h 2008-02-20 16:34:28.000000000 +0900 renamed from include/asm-sh/io.h +2 -2
 
-#define writesl __raw_writesl
-#define readsl  __raw_readsl
+#define writesl(m, a, c) __raw_writesl((unsigned long)(m), (a), (c))
+#define readsl(m, a, c)  __raw_readsl((unsigned long)(m), (a), (c))
Quoted 7 lines
Quoted 2 lines

Wouldn't it be better to do this as inline functions, that way we don't loose the type checking?

Yes, I think so too. But step by step. =) I'm planning on replacing a lot of code in io.h actually, and I'll use inlines and avoid casting to get proper type checking then. Thanks!

There's not a lot of point in merging this for 2.6.25, so lets just drop this and focus on the proper cleanup for the 2.6.26 window instead.

#4 lore raw
In reply to Magnus Damm
Quoted 19 lines · Paul Mundt
Quoted 18 lines · Magnus Damm
Quoted 16 lines · Stuart MENEFY
Quoted 3 lines · Magnus Damm

writesl() and readsl() use void __iomem * as argument but the current sh version of __raw_writesl()/__rawreadsl() takes unsigned long. Casting the pointer fixes smc91x warnings.

...

include/asm-sh/io.h 2008-02-20 16:34:28.000000000 +0900

Quoted 7 lines
include/asm-sh/io.h 2008-02-20 16:34:28.000000000 +0900 renamed from include/asm-sh/io.h +2 -2
 
-#define writesl __raw_writesl
-#define readsl  __raw_readsl
+#define writesl(m, a, c) __raw_writesl((unsigned long)(m), (a), (c))
+#define readsl(m, a, c)  __raw_readsl((unsigned long)(m), (a), (c))

Wouldn't it be better to do this as inline functions, that way we don't loose the type checking?

Quoted 6 lines
Quoted 4 lines

Yes, I think so too. But step by step. =) I'm planning on replacing a lot of code in io.h actually, and I'll use inlines and avoid casting to get proper type checking then. Thanks!

There's not a lot of point in merging this for 2.6.25, so lets just drop this and focus on the proper cleanup for the 2.6.26 window instead.

Sure, merging this for 2.6.25 doesn't make any sense.

I do however wonder what a proper cleanup would look like...

I heard something about starting to use __raw_readN/writeN() instead of ctrl_inN/outN() for on-chip access, and with proper type checking we should use unsigned longs to specify address for __raw_readN/writeN(). But we can't do that since __raw_writeN() in lib/iomap.c takes void __iomem * instead of unsigned long.

Arm solves this by using macros and casting, but then we loose the type checking. What about using __readN/writeN() for on-chip access? Or maybe just keep ctrl_inN/outN() and focus on fixing up the rest.

/ magnus