Skip to contentSkip to conversation

ARM: asm/io.h: kill off confusing #ifdef __mem_pci block

PATCH New Rasmus Villemoes 2 participants 4 messages Sep 10, 2019 – Oct 12, 2019 Arm (32-bit)

lore
Share & tools
lore
#0 lore raw

PATCH 1/2 ARM: asm/io.h: kill off confusing #ifdef __mem_pci block

No ARM board seems to define __mem_pci - and if it did, one would get tons of

./arch/arm/include/asm/io.h:307:0: warning: "readl" redefined

warnings, because readl and friends are unconditionally defined earlier in io.h. Moreover, the redefinitions lack the memory barriers that the first definitions have. So I'm guessing this is practically dead code.

---
 arch/arm/include/asm/io.h | 41 ---------------------------------------
 1 file changed, 41 deletions(-)
arch/arm/include/asm/io.h +0 -41
index e6d27b69f9..78b183d42f 100644
@@ -315,46 +315,6 @@ extern void _memset_io(unsigned long, int, size_t);
 
 extern void __readwrite_bug(const char *fn);
 
-/*
- * If this architecture has PCI memory IO, then define the read/write
- * macros.  These should only be used with the cookie passed from
- * ioremap.
- */
-#ifdef __mem_pci
-
-#define readb(c) ({ unsigned int __v = __raw_readb(__mem_pci(c)); __v; })
-#define readw(c) ({ unsigned int __v = le16_to_cpu(__raw_readw(__mem_pci(c))); __v; })
-#define readl(c) ({ unsigned int __v = le32_to_cpu(__raw_readl(__mem_pci(c))); __v; })
-
-#define writeb(v,c)		__raw_writeb(v,__mem_pci(c))
-#define writew(v,c)		__raw_writew(cpu_to_le16(v),__mem_pci(c))
-#define writel(v,c)		__raw_writel(cpu_to_le32(v),__mem_pci(c))
-
-#define memset_io(c,v,l)		_memset_io(__mem_pci(c),(v),(l))
-#define memcpy_fromio(a,c,l)		_memcpy_fromio((a),__mem_pci(c),(l))
-#define memcpy_toio(c,a,l)		_memcpy_toio(__mem_pci(c),(a),(l))
-
-#define eth_io_copy_and_sum(s,c,l,b) \
-				eth_copy_and_sum((s),__mem_pci(c),(l),(b))
-
-static inline int
-check_signature(unsigned long io_addr, const unsigned char *signature,
-		int length)
-{
-	int retval = 0;
-	do {
-		if (readb(io_addr) != *signature)
-			goto out;
-		io_addr++;
-		signature++;
-		length--;
-	} while (length);
-	retval = 1;
-out:
-	return retval;
-}
-
-#else
 #define memset_io(a, b, c)		memset((void *)(a), (b), (c))
 #define memcpy_fromio(a, b, c)		memcpy((a), (void *)(b), (c))
 #define memcpy_toio(a, b, c)		memcpy((void *)(a), (b), (c))
@@ -373,7 +333,6 @@ out:
 #define check_signature(io,sig,len)	(0)
 
 #endif
-#endif	/* __mem_pci */
 
 /*
  * If this architecture has ISA IO, then define the isa_read/isa_write
Signature · 1 line
2.20.1
#1 lore raw

PATCH 2/2 ARM: asm/io.h: remove redundant #if !defined(readb) block

readb is unconditionally defined earlier in io.h, so there's no point checking whether it's undefined.

---
 arch/arm/include/asm/io.h | 15 ---------------
 1 file changed, 15 deletions(-)
arch/arm/include/asm/io.h +0 -15
index 78b183d42f..723f3cf497 100644
@@ -319,21 +319,6 @@ extern void __readwrite_bug(const char *fn);
 #define memcpy_fromio(a, b, c)		memcpy((a), (void *)(b), (c))
 #define memcpy_toio(a, b, c)		memcpy((void *)(a), (b), (c))
 
-#if !defined(readb)
-
-#define readb(addr)			(__readwrite_bug("readb"),0)
-#define readw(addr)			(__readwrite_bug("readw"),0)
-#define readl(addr)			(__readwrite_bug("readl"),0)
-#define writeb(v,addr)			__readwrite_bug("writeb")
-#define writew(v,addr)			__readwrite_bug("writew")
-#define writel(v,addr)			__readwrite_bug("writel")
-
-#define eth_io_copy_and_sum(a,b,c,d)	__readwrite_bug("eth_io_copy_and_sum")
-
-#define check_signature(io,sig,len)	(0)
-
-#endif
-
 /*
  * If this architecture has ISA IO, then define the isa_read/isa_write
  * macros.
Signature · 1 line
2.20.1
#2 lore raw

PATCH 2/2 ARM: asm/io.h: remove redundant #if !defined(readb) block

Quoted 4 lines · Rasmus Villemoes

readb is unconditionally defined earlier in io.h, so there's no point checking whether it's undefined.

Applied to u-boot/master, thanks!

Signature · 8 lines
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 833 bytes
Desc: not available
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20191012/96483672/attachment.sig>
#3 lore raw

PATCH 1/2 ARM: asm/io.h: kill off confusing #ifdef __mem_pci block

In reply to Rasmus Villemoes
Quoted 10 lines · Rasmus Villemoes

No ARM board seems to define __mem_pci - and if it did, one would get tons of

./arch/arm/include/asm/io.h:307:0: warning: "readl" redefined

warnings, because readl and friends are unconditionally defined earlier in io.h. Moreover, the redefinitions lack the memory barriers that the first definitions have. So I'm guessing this is practically dead code.

Applied to u-boot/master, thanks!

Signature · 8 lines
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 833 bytes
Desc: not available
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20191012/a9d36c0c/attachment.sig>