memcpy_to/fromio cleanups for x86_64

From: Roland Dreier
Date: Mon May 17 2004 - 13:30:54 EST


My query about the types of the parameters for memcpy_toio and
memcpy_fromio was met with silence. Maybe some code can speak a
little louder.

Here is a patch for x86_64 that brings memcpy_toio and memcpy_fromio
more into line with other architectures (my approach is based on what
ia64 does), and cleans things up a little.

First of all, it makes the IO address parameter an unsigned long, so
that code that treats IO addresses as unsigned long does not get
warnings like

warning: passing arg 1 of `memcpy_toio' makes pointer from integer without a cast

Second, I moved the EXPORT_SYMBOL directly into io.c (shrinking
x8664_ksyms.c by a few lines). This means that io.o should be moved
from lib-y to obj-y, since otherwise __memcpy_toio and __memcpy_fromio
might not be included in the kernel.

Comments? Look good? Does anyone care :)?

Thanks,
Roland

Index: linux-2.6.6/arch/x86_64/kernel/x8664_ksyms.c
===================================================================
--- linux-2.6.6.orig/arch/x86_64/kernel/x8664_ksyms.c 2004-05-09 19:32:01.000000000 -0700
+++ linux-2.6.6/arch/x86_64/kernel/x8664_ksyms.c 2004-05-17 10:33:54.000000000 -0700
@@ -216,6 +216,3 @@
#endif

EXPORT_SYMBOL(sys_ioctl);
-
-EXPORT_SYMBOL(memcpy_toio);
-EXPORT_SYMBOL(memcpy_fromio);
Index: linux-2.6.6/arch/x86_64/lib/Makefile
===================================================================
--- linux-2.6.6.orig/arch/x86_64/lib/Makefile 2004-05-09 19:32:01.000000000 -0700
+++ linux-2.6.6/arch/x86_64/lib/Makefile 2004-05-17 11:17:09.000000000 -0700
@@ -4,9 +4,11 @@

CFLAGS_csum-partial.o := -funroll-loops

+obj-y := io.o
+
lib-y := csum-partial.o csum-copy.o csum-wrappers.o delay.o \
usercopy.o getuser.o putuser.o \
- thunk.o io.o clear_page.o copy_page.o bitstr.o
+ thunk.o clear_page.o copy_page.o bitstr.o
lib-y += memcpy.o memmove.o memset.o copy_user.o

lib-$(CONFIG_HAVE_DEC_LOCK) += dec_and_lock.o
Index: linux-2.6.6/arch/x86_64/lib/io.c
===================================================================
--- linux-2.6.6.orig/arch/x86_64/lib/io.c 2004-05-09 19:31:59.000000000 -0700
+++ linux-2.6.6/arch/x86_64/lib/io.c 2004-05-17 10:44:08.000000000 -0700
@@ -2,12 +2,14 @@
#include <asm/io.h>
#include <linux/module.h>

-void *memcpy_toio(void *dst,const void*src,unsigned len)
+void *__memcpy_toio(unsigned long dst,const void*src,unsigned len)
{
- return __inline_memcpy(dst,src,len);
+ return __inline_memcpy((void *) dst,src,len);
}
+EXPORT_SYMBOL(__memcpy_toio);

-void *memcpy_fromio(void *dst,const void*src,unsigned len)
+void *__memcpy_fromio(void *dst,unsigned long src,unsigned len)
{
- return __inline_memcpy(dst,src,len);
+ return __inline_memcpy(dst,(const void *) src,len);
}
+EXPORT_SYMBOL(__memcpy_fromio);
Index: linux-2.6.6/include/asm-x86_64/io.h
===================================================================
--- linux-2.6.6.orig/include/asm-x86_64/io.h 2004-05-09 19:32:28.000000000 -0700
+++ linux-2.6.6/include/asm-x86_64/io.h 2004-05-17 10:35:03.000000000 -0700
@@ -195,8 +195,13 @@
#define __raw_writel writel
#define __raw_writeq writeq

-void *memcpy_fromio(void*,const void*,unsigned);
-void *memcpy_toio(void*,const void*,unsigned);
+void *__memcpy_fromio(void*,unsigned long,unsigned);
+void *__memcpy_toio(unsigned long,const void*,unsigned);
+
+#define memcpy_fromio(to,from,len) \
+ __memcpy_fromio((to),(unsigned long)(from),(len))
+#define memcpy_toio(to,from,len) \
+ __memcpy_toio((unsigned long)(to),(from),(len))
#define memset_io(a,b,c) memset((void *)(a),(b),(c))

/*
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/