/* -- mmap -- */
        volatile struct snd_pcm_mmap_status *status;
        volatile struct snd_pcm_mmap_control *control;
-       atomic_t mmap_count;
 
        /* -- locking / scheduling -- */
        wait_queue_head_t sleep;
        /* -- assigned files -- */
        void *file;
        int ref_count;
+       atomic_t mmap_count;
        unsigned int f_flags;
        void (*pcm_release)(struct snd_pcm_substream *);
 #if defined(CONFIG_SND_PCM_OSS) || defined(CONFIG_SND_PCM_OSS_MODULE)
 static inline void snd_pcm_mmap_data_open(struct vm_area_struct *area)
 {
        struct snd_pcm_substream *substream = (struct snd_pcm_substream *)area->vm_private_data;
-       atomic_inc(&substream->runtime->mmap_count);
+       atomic_inc(&substream->mmap_count);
 }
 
 static inline void snd_pcm_mmap_data_close(struct vm_area_struct *area)
 {
        struct snd_pcm_substream *substream = (struct snd_pcm_substream *)area->vm_private_data;
-       atomic_dec(&substream->runtime->mmap_count);
+       atomic_dec(&substream->mmap_count);
 }
 
 /* mmap for io-memory area */
 
        oss_buffer_size = snd_pcm_plug_client_size(substream,
                                                   snd_pcm_hw_param_value_max(slave_params, SNDRV_PCM_HW_PARAM_BUFFER_SIZE, NULL)) * oss_frame_size;
        oss_buffer_size = 1 << ld2(oss_buffer_size);
-       if (atomic_read(&runtime->mmap_count)) {
+       if (atomic_read(&substream->mmap_count)) {
                if (oss_buffer_size > runtime->oss.mmap_bytes)
                        oss_buffer_size = runtime->oss.mmap_bytes;
        }
                goto failure;
        }
 
-       if (atomic_read(&runtime->mmap_count))
+       if (atomic_read(&substream->mmap_count))
                direct = 1;
        else
                direct = substream->oss.setup.direct;
        _snd_pcm_hw_param_setinteger(sparams, SNDRV_PCM_HW_PARAM_PERIODS);
        _snd_pcm_hw_param_min(sparams, SNDRV_PCM_HW_PARAM_PERIODS, 2, 0);
        snd_mask_none(&mask);
-       if (atomic_read(&runtime->mmap_count))
+       if (atomic_read(&substream->mmap_count))
                snd_mask_set(&mask, SNDRV_PCM_ACCESS_MMAP_INTERLEAVED);
        else {
                snd_mask_set(&mask, SNDRV_PCM_ACCESS_RW_INTERLEAVED);
        } else {
                sw_params->start_threshold = runtime->boundary;
        }
-       if (atomic_read(&runtime->mmap_count) || substream->stream == SNDRV_PCM_STREAM_CAPTURE)
+       if (atomic_read(&substream->mmap_count) ||
+           substream->stream == SNDRV_PCM_STREAM_CAPTURE)
                sw_params->stop_threshold = runtime->boundary;
        else
                sw_params->stop_threshold = runtime->buffer_size;
        sw_params->avail_min = substream->stream == SNDRV_PCM_STREAM_PLAYBACK ?
                1 : runtime->period_size;
        sw_params->xfer_align = 1;
-       if (atomic_read(&runtime->mmap_count) ||
+       if (atomic_read(&substream->mmap_count) ||
            substream->oss.setup.nosilence) {
                sw_params->silence_threshold = 0;
                sw_params->silence_size = 0;
        ssize_t tmp;
        struct snd_pcm_runtime *runtime = substream->runtime;
 
-       if (atomic_read(&runtime->mmap_count))
+       if (atomic_read(&substream->mmap_count))
                return -ENXIO;
 
        if ((tmp = snd_pcm_oss_make_ready(substream)) < 0)
        ssize_t tmp;
        struct snd_pcm_runtime *runtime = substream->runtime;
 
-       if (atomic_read(&runtime->mmap_count))
+       if (atomic_read(&substream->mmap_count))
                return -ENXIO;
 
        if ((tmp = snd_pcm_oss_make_ready(substream)) < 0)
        substream = pcm_oss_file->streams[SNDRV_PCM_STREAM_PLAYBACK];
        if (substream != NULL) {
                runtime = substream->runtime;
-               if (atomic_read(&runtime->mmap_count))
+               if (atomic_read(&substream->mmap_count))
                        goto __direct;
                if ((err = snd_pcm_oss_make_ready(substream)) < 0)
                        return err;
 
        if ((err = snd_pcm_oss_get_active_substream(pcm_oss_file, &substream)) < 0)
                return err;
-       if (atomic_read(&substream->runtime->mmap_count))
+       if (atomic_read(&substream->mmap_count))
                direct = 1;
        else
                direct = substream->oss.setup.direct;
                if (trigger & PCM_ENABLE_OUTPUT) {
                        if (runtime->oss.trigger)
                                goto _skip1;
-                       if (atomic_read(&psubstream->runtime->mmap_count))
+                       if (atomic_read(&psubstream->mmap_count))
                                snd_pcm_oss_simulate_fill(psubstream, runtime->hw_ptr_interrupt);
                        runtime->oss.trigger = 1;
                        runtime->start_threshold = 1;
        if (err < 0)
                return err;
        info.ptr = snd_pcm_oss_bytes(substream, runtime->status->hw_ptr % runtime->buffer_size);
-       if (atomic_read(&runtime->mmap_count)) {
+       if (atomic_read(&substream->mmap_count)) {
                snd_pcm_sframes_t n;
                n = (delay = runtime->hw_ptr_interrupt) - runtime->oss.prev_hw_ptr_interrupt;
                if (n < 0)
 static int snd_pcm_oss_playback_ready(struct snd_pcm_substream *substream)
 {
        struct snd_pcm_runtime *runtime = substream->runtime;
-       if (atomic_read(&runtime->mmap_count))
+       if (atomic_read(&substream->mmap_count))
                return runtime->oss.prev_hw_ptr_interrupt != runtime->hw_ptr_interrupt;
        else
                return snd_pcm_playback_avail(runtime) >= runtime->oss.period_frames;
 static int snd_pcm_oss_capture_ready(struct snd_pcm_substream *substream)
 {
        struct snd_pcm_runtime *runtime = substream->runtime;
-       if (atomic_read(&runtime->mmap_count))
+       if (atomic_read(&substream->mmap_count))
                return runtime->oss.prev_hw_ptr_interrupt != runtime->hw_ptr_interrupt;
        else
                return snd_pcm_capture_avail(runtime) >= runtime->oss.period_frames;
 
 #if defined(CONFIG_SND_PCM_OSS) || defined(CONFIG_SND_PCM_OSS_MODULE)
        if (!substream->oss.oss)
 #endif
-               if (atomic_read(&runtime->mmap_count))
+               if (atomic_read(&substream->mmap_count))
                        return -EBADFD;
 
        params->rmask = ~0U;
                return -EBADFD;
        }
        snd_pcm_stream_unlock_irq(substream);
-       if (atomic_read(&runtime->mmap_count))
+       if (atomic_read(&substream->mmap_count))
                return -EBADFD;
        if (substream->ops->hw_free)
                result = substream->ops->hw_free(substream);
        pcm_file = file->private_data;
        substream = pcm_file->substream;
        snd_assert(substream != NULL, return -ENXIO);
-       snd_assert(!atomic_read(&substream->runtime->mmap_count), );
+       snd_assert(!atomic_read(&substream->mmap_count), );
        pcm = substream->pcm;
        fasync_helper(-1, file, 0, &substream->runtime->fasync);
        mutex_lock(&pcm->open_mutex);
        area->vm_ops = &snd_pcm_vm_ops_data;
        area->vm_private_data = substream;
        area->vm_flags |= VM_RESERVED;
-       atomic_inc(&substream->runtime->mmap_count);
+       atomic_inc(&substream->mmap_count);
        return 0;
 }
 
                                (substream->runtime->dma_addr + offset) >> PAGE_SHIFT,
                                size, area->vm_page_prot))
                return -EAGAIN;
-       atomic_inc(&substream->runtime->mmap_count);
+       atomic_inc(&substream->mmap_count);
        return 0;
 }