]> git.karo-electronics.de Git - karo-tx-linux.git/blobdiff - sound/core/oss/pcm_oss.c
ALSA: pcm: Kill set_fs() in PCM OSS layer
[karo-tx-linux.git] / sound / core / oss / pcm_oss.c
index 36baf962f9b081649c07902a16abfee6932d79ad..2d6a825cfe88c151382ec6985b3ca5aff5ada417 100644 (file)
@@ -67,18 +67,6 @@ static int snd_pcm_oss_get_rate(struct snd_pcm_oss_file *pcm_oss_file);
 static int snd_pcm_oss_get_channels(struct snd_pcm_oss_file *pcm_oss_file);
 static int snd_pcm_oss_get_format(struct snd_pcm_oss_file *pcm_oss_file);
 
-static inline mm_segment_t snd_enter_user(void)
-{
-       mm_segment_t fs = get_fs();
-       set_fs(get_ds());
-       return fs;
-}
-
-static inline void snd_leave_user(mm_segment_t fs)
-{
-       set_fs(fs);
-}
-
 /*
  * helper functions to process hw_params
  */
@@ -799,7 +787,7 @@ static int snd_pcm_oss_period_size(struct snd_pcm_substream *substream,
 static int choose_rate(struct snd_pcm_substream *substream,
                       struct snd_pcm_hw_params *params, unsigned int best_rate)
 {
-       struct snd_interval *it;
+       const struct snd_interval *it;
        struct snd_pcm_hw_params *save;
        unsigned int rate, prev;
 
@@ -807,7 +795,7 @@ static int choose_rate(struct snd_pcm_substream *substream,
        if (save == NULL)
                return -ENOMEM;
        *save = *params;
-       it = hw_param_interval(save, SNDRV_PCM_HW_PARAM_RATE);
+       it = hw_param_interval_c(save, SNDRV_PCM_HW_PARAM_RATE);
 
        /* try multiples of the best rate */
        rate = best_rate;
@@ -848,7 +836,7 @@ static int snd_pcm_oss_change_params(struct snd_pcm_substream *substream,
        int direct;
        snd_pcm_format_t format, sformat;
        int n;
-       struct snd_mask sformat_mask;
+       const struct snd_mask *sformat_mask;
        struct snd_mask mask;
 
        if (trylock) {
@@ -891,18 +879,18 @@ static int snd_pcm_oss_change_params(struct snd_pcm_substream *substream,
 
        format = snd_pcm_oss_format_from(runtime->oss.format);
 
-       sformat_mask = *hw_param_mask(sparams, SNDRV_PCM_HW_PARAM_FORMAT);
+       sformat_mask = hw_param_mask_c(sparams, SNDRV_PCM_HW_PARAM_FORMAT);
        if (direct)
                sformat = format;
        else
-               sformat = snd_pcm_plug_slave_format(format, &sformat_mask);
+               sformat = snd_pcm_plug_slave_format(format, sformat_mask);
 
        if ((__force int)sformat < 0 ||
-           !snd_mask_test(&sformat_mask, (__force int)sformat)) {
+           !snd_mask_test(sformat_mask, (__force int)sformat)) {
                for (sformat = (__force snd_pcm_format_t)0;
                     (__force int)sformat <= (__force int)SNDRV_PCM_FORMAT_LAST;
                     sformat = (__force snd_pcm_format_t)((__force int)sformat + 1)) {
-                       if (snd_mask_test(&sformat_mask, (__force int)sformat) &&
+                       if (snd_mask_test(sformat_mask, (__force int)sformat) &&
                            snd_pcm_oss_format_to(sformat) >= 0)
                                break;
                }
@@ -1191,14 +1179,8 @@ snd_pcm_sframes_t snd_pcm_oss_write3(struct snd_pcm_substream *substream, const
                        if (ret < 0)
                                break;
                }
-               if (in_kernel) {
-                       mm_segment_t fs;
-                       fs = snd_enter_user();
-                       ret = snd_pcm_lib_write(substream, (void __force __user *)ptr, frames);
-                       snd_leave_user(fs);
-               } else {
-                       ret = snd_pcm_lib_write(substream, (void __force __user *)ptr, frames);
-               }
+               ret = __snd_pcm_lib_xfer(substream, (void *)ptr, true,
+                                        frames, in_kernel);
                if (ret != -EPIPE && ret != -ESTRPIPE)
                        break;
                /* test, if we can't store new data, because the stream */
@@ -1234,14 +1216,8 @@ snd_pcm_sframes_t snd_pcm_oss_read3(struct snd_pcm_substream *substream, char *p
                ret = snd_pcm_oss_capture_position_fixup(substream, &delay);
                if (ret < 0)
                        break;
-               if (in_kernel) {
-                       mm_segment_t fs;
-                       fs = snd_enter_user();
-                       ret = snd_pcm_lib_read(substream, (void __force __user *)ptr, frames);
-                       snd_leave_user(fs);
-               } else {
-                       ret = snd_pcm_lib_read(substream, (void __force __user *)ptr, frames);
-               }
+               ret = __snd_pcm_lib_xfer(substream, (void *)ptr, true,
+                                        frames, in_kernel);
                if (ret == -EPIPE) {
                        if (runtime->status->state == SNDRV_PCM_STATE_DRAINING) {
                                ret = snd_pcm_kernel_ioctl(substream, SNDRV_PCM_IOCTL_DROP, NULL);
@@ -1273,14 +1249,8 @@ snd_pcm_sframes_t snd_pcm_oss_writev3(struct snd_pcm_substream *substream, void
                        if (ret < 0)
                                break;
                }
-               if (in_kernel) {
-                       mm_segment_t fs;
-                       fs = snd_enter_user();
-                       ret = snd_pcm_lib_writev(substream, (void __user **)bufs, frames);
-                       snd_leave_user(fs);
-               } else {
-                       ret = snd_pcm_lib_writev(substream, (void __user **)bufs, frames);
-               }
+               ret = __snd_pcm_lib_xfer(substream, bufs, false, frames,
+                                        in_kernel);
                if (ret != -EPIPE && ret != -ESTRPIPE)
                        break;
 
@@ -1313,14 +1283,8 @@ snd_pcm_sframes_t snd_pcm_oss_readv3(struct snd_pcm_substream *substream, void *
                        if (ret < 0)
                                break;
                }
-               if (in_kernel) {
-                       mm_segment_t fs;
-                       fs = snd_enter_user();
-                       ret = snd_pcm_lib_readv(substream, (void __user **)bufs, frames);
-                       snd_leave_user(fs);
-               } else {
-                       ret = snd_pcm_lib_readv(substream, (void __user **)bufs, frames);
-               }
+               ret = __snd_pcm_lib_xfer(substream, bufs, false, frames,
+                                        in_kernel);
                if (ret != -EPIPE && ret != -ESTRPIPE)
                        break;
        }
@@ -1650,27 +1614,10 @@ static int snd_pcm_oss_sync(struct snd_pcm_oss_file *pcm_oss_file)
                size = runtime->control->appl_ptr % runtime->period_size;
                if (size > 0) {
                        size = runtime->period_size - size;
-                       if (runtime->access == SNDRV_PCM_ACCESS_RW_INTERLEAVED) {
-                               size = (runtime->frame_bits * size) / 8;
-                               while (size > 0) {
-                                       mm_segment_t fs;
-                                       size_t size1 = size < runtime->oss.period_bytes ? size : runtime->oss.period_bytes;
-                                       size -= size1;
-                                       size1 *= 8;
-                                       size1 /= runtime->sample_bits;
-                                       snd_pcm_format_set_silence(runtime->format,
-                                                                  runtime->oss.buffer,
-                                                                  size1);
-                                       size1 /= runtime->channels; /* frames */
-                                       fs = snd_enter_user();
-                                       snd_pcm_lib_write(substream, (void __force __user *)runtime->oss.buffer, size1);
-                                       snd_leave_user(fs);
-                               }
-                       } else if (runtime->access == SNDRV_PCM_ACCESS_RW_NONINTERLEAVED) {
-                               void __user *buffers[runtime->channels];
-                               memset(buffers, 0, runtime->channels * sizeof(void *));
-                               snd_pcm_lib_writev(substream, buffers, size);
-                       }
+                       if (runtime->access == SNDRV_PCM_ACCESS_RW_INTERLEAVED)
+                               snd_pcm_lib_write(substream, NULL, size);
+                       else if (runtime->access == SNDRV_PCM_ACCESS_RW_NONINTERLEAVED)
+                               snd_pcm_lib_writev(substream, NULL, size);
                }
                mutex_unlock(&runtime->oss.params_lock);
                /*
@@ -1780,7 +1727,7 @@ static int snd_pcm_oss_get_formats(struct snd_pcm_oss_file *pcm_oss_file)
        int direct;
        struct snd_pcm_hw_params *params;
        unsigned int formats = 0;
-       struct snd_mask format_mask;
+       const struct snd_mask *format_mask;
        int fmt;
 
        if ((err = snd_pcm_oss_get_active_substream(pcm_oss_file, &substream)) < 0)
@@ -1802,12 +1749,12 @@ static int snd_pcm_oss_get_formats(struct snd_pcm_oss_file *pcm_oss_file)
                return -ENOMEM;
        _snd_pcm_hw_params_any(params);
        err = snd_pcm_hw_refine(substream, params);
-       format_mask = *hw_param_mask(params, SNDRV_PCM_HW_PARAM_FORMAT); 
+       format_mask = hw_param_mask_c(params, SNDRV_PCM_HW_PARAM_FORMAT);
        kfree(params);
        if (err < 0)
                return err;
        for (fmt = 0; fmt < 32; ++fmt) {
-               if (snd_mask_test(&format_mask, fmt)) {
+               if (snd_mask_test(format_mask, fmt)) {
                        int f = snd_pcm_oss_format_to(fmt);
                        if (f >= 0)
                                formats |= f;