1 // SPDX-License-Identifier: GPL-2.0-or-later
3 * Copyright (c) by Jaroslav Kysela <perex@perex.cz>
5 * Misc memory accessors
8 #include <linux/export.h>
10 #include <linux/uaccess.h>
11 #include <sound/core.h>
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
19 * Copies the data from mmio-space to user-space.
21 * Return: Zero if successful, or non-zero on failure.
23 int copy_to_user_fromio(void __user
*dst
, const volatile void __iomem
*src
, size_t count
)
25 #if defined(__i386__) || defined(CONFIG_SPARC32)
26 return copy_to_user(dst
, (const void __force
*)src
, count
) ? -EFAULT
: 0;
33 memcpy_fromio(buf
, (void __iomem
*)src
, c
);
34 if (copy_to_user(dst
, buf
, c
))
43 EXPORT_SYMBOL(copy_to_user_fromio
);
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
51 * Copies the data from user-space to mmio-space.
53 * Return: Zero if successful, or non-zero on failure.
55 int copy_from_user_toio(volatile void __iomem
*dst
, const void __user
*src
, size_t count
)
57 #if defined(__i386__) || defined(CONFIG_SPARC32)
58 return copy_from_user((void __force
*)dst
, src
, count
) ? -EFAULT
: 0;
65 if (copy_from_user(buf
, src
, c
))
67 memcpy_toio(dst
, buf
, c
);
75 EXPORT_SYMBOL(copy_from_user_toio
);