Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

ALSA: nm256: Convert to generic PCM copy ops

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>

+6 -36
+6 -36
sound/pci/nm256/nm256.c
··· 691 691 static int 692 692 snd_nm256_playback_copy(struct snd_pcm_substream *substream, 693 693 int channel, unsigned long pos, 694 - void __user *src, unsigned long count) 694 + struct iov_iter *src, unsigned long count) 695 695 { 696 696 struct snd_pcm_runtime *runtime = substream->runtime; 697 697 struct nm256_stream *s = runtime->private_data; 698 698 699 - if (copy_from_user_toio(s->bufptr + pos, src, count)) 700 - return -EFAULT; 701 - return 0; 702 - } 703 - 704 - static int 705 - snd_nm256_playback_copy_kernel(struct snd_pcm_substream *substream, 706 - int channel, unsigned long pos, 707 - void *src, unsigned long count) 708 - { 709 - struct snd_pcm_runtime *runtime = substream->runtime; 710 - struct nm256_stream *s = runtime->private_data; 711 - 712 - memcpy_toio(s->bufptr + pos, src, count); 713 - return 0; 699 + return copy_from_iter_toio(s->bufptr + pos, src, count); 714 700 } 715 701 716 702 /* ··· 705 719 static int 706 720 snd_nm256_capture_copy(struct snd_pcm_substream *substream, 707 721 int channel, unsigned long pos, 708 - void __user *dst, unsigned long count) 722 + struct iov_iter *dst, unsigned long count) 709 723 { 710 724 struct snd_pcm_runtime *runtime = substream->runtime; 711 725 struct nm256_stream *s = runtime->private_data; 712 726 713 - if (copy_to_user_fromio(dst, s->bufptr + pos, count)) 714 - return -EFAULT; 715 - return 0; 716 - } 717 - 718 - static int 719 - snd_nm256_capture_copy_kernel(struct snd_pcm_substream *substream, 720 - int channel, unsigned long pos, 721 - void *dst, unsigned long count) 722 - { 723 - struct snd_pcm_runtime *runtime = substream->runtime; 724 - struct nm256_stream *s = runtime->private_data; 725 - 726 - memcpy_fromio(dst, s->bufptr + pos, count); 727 - return 0; 727 + return copy_to_iter_fromio(dst, s->bufptr + pos, count); 728 728 } 729 729 730 730 #endif /* !__i386__ */ ··· 881 909 .trigger = snd_nm256_playback_trigger, 882 910 .pointer = snd_nm256_playback_pointer, 883 911 #ifndef __i386__ 884 - .copy_user = snd_nm256_playback_copy, 885 - .copy_kernel = snd_nm256_playback_copy_kernel, 912 + .copy = snd_nm256_playback_copy, 886 913 .fill_silence = snd_nm256_playback_silence, 887 914 #endif 888 915 .mmap = snd_pcm_lib_mmap_iomem, ··· 895 924 .trigger = snd_nm256_capture_trigger, 896 925 .pointer = snd_nm256_capture_pointer, 897 926 #ifndef __i386__ 898 - .copy_user = snd_nm256_capture_copy, 899 - .copy_kernel = snd_nm256_capture_copy_kernel, 927 + .copy = snd_nm256_capture_copy, 900 928 #endif 901 929 .mmap = snd_pcm_lib_mmap_iomem, 902 930 };