ALSA: pcm: Remove set_fs() in PCM core code
PATCH 1/1 ALSA: pcm: Remove set_fs() in PCM core code
PCM core code has a few usages of set_fs(), mostly for two codepaths:
- The DELAY ioctl call from pcm_compat.c
- The ioctl wrapper in kernel context for PCM OSS and other
This patch removes the set_fs() usage in these places by a slight code refactoring. For the former point, snd_pcm_delay() is changed to return the value directly instead of putting the value to the given address. Each caller stores the result in an appropriate manner.
For fixing the latter, snd_pcm_lib_kernel_ioctl() is changed to call the functions directly as well. For achieving it, now the function accepts only the limited set of ioctls that have been used, so far. The primary user of this function is the PCM OSS layer, and the only other user is USB UAC1 gadget driver. Both drivers don't need the full set of ioctls.
--- sound/core/pcm_compat.c | 12 ++---- sound/core/pcm_native.c | 102 ++++++++++++++++++++++++++++++------------------ 2 files changed, 67 insertions(+), 47 deletions(-)
sound/core/pcm_compat.c +4 -8
@@ -27,17 +27,13 @@ static int snd_pcm_ioctl_delay_compat(struct snd_pcm_substream *substream, s32 __user *src) {snd_pcm_sframes_t delay; -mm_segment_t fs; -int err; - fs =snd_enter_user (); - err =snd_pcm_delay (substream, &delay); -snd_leave_user (fs); -if (err <0 ) -return err; + delay =snd_pcm_delay (substream); +if (delay <0 ) +return delay;if (put_user (delay, src))return -EFAULT ; -return err; +return 0 ; } static int snd_pcm_ioctl_rewind_compat(struct snd_pcm_substream *substream,
sound/core/pcm_native.c +63 -39
157 lines not on this page · raw message
Signature · 1 line
2.13.0
Quoted 9 lines · Takashi Iwai
PCM core code has a few usages of
set_fs(), mostly for two codepaths:
- The DELAY ioctl call frompcm_compat.c
- The ioctl wrapper in kernel context for PCM OSS and otherThis patch removes the
set_fs()usage in these places by a slight code refactoring. For the former point,snd_pcm_delay()is changed to return the value directly instead of putting the value to the given address. Each caller stores the result in an appropriate manner.
Quoted 8 lines
For fixing the latter,
snd_pcm_lib_kernel_ioctl()is changed to call the functions directly as well. For achieving it, now the function accepts only the limited set of ioctls that have been used, so far. The primary user of this function is the PCM OSS layer, and the only other user is USB UAC1 gadget driver. Both drivers don't need the full set of ioctls.Signed-off-by Takashi Iwai <[email protected]>
Regards
Takashi Sakamoto