LKML Archive on lore.kernel.org
help / color / mirror / Atom feed
* What types are the parameters of memcpy_toio?
@ 2004-05-17  4:03 Roland Dreier
  2004-05-17 18:28 ` memcpy_to/fromio cleanups for x86_64 Roland Dreier
  0 siblings, 1 reply; 2+ messages in thread
From: Roland Dreier @ 2004-05-17  4:03 UTC (permalink / raw)
  To: linux-kernel

This may be a silly question, but what are the types of the parameters
of memcpy_toio and memcpy_fromio?  I was under the impression that IO
addresses are "cookies" and not pointers, and hence should be kept as
unsigned long.

However, <asm-x86_64/io.h> declares them as

void *memcpy_fromio(void*,const void*,unsigned); 
void *memcpy_toio(void*,const void*,unsigned); 

which means my code (which uses unsigned long) gets warnings like

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

Other architectures seem to expect the IO address to be unsigned long
and explicitly cast it to a pointer.

Thanks,
  Roland

^ permalink raw reply	[flat|nested] 2+ messages in thread

* memcpy_to/fromio cleanups for x86_64
  2004-05-17  4:03 What types are the parameters of memcpy_toio? Roland Dreier
@ 2004-05-17 18:28 ` Roland Dreier
  0 siblings, 0 replies; 2+ messages in thread
From: Roland Dreier @ 2004-05-17 18:28 UTC (permalink / raw)
  To: ak; +Cc: linux-kernel

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))
 
 /*

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2004-05-17 18:29 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2004-05-17  4:03 What types are the parameters of memcpy_toio? Roland Dreier
2004-05-17 18:28 ` memcpy_to/fromio cleanups for x86_64 Roland Dreier

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).