[PATCH v2 1/2] alpha: rework use of memset_io, memsetw_io and scr_memsetw

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



In order to prepare the alpha architecture to use the generic IO
functions from lib/iomem_copy.c, rename _memset_c_io to memsetw_io.
Then move scr_memsetw to io.c, along the scr_memcpyw and scr_memmovew,
inside the CONFIG_VGA_CONSOLE.

Signed-off-by: Julian Vetter <julian@xxxxxxxxxxxxxxxx>
---
Changes for V2:
- Split the patch into two:
  - One that shuffles the memsetw_io and _memset_c_io around
  - And one that removed the memcpy_fromio and memcpy_toio
---
 arch/alpha/include/asm/io.h  | 14 +------------
 arch/alpha/include/asm/vga.h |  9 +--------
 arch/alpha/kernel/io.c       | 38 +++++++++++++++++++-----------------
 3 files changed, 22 insertions(+), 39 deletions(-)

diff --git a/arch/alpha/include/asm/io.h b/arch/alpha/include/asm/io.h
index 65fe1e54c6da..d6e868872e19 100644
--- a/arch/alpha/include/asm/io.h
+++ b/arch/alpha/include/asm/io.h
@@ -592,20 +592,8 @@ extern inline u64 readq_relaxed(const volatile void __iomem *addr)
  */
 extern void memcpy_fromio(void *, const volatile void __iomem *, long);
 extern void memcpy_toio(volatile void __iomem *, const void *, long);
-extern void _memset_c_io(volatile void __iomem *, unsigned long, long);
+extern void memsetw_io(volatile void __iomem *to, u16 c, long count);
 
-static inline void memset_io(volatile void __iomem *addr, u8 c, long len)
-{
-	_memset_c_io(addr, 0x0101010101010101UL * c, len);
-}
-
-#define __HAVE_ARCH_MEMSETW_IO
-static inline void memsetw_io(volatile void __iomem *addr, u16 c, long len)
-{
-	_memset_c_io(addr, 0x0001000100010001UL * c, len);
-}
-
-#define memset_io memset_io
 #define memcpy_fromio memcpy_fromio
 #define memcpy_toio memcpy_toio
 
diff --git a/arch/alpha/include/asm/vga.h b/arch/alpha/include/asm/vga.h
index 919931cb5b63..01611d792597 100644
--- a/arch/alpha/include/asm/vga.h
+++ b/arch/alpha/include/asm/vga.h
@@ -31,17 +31,10 @@ static inline u16 scr_readw(volatile const u16 *addr)
 		return *addr;
 }
 
-static inline void scr_memsetw(u16 *s, u16 c, unsigned int count)
-{
-	if (__is_ioaddr(s))
-		memsetw_io((u16 __iomem *) s, c, count);
-	else
-		memset16(s, c, count / 2);
-}
-
 /* Do not trust that the usage will be correct; analyze the arguments.  */
 extern void scr_memcpyw(u16 *d, const u16 *s, unsigned int count);
 extern void scr_memmovew(u16 *d, const u16 *s, unsigned int count);
+extern void scr_memsetw(u16 *s, u16 c, unsigned int count);
 
 /* ??? These are currently only used for downloading character sets.  As
    such, they don't need memory barriers.  Is this all they are intended
diff --git a/arch/alpha/kernel/io.c b/arch/alpha/kernel/io.c
index c28035d6d1e6..353b1dcbd422 100644
--- a/arch/alpha/kernel/io.c
+++ b/arch/alpha/kernel/io.c
@@ -585,29 +585,31 @@ void memcpy_toio(volatile void __iomem *to, const void *from, long count)
 
 EXPORT_SYMBOL(memcpy_toio);
 
+#if IS_ENABLED(CONFIG_VGA_CONSOLE) || IS_ENABLED(CONFIG_MDA_CONSOLE)
 
-/*
- * "memset" on IO memory space.
- */
-void _memset_c_io(volatile void __iomem *to, unsigned long c, long count)
+#include <asm/vga.h>
+
+void memsetw_io(volatile void __iomem *to, u16 c, long count)
 {
+	unsigned long v = 0x0001000100010001UL * c;
+
 	/* Handle any initial odd byte */
 	if (count > 0 && ((u64)to & 1)) {
-		__raw_writeb(c, to);
+		__raw_writeb(v, to);
 		to++;
 		count--;
 	}
 
 	/* Handle any initial odd halfword */
 	if (count >= 2 && ((u64)to & 2)) {
-		__raw_writew(c, to);
+		__raw_writew(v, to);
 		to += 2;
 		count -= 2;
 	}
 
 	/* Handle any initial odd word */
 	if (count >= 4 && ((u64)to & 4)) {
-		__raw_writel(c, to);
+		__raw_writel(v, to);
 		to += 4;
 		count -= 4;
 	}
@@ -617,7 +619,7 @@ void _memset_c_io(volatile void __iomem *to, unsigned long c, long count)
 	count -= 8;
 	if (count >= 0) {
 		do {
-			__raw_writeq(c, to);
+			__raw_writeq(v, to);
 			to += 8;
 			count -= 8;
 		} while (count >= 0);
@@ -626,14 +628,14 @@ void _memset_c_io(volatile void __iomem *to, unsigned long c, long count)
 
 	/* The tail is word-aligned if we still have count >= 4 */
 	if (count >= 4) {
-		__raw_writel(c, to);
+		__raw_writel(v, to);
 		to += 4;
 		count -= 4;
 	}
 
 	/* The tail is half-word aligned if we have count >= 2 */
 	if (count >= 2) {
-		__raw_writew(c, to);
+		__raw_writew(v, to);
 		to += 2;
 		count -= 2;
 	}
@@ -645,14 +647,14 @@ void _memset_c_io(volatile void __iomem *to, unsigned long c, long count)
 	mb();
 }
 
-EXPORT_SYMBOL(_memset_c_io);
-
-#if IS_ENABLED(CONFIG_VGA_CONSOLE) || IS_ENABLED(CONFIG_MDA_CONSOLE)
-
-#include <asm/vga.h>
-
-/* A version of memcpy used by the vga console routines to move data around
-   arbitrarily between screen and main memory.  */
+void scr_memsetw(u16 *s, u16 c, unsigned int count)
+{
+	if (__is_ioaddr(s))
+		memsetw_io((u16 __iomem *) s, c, count);
+	else
+		memset16(s, c, count / 2);
+}
+EXPORT_SYMBOL(scr_memsetw);
 
 void
 scr_memcpyw(u16 *d, const u16 *s, unsigned int count)
-- 
2.34.1





[Index of Archives]     [Netdev]     [Linux Wireless]     [Kernel Newbies]     [Security]     [Linux for Hams]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux Admin]     [Samba]

  Powered by Linux