2 * Copyright (c) by Jaroslav Kysela <perex@perex.cz>
4 * Misc memory accessors
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.
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.
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
23 #include <linux/export.h>
25 #include <linux/uaccess.h>
26 #include <sound/core.h>
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
34 * Copies the data from mmio-space to user-space.
36 * Return: Zero if successful, or non-zero on failure.
38 int copy_to_user_fromio(void __user
*dst
, const volatile void __iomem
*src
, size_t count
)
40 #if defined(__i386__) || defined(CONFIG_SPARC32)
41 return copy_to_user(dst
, (const void __force
*)src
, count
) ? -EFAULT
: 0;
48 memcpy_fromio(buf
, (void __iomem
*)src
, c
);
49 if (copy_to_user(dst
, buf
, c
))
58 EXPORT_SYMBOL(copy_to_user_fromio
);
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
66 * Copies the data from user-space to mmio-space.
68 * Return: Zero if successful, or non-zero on failure.
70 int copy_from_user_toio(volatile void __iomem
*dst
, const void __user
*src
, size_t count
)
72 #if defined(__i386__) || defined(CONFIG_SPARC32)
73 return copy_from_user((void __force
*)dst
, src
, count
) ? -EFAULT
: 0;
80 if (copy_from_user(buf
, src
, c
))
82 memcpy_toio(dst
, buf
, c
);
90 EXPORT_SYMBOL(copy_from_user_toio
);