Add two more helpers for copying memory between sockptr and iomem, which will be used by the new PCM copy ops in a few drivers. It's just bridging to the existing helpers.
Signed-off-by: Takashi Iwai tiwai@suse.de --- include/sound/pcm.h | 4 ++++ sound/core/memory.c | 39 +++++++++++++++++++++++++++++++++++++++ 2 files changed, 43 insertions(+)
diff --git a/include/sound/pcm.h b/include/sound/pcm.h index 04b935200d0e..9b7054f0cea0 100644 --- a/include/sound/pcm.h +++ b/include/sound/pcm.h @@ -1559,6 +1559,10 @@ static inline u64 pcm_format_to_bits(snd_pcm_format_t pcm_format) #define pcm_dbg(pcm, fmt, args...) \ dev_dbg((pcm)->card->dev, fmt, ##args)
+/* helpers for copying between sockptr and iomem */ +int copy_to_sockptr_fromio(sockptr_t dst, const void __iomem *src, size_t count); +int copy_from_sockptr_toio(void __iomem *dst, sockptr_t src, size_t count); + struct snd_pcm_status64 { snd_pcm_state_t state; /* stream state */ u8 rsvd[4]; diff --git a/sound/core/memory.c b/sound/core/memory.c index 5d894dc32f7d..ff4a9e0064a2 100644 --- a/sound/core/memory.c +++ b/sound/core/memory.c @@ -9,6 +9,7 @@ #include <linux/io.h> #include <linux/uaccess.h> #include <sound/core.h> +#include <sound/pcm.h>
/** * copy_to_user_fromio - copy data from mmio-space to user-space @@ -73,3 +74,41 @@ int copy_from_user_toio(volatile void __iomem *dst, const void __user *src, size #endif } EXPORT_SYMBOL(copy_from_user_toio); + +/** + * copy_to_sockptr_fromio - copy data from mmio-space to sockptr + * @dst: the destination pointer + * @src: the source pointer on mmio + * @count: the data size to copy in bytes + * + * Copies the data from mmio-space to the generic pointer address + * + * Return: Zero if successful, or -EFAULT on failure + */ +int copy_to_sockptr_fromio(sockptr_t dst, const void __iomem *src, size_t count) +{ + if (!sockptr_is_kernel(dst)) + return copy_to_user_fromio(dst.user, src, count); + memcpy_fromio(dst.kernel, src, count); + return 0; +} +EXPORT_SYMBOL(copy_to_sockptr_fromio); + +/** + * copy_from_sockptr_toio - copy data from sockptr to mmio-space + * @dst: the destination pointer on mmio-space + * @src: the source pointer + * @count: the data size to copy in bytes + * + * Copies the data from the generic pointer address to mmio-space. + * + * Return: Zero if successful, or -EFAULT on failure + */ +int copy_from_sockptr_toio(void __iomem *dst, sockptr_t src, size_t count) +{ + if (!sockptr_is_kernel(src)) + return copy_from_user_toio(dst, src.user, count); + memcpy_toio(dst, src.kernel, count); + return 0; +} +EXPORT_SYMBOL(copy_from_sockptr_toio);