[PATCH 09/25] ALSA: nm256: Convert to generic PCM copy ops

From: Takashi Iwai
Date: Mon Aug 14 2023 - 07:57:22 EST


This patch converts the nm256 driver code to use the new unified PCM
copy callback. It's a straightforward conversion from *_user() to
*_iter() variants.

Signed-off-by: Takashi Iwai <tiwai@xxxxxxx>
---
sound/pci/nm256/nm256.c | 42 ++++++-----------------------------------
1 file changed, 6 insertions(+), 36 deletions(-)

diff --git a/sound/pci/nm256/nm256.c b/sound/pci/nm256/nm256.c
index f99a1e96e923..34f90829e656 100644
--- a/sound/pci/nm256/nm256.c
+++ b/sound/pci/nm256/nm256.c
@@ -691,26 +691,12 @@ snd_nm256_playback_silence(struct snd_pcm_substream *substream,
static int
snd_nm256_playback_copy(struct snd_pcm_substream *substream,
int channel, unsigned long pos,
- void __user *src, unsigned long count)
+ struct iov_iter *src, unsigned long count)
{
struct snd_pcm_runtime *runtime = substream->runtime;
struct nm256_stream *s = runtime->private_data;

- if (copy_from_user_toio(s->bufptr + pos, src, count))
- return -EFAULT;
- return 0;
-}
-
-static int
-snd_nm256_playback_copy_kernel(struct snd_pcm_substream *substream,
- int channel, unsigned long pos,
- void *src, unsigned long count)
-{
- struct snd_pcm_runtime *runtime = substream->runtime;
- struct nm256_stream *s = runtime->private_data;
-
- memcpy_toio(s->bufptr + pos, src, count);
- return 0;
+ return copy_from_iter_toio(s->bufptr + pos, src, count);
}

/*
@@ -719,26 +705,12 @@ snd_nm256_playback_copy_kernel(struct snd_pcm_substream *substream,
static int
snd_nm256_capture_copy(struct snd_pcm_substream *substream,
int channel, unsigned long pos,
- void __user *dst, unsigned long count)
+ struct iov_iter *dst, unsigned long count)
{
struct snd_pcm_runtime *runtime = substream->runtime;
struct nm256_stream *s = runtime->private_data;

- if (copy_to_user_fromio(dst, s->bufptr + pos, count))
- return -EFAULT;
- return 0;
-}
-
-static int
-snd_nm256_capture_copy_kernel(struct snd_pcm_substream *substream,
- int channel, unsigned long pos,
- void *dst, unsigned long count)
-{
- struct snd_pcm_runtime *runtime = substream->runtime;
- struct nm256_stream *s = runtime->private_data;
-
- memcpy_fromio(dst, s->bufptr + pos, count);
- return 0;
+ return copy_to_iter_fromio(dst, s->bufptr + pos, count);
}

#endif /* !__i386__ */
@@ -909,8 +881,7 @@ static const struct snd_pcm_ops snd_nm256_playback_ops = {
.trigger = snd_nm256_playback_trigger,
.pointer = snd_nm256_playback_pointer,
#ifndef __i386__
- .copy_user = snd_nm256_playback_copy,
- .copy_kernel = snd_nm256_playback_copy_kernel,
+ .copy = snd_nm256_playback_copy,
.fill_silence = snd_nm256_playback_silence,
#endif
.mmap = snd_pcm_lib_mmap_iomem,
@@ -924,8 +895,7 @@ static const struct snd_pcm_ops snd_nm256_capture_ops = {
.trigger = snd_nm256_capture_trigger,
.pointer = snd_nm256_capture_pointer,
#ifndef __i386__
- .copy_user = snd_nm256_capture_copy,
- .copy_kernel = snd_nm256_capture_copy_kernel,
+ .copy = snd_nm256_capture_copy,
#endif
.mmap = snd_pcm_lib_mmap_iomem,
};
--
2.35.3