ALSA: nm256: Convert to generic PCM copy ops
authorTakashi Iwai <tiwai@suse.de>
Tue, 15 Aug 2023 19:01:20 +0000 (21:01 +0200)
committerTakashi Iwai <tiwai@suse.de>
Fri, 18 Aug 2023 10:18:21 +0000 (12:18 +0200)
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.

Link: https://lore.kernel.org/r/20230815190136.8987-10-tiwai@suse.de
Signed-off-by: Takashi Iwai <tiwai@suse.de>
sound/pci/nm256/nm256.c

index f99a1e9..34f9082 100644 (file)
@@ -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,
 };