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

ALSA: gus: Convert to generic PCM copy ops

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

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-6-tiwai@suse.de
Signed-off-by: Takashi Iwai <tiwai@suse.de>

+3 -20
+3 -20
sound/isa/gus/gus_pcm.c
··· 369 369 370 370 static int snd_gf1_pcm_playback_copy(struct snd_pcm_substream *substream, 371 371 int voice, unsigned long pos, 372 - void __user *src, unsigned long count) 372 + struct iov_iter *src, unsigned long count) 373 373 { 374 374 struct snd_pcm_runtime *runtime = substream->runtime; 375 375 struct gus_pcm_private *pcmp = runtime->private_data; ··· 379 379 bpos = get_bpos(pcmp, voice, pos, len); 380 380 if (bpos < 0) 381 381 return pos; 382 - if (copy_from_user(runtime->dma_area + bpos, src, len)) 382 + if (copy_from_iter(runtime->dma_area + bpos, len, src) != len) 383 383 return -EFAULT; 384 - return playback_copy_ack(substream, bpos, len); 385 - } 386 - 387 - static int snd_gf1_pcm_playback_copy_kernel(struct snd_pcm_substream *substream, 388 - int voice, unsigned long pos, 389 - void *src, unsigned long count) 390 - { 391 - struct snd_pcm_runtime *runtime = substream->runtime; 392 - struct gus_pcm_private *pcmp = runtime->private_data; 393 - unsigned int len = count; 394 - int bpos; 395 - 396 - bpos = get_bpos(pcmp, voice, pos, len); 397 - if (bpos < 0) 398 - return pos; 399 - memcpy(runtime->dma_area + bpos, src, len); 400 384 return playback_copy_ack(substream, bpos, len); 401 385 } 402 386 ··· 814 830 .prepare = snd_gf1_pcm_playback_prepare, 815 831 .trigger = snd_gf1_pcm_playback_trigger, 816 832 .pointer = snd_gf1_pcm_playback_pointer, 817 - .copy_user = snd_gf1_pcm_playback_copy, 818 - .copy_kernel = snd_gf1_pcm_playback_copy_kernel, 833 + .copy = snd_gf1_pcm_playback_copy, 819 834 .fill_silence = snd_gf1_pcm_playback_silence, 820 835 }; 821 836