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

ALSA: es1938: Convert to generic PCM copy ops

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

Note that copy_from/to_iter() returns the copied bytes, hence the
error condition is adjusted accordingly.

Link: https://lore.kernel.org/r/20230815190136.8987-8-tiwai@suse.de
Signed-off-by: Takashi Iwai <tiwai@suse.de>

+5 -25
+5 -25
sound/pci/es1938.c
··· 824 824 825 825 static int snd_es1938_capture_copy(struct snd_pcm_substream *substream, 826 826 int channel, unsigned long pos, 827 - void __user *dst, unsigned long count) 827 + struct iov_iter *dst, unsigned long count) 828 828 { 829 829 struct snd_pcm_runtime *runtime = substream->runtime; 830 830 struct es1938 *chip = snd_pcm_substream_chip(substream); ··· 832 832 if (snd_BUG_ON(pos + count > chip->dma1_size)) 833 833 return -EINVAL; 834 834 if (pos + count < chip->dma1_size) { 835 - if (copy_to_user(dst, runtime->dma_area + pos + 1, count)) 835 + if (copy_to_iter(runtime->dma_area + pos + 1, count, dst) != count) 836 836 return -EFAULT; 837 837 } else { 838 - if (copy_to_user(dst, runtime->dma_area + pos + 1, count - 1)) 838 + if (copy_to_iter(runtime->dma_area + pos + 1, count - 1, dst) != count - 1) 839 839 return -EFAULT; 840 - if (put_user(runtime->dma_area[0], 841 - ((unsigned char __user *)dst) + count - 1)) 840 + if (copy_to_iter(runtime->dma_area, 1, dst) != 1) 842 841 return -EFAULT; 843 - } 844 - return 0; 845 - } 846 - 847 - static int snd_es1938_capture_copy_kernel(struct snd_pcm_substream *substream, 848 - int channel, unsigned long pos, 849 - void *dst, unsigned long count) 850 - { 851 - struct snd_pcm_runtime *runtime = substream->runtime; 852 - struct es1938 *chip = snd_pcm_substream_chip(substream); 853 - 854 - if (snd_BUG_ON(pos + count > chip->dma1_size)) 855 - return -EINVAL; 856 - if (pos + count < chip->dma1_size) { 857 - memcpy(dst, runtime->dma_area + pos + 1, count); 858 - } else { 859 - memcpy(dst, runtime->dma_area + pos + 1, count - 1); 860 - runtime->dma_area[0] = *((unsigned char *)dst + count - 1); 861 842 } 862 843 return 0; 863 844 } ··· 968 987 .prepare = snd_es1938_capture_prepare, 969 988 .trigger = snd_es1938_capture_trigger, 970 989 .pointer = snd_es1938_capture_pointer, 971 - .copy_user = snd_es1938_capture_copy, 972 - .copy_kernel = snd_es1938_capture_copy_kernel, 990 + .copy = snd_es1938_capture_copy, 973 991 }; 974 992 975 993 static int snd_es1938_new_pcm(struct es1938 *chip, int device)