Skip to contentSkip to conversation

arch: m32r: include: asm: add generic ioremap_wc() definition

PATCH New Chen Gang 3 participants 12 messages Jun 27, 2013 – Jun 28, 2013 Generic include/asm header files

lore
Share & tools
lore

Chen Gang

author
#0 lore raw

PATCH 1/1 arch: m32r: include: asm: add generic ioremap_wc() definition

Add generic ioremap_wc() definition, or compiling failed.

The related error (with allmodconfig):

drivers/gpu/drm/drm_bufs.c: In function ‘drm_addmap_core’:
drivers/gpu/drm/drm_bufs.c:219:5: error: implicit declaration of function ‘ioremap_wc’ [-Werror=implicit-function-declaration] drivers/gpu/drm/drm_bufs.c:219:17: warning: assignment makes pointer from integer without a cast [enabled by default]

---
 arch/m32r/include/asm/io.h |    1 +
 1 files changed, 1 insertions(+), 0 deletions(-)
arch/m32r/include/asm/io.h +1 -0
index 4010f1f..f9f4fb6 100644
@@ -67,6 +67,7 @@ static inline void __iomem *ioremap(unsigned long offset, unsigned long size)
 
 extern void iounmap(volatile void __iomem *addr);
 #define ioremap_nocache(off,size) ioremap(off,size)
+#define ioremap_wc ioremap_nocache
 
 /*
  * IO bus memory addresses are also 1:1 with the physical address
Signature · 1 line
1.7.7.6
author
#1 lore raw

PATCH 1/1 arch: m32r: include: asm: use 'readb' instead of 'read'

Need use 'readb' instead of 'read', it is a typo issue which found by compiler.

The related error (with allmodconfig):

drivers/i2c/busses/i2c-ocores.c: In function ‘oc_getreg_8’:
drivers/i2c/busses/i2c-ocores.c:96:2: error: implicit declaration of function ‘read’ [-Werror=implicit-function-declaration]

---
 arch/m32r/include/asm/io.h |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
arch/m32r/include/asm/io.h +1 -1
index 4010f1f..343ae4c 100644
@@ -162,7 +162,7 @@ static inline void _writel(unsigned long l, unsigned long addr)
 #define __raw_writew writew
 #define __raw_writel writel
 
-#define ioread8 read
+#define ioread8 readb
 #define ioread16 readw
 #define ioread32 readl
 #define iowrite8 writeb
Signature · 1 line
1.7.7.6
author
#2 lore raw

PATCH 1/1 arch: m32r: include: asm: add ioread*be() and iowrite*be()

Add generic ioread*be() and iowrite*be(), or compiling fails.

The related error (with allmodconfig):

drivers/ipack/ipack.c: In function ‘ipack_device_read_id’:
drivers/ipack/ipack.c:376:3: error: implicit declaration of function ‘ioread16be’ [-Werror=implicit-function-declaration]

---
 arch/m32r/include/asm/io.h |    4 ++++
 1 files changed, 4 insertions(+), 0 deletions(-)
arch/m32r/include/asm/io.h +4 -0
index 4010f1f..9f9b609 100644
@@ -164,10 +164,14 @@ static inline void _writel(unsigned long l, unsigned long addr)
 
 #define ioread8 read
 #define ioread16 readw
+#define ioread16be(addr)	__be16_to_cpu(__raw_readw(addr))
 #define ioread32 readl
+#define ioread32be(addr)	__be32_to_cpu(__raw_readl(addr))
 #define iowrite8 writeb
 #define iowrite16 writew
+#define iowrite16be(v, addr)	__raw_writew(__cpu_to_be16(v), addr)
 #define iowrite32 writel
+#define iowrite32be(v, addr)	__raw_writel(__cpu_to_be32(v), addr)
 
 #define mmiowb()
 
Signature · 1 line
1.7.7.6
author
#3 lore raw

PATCH 1/1 arch: m32r: include: asm: add ioread*_rep() and iowrite*_rep()

add generic ioread*_rep() and iowrite*_rep(), or compiling failed.

The related error (with allmodconfig):

CC [M] drivers/mtd/nand/nand_base.o
drivers/mtd/nand/nand_base.c: In function ‘nand_write_buf’:
drivers/mtd/nand/nand_base.c:216:2: error: implicit declaration of function ‘iowrite8_rep’ [-Werror=implicit-function-declaration] drivers/mtd/nand/nand_base.c: In function ‘nand_read_buf’:
drivers/mtd/nand/nand_base.c:231:2: error: implicit declaration of function ‘ioread8_rep’ [-Werror=implicit-function-declaration] drivers/mtd/nand/nand_base.c: In function ‘nand_write_buf16’:
drivers/mtd/nand/nand_base.c:247:2: error: implicit declaration of function ‘iowrite16_rep’ [-Werror=implicit-function-declaration] drivers/mtd/nand/nand_base.c: In function ‘nand_read_buf16’:
drivers/mtd/nand/nand_base.c:263:2: error: implicit declaration of function ‘ioread16_rep’ [-Werror=implicit-function-declaration]

---
 arch/m32r/include/asm/io.h |   14 ++++++++++++++
 1 files changed, 14 insertions(+), 0 deletions(-)
arch/m32r/include/asm/io.h +14 -0
index 4010f1f..167d6ed 100644
@@ -169,6 +169,20 @@ static inline void _writel(unsigned long l, unsigned long addr)
 #define iowrite16 writew
 #define iowrite32 writel
 
+#define ioread8_rep(p, dst, count) \
+	insb((unsigned long) (p), (dst), (count))
+#define ioread16_rep(p, dst, count) \
+	insw((unsigned long) (p), (dst), (count))
+#define ioread32_rep(p, dst, count) \
+	insl((unsigned long) (p), (dst), (count))
+
+#define iowrite8_rep(p, src, count) \
+	outsb((unsigned long) (p), (src), (count))
+#define iowrite16_rep(p, src, count) \
+	outsw((unsigned long) (p), (src), (count))
+#define iowrite32_rep(p, src, count) \
+	outsl((unsigned long) (p), (src), (count))
+
 #define mmiowb()
 
 #define flush_write_buffers() do { } while (0)  /* M32R_FIXME */
Signature · 1 line
1.7.7.6
author
#4 lore raw

Re: [PATCH] arch: m32r: include: asm: add ioread*_rep() and iowrite*_rep()

Hello Maintainers:

If the related 4 patches for io.h pass your checking, it seems OK to merge them into one patch, the diff like below:

--------------------------------diff begin------------------------------

arch/m32r/include/asm/io.h +20 -1
index 4010f1f..5506d86 100644
@@ -67,6 +67,7 @@ static inline void __iomem *ioremap(unsigned long offset, unsigned long size)
 
 extern void iounmap(volatile void __iomem *addr);
 #define ioremap_nocache(off,size) ioremap(off,size)
+#define ioremap_wc ioremap_nocache
 
 /*
  * IO bus memory addresses are also 1:1 with the physical address
@@ -162,12 +163,30 @@ static inline void _writel(unsigned long l, unsigned long addr)
 #define __raw_writew writew
 #define __raw_writel writel
 
-#define ioread8 read
+#define ioread8 readb
 #define ioread16 readw
+#define ioread16be(addr)        __be16_to_cpu(__raw_readw(addr))
 #define ioread32 readl
+#define ioread32be(addr)        __be32_to_cpu(__raw_readl(addr))
 #define iowrite8 writeb
 #define iowrite16 writew
+#define iowrite16be(v, addr)    __raw_writew(__cpu_to_be16(v), addr)
 #define iowrite32 writel
+#define iowrite32be(v, addr)    __raw_writel(__cpu_to_be32(v), addr)
+
+#define ioread8_rep(p, dst, count) \
+	insb((unsigned long) (p), (dst), (count))
+#define ioread16_rep(p, dst, count) \
+	insw((unsigned long) (p), (dst), (count))
+#define ioread32_rep(p, dst, count) \
+	insl((unsigned long) (p), (dst), (count))
+
+#define iowrite8_rep(p, src, count) \
+	outsb((unsigned long) (p), (src), (count))
+#define iowrite16_rep(p, src, count) \
+	outsw((unsigned long) (p), (src), (count))
+#define iowrite32_rep(p, src, count) \
+	outsl((unsigned long) (p), (src), (count))
 
 #define mmiowb()
 

--------------------------------diff end--------------------------------

Thanks.

Quoted 46 lines · Chen Gang

add generic ioread*_rep() and iowrite*_rep(), or compiling failed.

The related error (with allmodconfig):

CC [M] drivers/mtd/nand/nand_base.o
drivers/mtd/nand/nand_base.c: In function ‘nand_write_buf’:
drivers/mtd/nand/nand_base.c:216:2: error: implicit declaration of function ‘iowrite8_rep’ [-Werror=implicit-function-declaration] drivers/mtd/nand/nand_base.c: In function ‘nand_read_buf’:
drivers/mtd/nand/nand_base.c:231:2: error: implicit declaration of function ‘ioread8_rep’ [-Werror=implicit-function-declaration] drivers/mtd/nand/nand_base.c: In function ‘nand_write_buf16’:
drivers/mtd/nand/nand_base.c:247:2: error: implicit declaration of function ‘iowrite16_rep’ [-Werror=implicit-function-declaration] drivers/mtd/nand/nand_base.c: In function ‘nand_read_buf16’:
drivers/mtd/nand/nand_base.c:263:2: error: implicit declaration of function ‘ioread16_rep’ [-Werror=implicit-function-declaration]

---
 arch/m32r/include/asm/io.h |   14 ++++++++++++++
 1 files changed, 14 insertions(+), 0 deletions(-)
arch/m32r/include/asm/io.h +14 -0
index 4010f1f..167d6ed 100644
@@ -169,6 +169,20 @@ static inline void _writel(unsigned long l, unsigned long addr)
 #define iowrite16 writew
 #define iowrite32 writel
 
+#define ioread8_rep(p, dst, count) \
+	insb((unsigned long) (p), (dst), (count))
+#define ioread16_rep(p, dst, count) \
+	insw((unsigned long) (p), (dst), (count))
+#define ioread32_rep(p, dst, count) \
+	insl((unsigned long) (p), (dst), (count))
+
+#define iowrite8_rep(p, src, count) \
+	outsb((unsigned long) (p), (src), (count))
+#define iowrite16_rep(p, src, count) \
+	outsw((unsigned long) (p), (src), (count))
+#define iowrite32_rep(p, src, count) \
+	outsl((unsigned long) (p), (src), (count))
+
 #define mmiowb()
 
 #define flush_write_buffers() do { } while (0)  /* M32R_FIXME */
Signature · 1 line
Chen Gang
#5 lore raw

Re: [PATCH] arch: m32r: include: asm: add ioread*_rep() and iowrite*_rep()

In reply to Chen Gang

arch/m32r/include/asm/io.h static inline void _writel(unsigned long l, unsigned long addr) · line 173

Quoted 8 lines · Chen Gang
arch/m32r/include/asm/io.h +2 -0
@@ -169,6 +169,20 @@ static inline void _writel(unsigned long l, unsigned long addr)
 #define iowrite16 writew
 #define iowrite32 writel
 
+#define ioread8_rep(p, dst, count) \
+       insb((unsigned long) (p), (dst), (count))

As ioread8() is mapped to readb() (I/O memory space), not inb() (I/O port space),
ioread8_rep() should map to readsb() (which m32r doesn't have yet BTW), not insb().
For m32r this does matter, as inb() and readb() use different mechanisms internally.

It seems include/asm-generic/io.h also has this wrong?

Gr{oetje,eeting}s,

Geert

--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- [email protected]

In personal conversations with technical people, I call myself a hacker. But when I'm talking to journalists I just say "programmer" or something like that.
-- Linus Torvalds

maintainer
#6 lore raw

Re: [PATCH] arch: m32r: include: asm: add ioread*_rep() and iowrite*_rep()

Quoted 17 lines · On Thursday 27 June 2013 09:07:29 Geert Uytterhoeven wrote:

arch/m32r/include/asm/io.h static inline void _writel(unsigned long l, unsigned long addr) · line 173

Quoted 8 lines · Chen Gang
arch/m32r/include/asm/io.h +2 -0
@@ -169,6 +169,20 @@ static inline void _writel(unsigned long l, unsigned long addr)
 #define iowrite16 writew
 #define iowrite32 writel
 
+#define ioread8_rep(p, dst, count) \
+       insb((unsigned long) (p), (dst), (count))

As ioread8() is mapped to readb() (I/O memory space), not inb() (I/O port space),
ioread8_rep() should map to readsb() (which m32r doesn't have yet BTW), not insb().
For m32r this does matter, as inb() and readb() use different mechanisms internally.

Quoted 1 line

It seems include/asm-generic/io.h also has this wrong?

Yes, you are right. I thought we had fixed that long ago.

Does the patch below look ok to you? Note that none of the architectures using asm-generic/io.h supports PIO access and it works by chance this way, but we should definitely fix it.

include/asm-generic/io.h +50 -50
index d5afe96..8af7a64 100644
@@ -161,108 +161,108 @@ static inline void outl(u32 b, unsigned long addr)
 #define outw_p(x, addr)	outw((x), (addr))
 #define outl_p(x, addr)	outl((x), (addr))
 
-#ifndef insb
-static inline void insb(unsigned long addr, void *buffer, int count)
+#ifndef CONFIG_GENERIC_IOMAP
+#define ioread8(addr)		readb(addr)
+#define ioread16(addr)		readw(addr)
+#define ioread16be(addr)	__be16_to_cpu(__raw_readw(addr))
+#define ioread32(addr)		readl(addr)
+#define ioread32be(addr)	__be32_to_cpu(__raw_readl(addr))
+
+#define iowrite8(v, addr)	writeb((v), (addr))
+#define iowrite16(v, addr)	writew((v), (addr))
+#define iowrite16be(v, addr)	__raw_writew(__cpu_to_be16(v), addr)
+#define iowrite32(v, addr)	writel((v), (addr))
+#define iowrite32be(v, addr)	__raw_writel(__cpu_to_be32(v), addr)
+
+static inline void ioread8_rep(void __iomem *addr, void *buffer, int count)
 {
 	if (count) {
 		u8 *buf = buffer;
 		do {
-			u8 x = __raw_readb(addr + PCI_IOBASE);
+			u8 x = __raw_readb(addr);
 			*buf++ = x;
 		} while (--count);
 	}
 }
-#endif
 
-#ifndef insw
-static inline void insw(unsigned long addr, void *buffer, int count)
+static inline void ioread16_rep(void __iomem *addr, void *buffer, int count)
 {
 	if (count) {
 		u16 *buf = buffer;
 		do {
-			u16 x = __raw_readw(addr + PCI_IOBASE);
+			u16 x = __raw_readw(addr);
 			*buf++ = x;
 		} while (--count);
 	}
 }
-#endif
 
-#ifndef insl
-static inline void insl(unsigned long addr, void *buffer, int count)
+static inline void ioread32_rep(void __iomem *addr, void *buffer, int count)
 {
 	if (count) {
 		u32 *buf = buffer;
 		do {
-			u32 x = __raw_readl(addr + PCI_IOBASE);
+			u32 x = __raw_readl(addr);
 			*buf++ = x;
 		} while (--count);
 	}
 }
-#endif
 
-#ifndef outsb
-static inline void outsb(unsigned long addr, const void *buffer, int count)
+static inline void iowrite8_rep(void __iomem *addr, const void *buffer, int count)
 {
 	if (count) {
 		const u8 *buf = buffer;
 		do {
-			__raw_writeb(*buf++, addr + PCI_IOBASE);
+			__raw_writeb(*buf++, addr);
 		} while (--count);
 	}
 }
-#endif
 
-#ifndef outsw
-static inline void outsw(unsigned long addr, const void *buffer, int count)
+static inline void iowrite16_rep(void __iomem *addr, const void *buffer, int count)
 {
 	if (count) {
 		const u16 *buf = buffer;
 		do {
-			__raw_writew(*buf++, addr + PCI_IOBASE);
+			__raw_writew(*buf++, addr);
 		} while (--count);
 	}
 }
-#endif
 
-#ifndef outsl
-static inline void outsl(unsigned long addr, const void *buffer, int count)
+static inline void iowrite32_rep(void __iomem *addr, const void *buffer, int count)
 {
 	if (count) {
 		const u32 *buf = buffer;
 		do {
-			__raw_writel(*buf++, addr + PCI_IOBASE);
+			__raw_writel(*buf++, addr);
 		} while (--count);
 	}
 }
-#endif
-
-#ifndef CONFIG_GENERIC_IOMAP
-#define ioread8(addr)		readb(addr)
-#define ioread16(addr)		readw(addr)
-#define ioread16be(addr)	__be16_to_cpu(__raw_readw(addr))
-#define ioread32(addr)		readl(addr)
-#define ioread32be(addr)	__be32_to_cpu(__raw_readl(addr))
+#endif /* CONFIG_GENERIC_IOMAP */
 
-#define iowrite8(v, addr)	writeb((v), (addr))
-#define iowrite16(v, addr)	writew((v), (addr))
-#define iowrite16be(v, addr)	__raw_writew(__cpu_to_be16(v), addr)
-#define iowrite32(v, addr)	writel((v), (addr))
-#define iowrite32be(v, addr)	__raw_writel(__cpu_to_be32(v), addr)
+#ifndef insb
+#define insb(a, dst, count) \
+	ioread8_rep((a) + PCI_IOBASE, (dst), (count))
+#endif
+#ifndef insw
+#define insw(a, dst, count) \
+	ioread16_rep((a) + PCI_IOBASE, (dst), (count))
+#endif
+#ifndef insl
+#define insl(a, dst, count) \
+	ioread32_rep((a) + PCI_IOBASE, (dst), (count))
+#endif
 
-#define ioread8_rep(p, dst, count) \
-	insb((unsigned long) (p), (dst), (count))
-#define ioread16_rep(p, dst, count) \
-	insw((unsigned long) (p), (dst), (count))
-#define ioread32_rep(p, dst, count) \
-	insl((unsigned long) (p), (dst), (count))
-
-#define iowrite8_rep(p, src, count) \
-	outsb((unsigned long) (p), (src), (count))
-#define iowrite16_rep(p, src, count) \
-	outsw((unsigned long) (p), (src), (count))
-#define iowrite32_rep(p, src, count) \
-	outsl((unsigned long) (p), (src), (count))
-#endif /* CONFIG_GENERIC_IOMAP */
+#ifndef outsb
+#define outsb(a, src, count) \
+	iowrite8_rep((a) + PCI_IOBASE, (src), (count))
+#endif
+#ifndef outsw
+#define outsw(a, src, count) \
+	iowrite16_rep((a) + PCI_IOBASE, (src), (count))
+#endif
+#ifndef outsl
+#define outsl(a, src, count) \
+	iowrite32_rep((a) + PCI_IOBASE, (src), (count))
+#endif
 
 #ifndef IO_SPACE_LIMIT
 #define IO_SPACE_LIMIT 0xffff
#7 lore raw

Re: [PATCH] arch: m32r: include: asm: add ioread*_rep() and iowrite*_rep()

Quoted 20 lines · Arnd Bergmann
Quoted 17 lines · On Thursday 27 June 2013 09:07:29 Geert Uytterhoeven wrote:

arch/m32r/include/asm/io.h static inline void _writel(unsigned long l, unsigned long addr) · line 173

Quoted 8 lines · Chen Gang
arch/m32r/include/asm/io.h +2 -0
@@ -169,6 +169,20 @@ static inline void _writel(unsigned long l, unsigned long addr)
 #define iowrite16 writew
 #define iowrite32 writel
 
+#define ioread8_rep(p, dst, count) \
+       insb((unsigned long) (p), (dst), (count))

As ioread8() is mapped to readb() (I/O memory space), not inb() (I/O port space),
ioread8_rep() should map to readsb() (which m32r doesn't have yet BTW), not insb().
For m32r this does matter, as inb() and readb() use different mechanisms internally.

Quoted 1 line

It seems include/asm-generic/io.h also has this wrong?

Quoted 7 lines

Yes, you are right. I thought we had fixed that long ago.

Does the patch below look ok to you? Note that none of the architectures using asm-generic/io.h supports PIO access and it works by chance this way, but we should definitely fix it.

Gr{oetje,eeting}s,

Geert

--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- [email protected]

In personal conversations with technical people, I call myself a hacker. But when I'm talking to journalists I just say "programmer" or something like that.
-- Linus Torvalds

author
#8 lore raw

Re: [PATCH] arch: m32r: include: asm: add ioread*_rep() and iowrite*_rep()

In reply to Arnd Bergmann
Quoted 18 lines · Arnd Bergmann
Quoted 17 lines · On Thursday 27 June 2013 09:07:29 Geert Uytterhoeven wrote:
Quoted 17 lines · Chen Gang
Quoted 8 lines

arch/m32r/include/asm/io.h static inline void _writel(unsigned long l, unsigned long addr) · line 173

Quoted 8 lines
arch/m32r/include/asm/io.h +2 -0
@@ -169,6 +169,20 @@ static inline void _writel(unsigned long l, unsigned long addr)
 #define iowrite16 writew
 #define iowrite32 writel
 
+#define ioread8_rep(p, dst, count) \
+       insb((unsigned long) (p), (dst), (count))

As ioread8() is mapped to readb() (I/O memory space), not inb() (I/O port space),
ioread8_rep() should map to readsb() (which m32r doesn't have yet BTW), not insb().
For m32r this does matter, as inb() and readb() use different mechanisms internally.

Quoted 9 lines
Quoted 1 line
Quoted 1 line

It seems include/asm-generic/io.h also has this wrong?

Yes, you are right. I thought we had fixed that long ago.

Does the patch below look ok to you? Note that none of the architectures using asm-generic/io.h supports PIO access and it works by chance this way, but we should definitely fix it.

Is it better to let the code block (from "#ifndef CONFIG_GENERIC_IOMAP to #endif) in an individual file (e.g. iomap_inline.h)?

So that many architectures (m32r, tile, ...) can include the individual file to get these necessary code, and not need consider the confilict about the other code in generic io.h ?

Thanks.

Quoted 163 lines
include/asm-generic/io.h +50 -50
index d5afe96..8af7a64 100644
@@ -161,108 +161,108 @@ static inline void outl(u32 b, unsigned long addr)
 #define outw_p(x, addr)	outw((x), (addr))
 #define outl_p(x, addr)	outl((x), (addr))
 
-#ifndef insb
-static inline void insb(unsigned long addr, void *buffer, int count)
+#ifndef CONFIG_GENERIC_IOMAP
+#define ioread8(addr)		readb(addr)
+#define ioread16(addr)		readw(addr)
+#define ioread16be(addr)	__be16_to_cpu(__raw_readw(addr))
+#define ioread32(addr)		readl(addr)
+#define ioread32be(addr)	__be32_to_cpu(__raw_readl(addr))
+
+#define iowrite8(v, addr)	writeb((v), (addr))
+#define iowrite16(v, addr)	writew((v), (addr))
+#define iowrite16be(v, addr)	__raw_writew(__cpu_to_be16(v), addr)
+#define iowrite32(v, addr)	writel((v), (addr))
+#define iowrite32be(v, addr)	__raw_writel(__cpu_to_be32(v), addr)
+
+static inline void ioread8_rep(void __iomem *addr, void *buffer, int count)
 {
 	if (count) {
 		u8 *buf = buffer;
 		do {
-			u8 x = __raw_readb(addr + PCI_IOBASE);
+			u8 x = __raw_readb(addr);
 			*buf++ = x;
 		} while (--count);
 	}
 }
-#endif
 
-#ifndef insw
-static inline void insw(unsigned long addr, void *buffer, int count)
+static inline void ioread16_rep(void __iomem *addr, void *buffer, int count)
 {
 	if (count) {
 		u16 *buf = buffer;
 		do {
-			u16 x = __raw_readw(addr + PCI_IOBASE);
+			u16 x = __raw_readw(addr);
 			*buf++ = x;
 		} while (--count);
 	}
 }
-#endif
 
-#ifndef insl
-static inline void insl(unsigned long addr, void *buffer, int count)
+static inline void ioread32_rep(void __iomem *addr, void *buffer, int count)
 {
 	if (count) {
 		u32 *buf = buffer;
 		do {
-			u32 x = __raw_readl(addr + PCI_IOBASE);
+			u32 x = __raw_readl(addr);
 			*buf++ = x;
 		} while (--count);
 	}
 }
-#endif
 
-#ifndef outsb
-static inline void outsb(unsigned long addr, const void *buffer, int count)
+static inline void iowrite8_rep(void __iomem *addr, const void *buffer, int count)
 {
 	if (count) {
 		const u8 *buf = buffer;
 		do {
-			__raw_writeb(*buf++, addr + PCI_IOBASE);
+			__raw_writeb(*buf++, addr);
 		} while (--count);
 	}
 }
-#endif
 
-#ifndef outsw
-static inline void outsw(unsigned long addr, const void *buffer, int count)
+static inline void iowrite16_rep(void __iomem *addr, const void *buffer, int count)
 {
 	if (count) {
 		const u16 *buf = buffer;
 		do {
-			__raw_writew(*buf++, addr + PCI_IOBASE);
+			__raw_writew(*buf++, addr);
 		} while (--count);
 	}
 }
-#endif
 
-#ifndef outsl
-static inline void outsl(unsigned long addr, const void *buffer, int count)
+static inline void iowrite32_rep(void __iomem *addr, const void *buffer, int count)
 {
 	if (count) {
 		const u32 *buf = buffer;
 		do {
-			__raw_writel(*buf++, addr + PCI_IOBASE);
+			__raw_writel(*buf++, addr);
 		} while (--count);
 	}
 }
-#endif
-
-#ifndef CONFIG_GENERIC_IOMAP
-#define ioread8(addr)		readb(addr)
-#define ioread16(addr)		readw(addr)
-#define ioread16be(addr)	__be16_to_cpu(__raw_readw(addr))
-#define ioread32(addr)		readl(addr)
-#define ioread32be(addr)	__be32_to_cpu(__raw_readl(addr))
+#endif /* CONFIG_GENERIC_IOMAP */
 
-#define iowrite8(v, addr)	writeb((v), (addr))
-#define iowrite16(v, addr)	writew((v), (addr))
-#define iowrite16be(v, addr)	__raw_writew(__cpu_to_be16(v), addr)
-#define iowrite32(v, addr)	writel((v), (addr))
-#define iowrite32be(v, addr)	__raw_writel(__cpu_to_be32(v), addr)
+#ifndef insb
+#define insb(a, dst, count) \
+	ioread8_rep((a) + PCI_IOBASE, (dst), (count))
+#endif
+#ifndef insw
+#define insw(a, dst, count) \
+	ioread16_rep((a) + PCI_IOBASE, (dst), (count))
+#endif
+#ifndef insl
+#define insl(a, dst, count) \
+	ioread32_rep((a) + PCI_IOBASE, (dst), (count))
+#endif
 
-#define ioread8_rep(p, dst, count) \
-	insb((unsigned long) (p), (dst), (count))
-#define ioread16_rep(p, dst, count) \
-	insw((unsigned long) (p), (dst), (count))
-#define ioread32_rep(p, dst, count) \
-	insl((unsigned long) (p), (dst), (count))
-
-#define iowrite8_rep(p, src, count) \
-	outsb((unsigned long) (p), (src), (count))
-#define iowrite16_rep(p, src, count) \
-	outsw((unsigned long) (p), (src), (count))
-#define iowrite32_rep(p, src, count) \
-	outsl((unsigned long) (p), (src), (count))
-#endif /* CONFIG_GENERIC_IOMAP */
+#ifndef outsb
+#define outsb(a, src, count) \
+	iowrite8_rep((a) + PCI_IOBASE, (src), (count))
+#endif
+#ifndef outsw
+#define outsw(a, src, count) \
+	iowrite16_rep((a) + PCI_IOBASE, (src), (count))
+#endif
+#ifndef outsl
+#define outsl(a, src, count) \
+	iowrite32_rep((a) + PCI_IOBASE, (src), (count))
+#endif
 
 #ifndef IO_SPACE_LIMIT
 #define IO_SPACE_LIMIT 0xffff
Signature · 1 line
Chen Gang
author
#9 lore raw

Re: [PATCH] arch: m32r: include: asm: add ioread*_rep() and iowrite*_rep()

In reply to Geert Uytterhoeven
Quoted 7 lines · Geert Uytterhoeven
Quoted 6 lines · Chen Gang
arch/m32r/include/asm/io.h +0 -0
@@ -169,6 +169,20 @@ static inline void _writel(unsigned long l, unsigned long addr)
 #define iowrite16 writew
 #define iowrite32 writel
 
Quoted 10 lines

arch/m32r/include/asm/io.h static inline void _writel(unsigned long l, unsigned long addr) · line 173

Quoted 2 lines
arch/m32r/include/asm/io.h +2 -0
+#define ioread8_rep(p, dst, count) \
+       insb((unsigned long) (p), (dst), (count))

As ioread8() is mapped to readb() (I/O memory space), not inb() (I/O port space),
ioread8_rep() should map to readsb() (which m32r doesn't have yet BTW), not insb().
For m32r this does matter, as inb() and readb() use different mechanisms internally.

Reasonable, but excuse me, I am not quite familiar with it, can any other members (or maintainer) to help implement it ?

Thanks firstly.

:-)

Quoted 2 lines

It seems include/asm-generic/io.h also has this wrong?

I think it need improvement, if readsb has been defined, it should use readsb() instead, or just use insb().

Thank you to provide a good chance to send another generic patch. ;-)

Signature · 1 line
Chen Gang
#10 lore raw

Re: [PATCH] arch: m32r: include: asm: add ioread*_rep() and iowrite*_rep()

Quoted 24 lines · Chen Gang
Quoted 7 lines · Geert Uytterhoeven
Quoted 6 lines · Chen Gang
arch/m32r/include/asm/io.h +0 -0
@@ -169,6 +169,20 @@ static inline void _writel(unsigned long l, unsigned long addr)
 #define iowrite16 writew
 #define iowrite32 writel
 
Quoted 10 lines

arch/m32r/include/asm/io.h static inline void _writel(unsigned long l, unsigned long addr) · line 173

Quoted 2 lines
arch/m32r/include/asm/io.h +2 -0
+#define ioread8_rep(p, dst, count) \
+       insb((unsigned long) (p), (dst), (count))

As ioread8() is mapped to readb() (I/O memory space), not inb() (I/O port space),
ioread8_rep() should map to readsb() (which m32r doesn't have yet BTW), not insb().
For m32r this does matter, as inb() and readb() use different mechanisms internally.

Reasonable, but excuse me, I am not quite familiar with it, can any other members (or maintainer) to help implement it ?

Thanks firstly.

Quoted 7 lines

:-)

Quoted 2 lines

It seems include/asm-generic/io.h also has this wrong?

I think it need improvement, if readsb has been defined, it should use readsb() instead, or just use insb().

I think m32r can mostly use asm-generic/io.h.
I.e. arch/m32r/include/asm/io.h has to #define all the operations it implements itself, and defer the rest to asm-generic/io.h.

Gr{oetje,eeting}s,

Geert

--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- [email protected]

In personal conversations with technical people, I call myself a hacker. But when I'm talking to journalists I just say "programmer" or something like that.
-- Linus Torvalds

author
#11 lore raw

Re: [PATCH] arch: m32r: include: asm: add ioread*_rep() and iowrite*_rep()

Quoted 27 lines · Geert Uytterhoeven
Quoted 26 lines · Chen Gang
Quoted 26 lines · Geert Uytterhoeven
Quoted 7 lines
Quoted 7 lines · Chen Gang
Quoted 6 lines
Quoted 6 lines
arch/m32r/include/asm/io.h +0 -0
@@ -169,6 +169,20 @@ static inline void _writel(unsigned long l, unsigned long addr)
 #define iowrite16 writew
 #define iowrite32 writel
 
Quoted 10 lines
Quoted 10 lines
Quoted 2 lines

arch/m32r/include/asm/io.h static inline void _writel(unsigned long l, unsigned long addr) · line 173

Quoted 2 lines
arch/m32r/include/asm/io.h +2 -0
+#define ioread8_rep(p, dst, count) \
+       insb((unsigned long) (p), (dst), (count))

As ioread8() is mapped to readb() (I/O memory space), not inb() (I/O port space),
ioread8_rep() should map to readsb() (which m32r doesn't have yet BTW), not insb().
For m32r this does matter, as inb() and readb() use different mechanisms internally.

Reasonable, but excuse me, I am not quite familiar with it, can any other members (or maintainer) to help implement it ?

Thanks firstly.

:-)

Quoted 8 lines
Quoted 5 lines
Quoted 5 lines
Quoted 2 lines
Quoted 2 lines

It seems include/asm-generic/io.h also has this wrong?

I think it need improvement, if readsb has been defined, it should use readsb() instead, or just use insb().

I think m32r can mostly use asm-generic/io.h.
I.e. arch/m32r/include/asm/io.h has to #define all the operations it implements itself, and defer the rest to asm-generic/io.h.

Really it is, if Arnd's patch for asm-generic/io.h pass checking and is applied, thanks.

Hello Arnd:

Can you help to send the related patch too, since you have already send the patch for asm-generic/io.h, which this patch depends on.

Thanks.

Signature · 1 line
Chen Gang