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

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

Version: ~ [ linux-5.15-rc1 ] ~ [ linux-5.14.5 ] ~ [ linux-5.13.18 ] ~ [ linux-5.12.19 ] ~ [ linux-5.11.22 ] ~ [ linux-5.10.66 ] ~ [ linux-5.9.16 ] ~ [ linux-5.8.18 ] ~ [ linux-5.7.19 ] ~ [ linux-5.6.19 ] ~ [ linux-5.5.19 ] ~ [ linux-5.4.147 ] ~ [ linux-5.3.18 ] ~ [ linux-5.2.21 ] ~ [ linux-5.1.21 ] ~ [ linux-5.0.21 ] ~ [ linux-4.20.17 ] ~ [ linux-4.19.206 ] ~ [ linux-4.18.20 ] ~ [ linux-4.17.19 ] ~ [ linux-4.16.18 ] ~ [ linux-4.15.18 ] ~ [ linux-4.14.246 ] ~ [ linux-4.13.16 ] ~ [ linux-4.12.14 ] ~ [ linux-4.11.12 ] ~ [ linux-4.10.17 ] ~ [ linux-4.9.282 ] ~ [ linux-4.8.17 ] ~ [ linux-4.7.10 ] ~ [ linux-4.6.7 ] ~ [ linux-4.5.7 ] ~ [ linux-4.4.283 ] ~ [ linux-4.3.6 ] ~ [ linux-4.2.8 ] ~ [ linux-4.1.52 ] ~ [ linux-4.0.9 ] ~ [ linux-3.18.140 ] ~ [ linux-3.16.85 ] ~ [ linux-3.14.79 ] ~ [ linux-3.12.74 ] ~ [ 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.5 ] ~ [ policy-sample ] ~
Architecture: ~ [ i386 ] ~ [ alpha ] ~ [ m68k ] ~ [ mips ] ~ [ ppc ] ~ [ sparc ] ~ [ sparc64 ] ~

  1 /*
  2  *  Copyright (c) by Jaroslav Kysela <perex@perex.cz>
  3  * 
  4  *  Misc memory accessors
  5  *
  6  *
  7  *   This program is free software; you can redistribute it and/or modify
  8  *   it under the terms of the GNU General Public License as published by
  9  *   the Free Software Foundation; either version 2 of the License, or
 10  *   (at your option) any later version.
 11  *
 12  *   This program is distributed in the hope that it will be useful,
 13  *   but WITHOUT ANY WARRANTY; without even the implied warranty of
 14  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 15  *   GNU General Public License for more details.
 16  *
 17  *   You should have received a copy of the GNU General Public License
 18  *   along with this program; if not, write to the Free Software
 19  *   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
 20  *
 21  */
 22 
 23 #include <linux/export.h>
 24 #include <linux/io.h>
 25 #include <linux/uaccess.h>
 26 #include <sound/core.h>
 27 
 28 /**
 29  * copy_to_user_fromio - copy data from mmio-space to user-space
 30  * @dst: the destination pointer on user-space
 31  * @src: the source pointer on mmio
 32  * @count: the data size to copy in bytes
 33  *
 34  * Copies the data from mmio-space to user-space.
 35  *
 36  * Return: Zero if successful, or non-zero on failure.
 37  */
 38 int copy_to_user_fromio(void __user *dst, const volatile void __iomem *src, size_t count)
 39 {
 40 #if defined(__i386__) || defined(CONFIG_SPARC32)
 41         return copy_to_user(dst, (const void __force*)src, count) ? -EFAULT : 0;
 42 #else
 43         char buf[256];
 44         while (count) {
 45                 size_t c = count;
 46                 if (c > sizeof(buf))
 47                         c = sizeof(buf);
 48                 memcpy_fromio(buf, (void __iomem *)src, c);
 49                 if (copy_to_user(dst, buf, c))
 50                         return -EFAULT;
 51                 count -= c;
 52                 dst += c;
 53                 src += c;
 54         }
 55         return 0;
 56 #endif
 57 }
 58 EXPORT_SYMBOL(copy_to_user_fromio);
 59 
 60 /**
 61  * copy_from_user_toio - copy data from user-space to mmio-space
 62  * @dst: the destination pointer on mmio-space
 63  * @src: the source pointer on user-space
 64  * @count: the data size to copy in bytes
 65  *
 66  * Copies the data from user-space to mmio-space.
 67  *
 68  * Return: Zero if successful, or non-zero on failure.
 69  */
 70 int copy_from_user_toio(volatile void __iomem *dst, const void __user *src, size_t count)
 71 {
 72 #if defined(__i386__) || defined(CONFIG_SPARC32)
 73         return copy_from_user((void __force *)dst, src, count) ? -EFAULT : 0;
 74 #else
 75         char buf[256];
 76         while (count) {
 77                 size_t c = count;
 78                 if (c > sizeof(buf))
 79                         c = sizeof(buf);
 80                 if (copy_from_user(buf, src, c))
 81                         return -EFAULT;
 82                 memcpy_toio(dst, buf, c);
 83                 count -= c;
 84                 dst += c;
 85                 src += c;
 86         }
 87         return 0;
 88 #endif
 89 }
 90 EXPORT_SYMBOL(copy_from_user_toio);
 91 

~ [ 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