2004-11-12 16:46:19

by Yoshinori Sato

[permalink] [raw]
Subject: [PATCH] H8/300 read{b,w,l} / write{b,w,l} error fix

Signed-off-by: Yoshinori Sato <[email protected]>

diff -Nru a/include/asm-h8300/io.h b/include/asm-h8300/io.h
--- a/include/asm-h8300/io.h 2004-11-13 01:12:50 +09:00
+++ b/include/asm-h8300/io.h 2004-11-13 01:12:50 +09:00
@@ -70,15 +70,24 @@
}

#define readb(addr) \
- ({ unsigned char __v = (*(volatile unsigned char *) ((addr) & 0x00ffffff)); __v; })
+ ({ unsigned char __v = \
+ *(volatile unsigned char *)((unsigned long)(addr) & 0x00ffffff); \
+ __v; })
#define readw(addr) \
- ({ unsigned short __v = (*(volatile unsigned short *) ((addr) & 0x00ffffff)); __v; })
+ ({ unsigned short __v = \
+ *(volatile unsigned short *)((unsigned long)(addr) & 0x00ffffff); \
+ __v; })
#define readl(addr) \
- ({ unsigned int __v = (*(volatile unsigned int *) ((addr) & 0x00ffffff)); __v; })
+ ({ unsigned long __v = \
+ *(volatile unsigned long *)((unsigned long)(addr) & 0x00ffffff); \
+ __v; })

-#define writeb(b,addr) (void)((*(volatile unsigned char *) ((addr) & 0x00ffffff)) = (b))
-#define writew(b,addr) (void)((*(volatile unsigned short *) ((addr) & 0x00ffffff)) = (b))
-#define writel(b,addr) (void)((*(volatile unsigned int *) ((addr) & 0x00ffffff)) = (b))
+#define writeb(b,addr) (void)((*(volatile unsigned char *) \
+ ((unsigned long)(addr) & 0x00ffffff)) = (b))
+#define writew(b,addr) (void)((*(volatile unsigned short *) \
+ ((unsigned long)(addr) & 0x00ffffff)) = (b))
+#define writel(b,addr) (void)((*(volatile unsigned long *) \
+ ((unsigned long)(addr) & 0x00ffffff)) = (b))
#define readb_relaxed(addr) readb(addr)
#define readw_relaxed(addr) readw(addr)
#define readl_relaxed(addr) readl(addr)

--
Yoshinori Sato
<[email protected]>


2004-11-13 15:26:43

by Yoshinori Sato

[permalink] [raw]
Subject: Re: [PATCH] H8/300 read{b,w,l} / write{b,w,l} error fix

At Fri, 12 Nov 2004 09:25:00 -0800,
Joe Perches wrote:
>
> On Sat, 2004-11-13 at 01:42 +0900, Yoshinori Sato wrote:
> > #define readb(addr) \
> > - ({ unsigned char __v = (*(volatile unsigned char *) ((addr) & 0x00ffffff)); __v; })
> > + ({ unsigned char __v = \
> > + *(volatile unsigned char *)((unsigned long)(addr) & 0x00ffffff); \
> > + __v; })
>
> How about moving #define IO_SPACE_LIMIT up and using that instead?
>

It is so.

Signed-off-by: Yoshinori Sato <[email protected]>

diff -Nru a/include/asm-h8300/io.h b/include/asm-h8300/io.h
--- a/include/asm-h8300/io.h 2004-11-14 00:21:49 +09:00
+++ b/include/asm-h8300/io.h 2004-11-14 00:21:49 +09:00
@@ -69,16 +69,27 @@
#endif
}

+#define IO_SPACE_LIMIT 0xffffff
+
#define readb(addr) \
- ({ unsigned char __v = (*(volatile unsigned char *) ((addr) & 0x00ffffff)); __v; })
+ ({ unsigned char __v = \
+ *(volatile unsigned char *)((unsigned long)(addr) & IO_SPACE_LIMIT); \
+ __v; })
#define readw(addr) \
- ({ unsigned short __v = (*(volatile unsigned short *) ((addr) & 0x00ffffff)); __v; })
+ ({ unsigned short __v = \
+ *(volatile unsigned short *)((unsigned long)(addr) & IO_SPACE_LIMIT); \
+ __v; })
#define readl(addr) \
- ({ unsigned int __v = (*(volatile unsigned int *) ((addr) & 0x00ffffff)); __v; })
-
-#define writeb(b,addr) (void)((*(volatile unsigned char *) ((addr) & 0x00ffffff)) = (b))
-#define writew(b,addr) (void)((*(volatile unsigned short *) ((addr) & 0x00ffffff)) = (b))
-#define writel(b,addr) (void)((*(volatile unsigned int *) ((addr) & 0x00ffffff)) = (b))
+ ({ unsigned long __v = \
+ *(volatile unsigned long *)((unsigned long)(addr) & IO_SPACE_LIMIT); \
+ __v; })
+
+#define writeb(b,addr) (void)((*(volatile unsigned char *) \
+ ((unsigned long)(addr) & IO_SPACE_LIMIT)) = (b))
+#define writew(b,addr) (void)((*(volatile unsigned short *) \
+ ((unsigned long)(addr) & IO_SPACE_LIMIT)) = (b))
+#define writel(b,addr) (void)((*(volatile unsigned long *) \
+ ((unsigned long)(addr) & IO_SPACE_LIMIT)) = (b))
#define readb_relaxed(addr) readb(addr)
#define readw_relaxed(addr) readw(addr)
#define readl_relaxed(addr) readl(addr)
@@ -224,9 +235,6 @@
#define insb(a,b,l) io_insb(a,b,l)
#define insw(a,b,l) io_insw(a,b,l)
#define insl(a,b,l) io_insl(a,b,l)
-
-#define IO_SPACE_LIMIT 0xffffff
-

/* Values for nocacheflag and cmode */
#define IOMAP_FULL_CACHING 0

--
Yoshinori Sato
<[email protected]>