0001
0002
0003
0004
0005
0006
0007
0008 #include <linux/export.h>
0009 #include <linux/io.h>
0010 #include <linux/uaccess.h>
0011 #include <sound/core.h>
0012
0013
0014
0015
0016
0017
0018
0019
0020
0021
0022
0023 int copy_to_user_fromio(void __user *dst, const volatile void __iomem *src, size_t count)
0024 {
0025 #if defined(__i386__) || defined(CONFIG_SPARC32)
0026 return copy_to_user(dst, (const void __force*)src, count) ? -EFAULT : 0;
0027 #else
0028 char buf[256];
0029 while (count) {
0030 size_t c = count;
0031 if (c > sizeof(buf))
0032 c = sizeof(buf);
0033 memcpy_fromio(buf, (void __iomem *)src, c);
0034 if (copy_to_user(dst, buf, c))
0035 return -EFAULT;
0036 count -= c;
0037 dst += c;
0038 src += c;
0039 }
0040 return 0;
0041 #endif
0042 }
0043 EXPORT_SYMBOL(copy_to_user_fromio);
0044
0045
0046
0047
0048
0049
0050
0051
0052
0053
0054
0055 int copy_from_user_toio(volatile void __iomem *dst, const void __user *src, size_t count)
0056 {
0057 #if defined(__i386__) || defined(CONFIG_SPARC32)
0058 return copy_from_user((void __force *)dst, src, count) ? -EFAULT : 0;
0059 #else
0060 char buf[256];
0061 while (count) {
0062 size_t c = count;
0063 if (c > sizeof(buf))
0064 c = sizeof(buf);
0065 if (copy_from_user(buf, src, c))
0066 return -EFAULT;
0067 memcpy_toio(dst, buf, c);
0068 count -= c;
0069 dst += c;
0070 src += c;
0071 }
0072 return 0;
0073 #endif
0074 }
0075 EXPORT_SYMBOL(copy_from_user_toio);