~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

TOMOYO Linux Cross Reference
Linux/sound/core/memory.c

Version: ~ [ linux-6.0-rc1 ] ~ [ linux-5.19.1 ] ~ [ linux-5.18.17 ] ~ [ linux-5.17.15 ] ~ [ linux-5.16.20 ] ~ [ linux-5.15.60 ] ~ [ linux-5.14.21 ] ~ [ linux-5.13.19 ] ~ [ linux-5.12.19 ] ~ [ linux-5.11.22 ] ~ [ linux-5.10.136 ] ~ [ linux-5.9.16 ] ~ [ linux-5.8.18 ] ~ [ linux-5.7.19 ] ~ [ linux-5.6.19 ] ~ [ linux-5.5.19 ] ~ [ linux-5.4.210 ] ~ [ linux-5.3.18 ] ~ [ linux-5.2.21 ] ~ [ linux-5.1.21 ] ~ [ linux-5.0.21 ] ~ [ linux-4.20.17 ] ~ [ linux-4.19.255 ] ~ [ linux-4.18.20 ] ~ [ linux-4.17.19 ] ~ [ linux-4.16.18 ] ~ [ linux-4.15.18 ] ~ [ linux-4.14.290 ] ~ [ linux-4.13.16 ] ~ [ linux-4.12.14 ] ~ [ linux-4.11.12 ] ~ [ linux-4.10.17 ] ~ [ linux-4.9.325 ] ~ [ linux-4.8.17 ] ~ [ linux-4.7.10 ] ~ [ linux-4.6.7 ] ~ [ linux-4.5.7 ] ~ [ linux-4.4.302 ] ~ [ linux-4.3.6 ] ~ [ linux-4.2.8 ] ~ [ linux-4.1.52 ] ~ [ linux-4.0.9 ] ~ [ linux-3.10.108 ] ~ [ linux-2.6.32.71 ] ~ [ linux-2.6.0 ] ~ [ linux-2.4.37.11 ] ~ [ unix-v6-master ] ~ [ ccs-tools-1.8.9 ] ~ [ policy-sample ] ~
Architecture: ~ [ i386 ] ~ [ alpha ] ~ [ m68k ] ~ [ mips ] ~ [ ppc ] ~ [ sparc ] ~ [ sparc64 ] ~

  1 // SPDX-License-Identifier: GPL-2.0-or-later
  2 /*
  3  *  Copyright (c) by Jaroslav Kysela <perex@perex.cz>
  4  * 
  5  *  Misc memory accessors
  6  */
  7 
  8 #include <linux/export.h>
  9 #include <linux/io.h>
 10 #include <linux/uaccess.h>
 11 #include <sound/core.h>
 12 
 13 /**
 14  * copy_to_user_fromio - copy data from mmio-space to user-space
 15  * @dst: the destination pointer on user-space
 16  * @src: the source pointer on mmio
 17  * @count: the data size to copy in bytes
 18  *
 19  * Copies the data from mmio-space to user-space.
 20  *
 21  * Return: Zero if successful, or non-zero on failure.
 22  */
 23 int copy_to_user_fromio(void __user *dst, const volatile void __iomem *src, size_t count)
 24 {
 25 #if defined(__i386__) || defined(CONFIG_SPARC32)
 26         return copy_to_user(dst, (const void __force*)src, count) ? -EFAULT : 0;
 27 #else
 28         char buf[256];
 29         while (count) {
 30                 size_t c = count;
 31                 if (c > sizeof(buf))
 32                         c = sizeof(buf);
 33                 memcpy_fromio(buf, (void __iomem *)src, c);
 34                 if (copy_to_user(dst, buf, c))
 35                         return -EFAULT;
 36                 count -= c;
 37                 dst += c;
 38                 src += c;
 39         }
 40         return 0;
 41 #endif
 42 }
 43 EXPORT_SYMBOL(copy_to_user_fromio);
 44 
 45 /**
 46  * copy_from_user_toio - copy data from user-space to mmio-space
 47  * @dst: the destination pointer on mmio-space
 48  * @src: the source pointer on user-space
 49  * @count: the data size to copy in bytes
 50  *
 51  * Copies the data from user-space to mmio-space.
 52  *
 53  * Return: Zero if successful, or non-zero on failure.
 54  */
 55 int copy_from_user_toio(volatile void __iomem *dst, const void __user *src, size_t count)
 56 {
 57 #if defined(__i386__) || defined(CONFIG_SPARC32)
 58         return copy_from_user((void __force *)dst, src, count) ? -EFAULT : 0;
 59 #else
 60         char buf[256];
 61         while (count) {
 62                 size_t c = count;
 63                 if (c > sizeof(buf))
 64                         c = sizeof(buf);
 65                 if (copy_from_user(buf, src, c))
 66                         return -EFAULT;
 67                 memcpy_toio(dst, buf, c);
 68                 count -= c;
 69                 dst += c;
 70                 src += c;
 71         }
 72         return 0;
 73 #endif
 74 }
 75 EXPORT_SYMBOL(copy_from_user_toio);
 76 

~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

kernel.org | git.kernel.org | LWN.net | Project Home | Wiki (Japanese) | Wiki (English) | SVN repository | Mail admin

Linux® is a registered trademark of Linus Torvalds in the United States and other countries.
TOMOYO® is a registered trademark of NTT DATA CORPORATION.

osdn.jp