ALSA: bebob: change type of substream counter from atomic_t to unsigned int
authorTakashi Sakamoto <o-takashi@sakamocchi.jp>
Sat, 20 Feb 2016 07:18:58 +0000 (16:18 +0900)
committerTakashi Iwai <tiwai@suse.de>
Sat, 20 Feb 2016 14:45:38 +0000 (15:45 +0100)
The counter is incremented/decremented in critical section protected with
mutex. Therefore, no need to use atomic_t.

This commit changes the type to unsigned int.

Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
sound/firewire/bebob/bebob.h
sound/firewire/bebob/bebob_midi.c
sound/firewire/bebob/bebob_pcm.c
sound/firewire/bebob/bebob_stream.c

index c2e885c..4fe58e4 100644 (file)
@@ -95,7 +95,7 @@ struct snd_bebob {
        struct amdtp_stream rx_stream;
        struct cmp_connection out_conn;
        struct cmp_connection in_conn;
-       atomic_t substreams_counter;
+       unsigned int substreams_counter;
 
        struct snd_bebob_stream_formation
                tx_stream_formations[SND_BEBOB_STRM_FMT_ENTRIES];
index cb1b385..868eb0d 100644 (file)
@@ -18,7 +18,7 @@ static int midi_capture_open(struct snd_rawmidi_substream *substream)
                goto end;
 
        mutex_lock(&bebob->mutex);
-       atomic_inc(&bebob->substreams_counter);
+       bebob->substreams_counter++;
        err = snd_bebob_stream_start_duplex(bebob, 0);
        mutex_unlock(&bebob->mutex);
        if (err < 0)
@@ -37,7 +37,7 @@ static int midi_playback_open(struct snd_rawmidi_substream *substream)
                goto end;
 
        mutex_lock(&bebob->mutex);
-       atomic_inc(&bebob->substreams_counter);
+       bebob->substreams_counter++;
        err = snd_bebob_stream_start_duplex(bebob, 0);
        mutex_unlock(&bebob->mutex);
        if (err < 0)
@@ -51,7 +51,7 @@ static int midi_capture_close(struct snd_rawmidi_substream *substream)
        struct snd_bebob *bebob = substream->rmidi->private_data;
 
        mutex_lock(&bebob->mutex);
-       atomic_dec(&bebob->substreams_counter);
+       bebob->substreams_counter--;
        snd_bebob_stream_stop_duplex(bebob);
        mutex_unlock(&bebob->mutex);
 
@@ -64,7 +64,7 @@ static int midi_playback_close(struct snd_rawmidi_substream *substream)
        struct snd_bebob *bebob = substream->rmidi->private_data;
 
        mutex_lock(&bebob->mutex);
-       atomic_dec(&bebob->substreams_counter);
+       bebob->substreams_counter--;
        snd_bebob_stream_stop_duplex(bebob);
        mutex_unlock(&bebob->mutex);
 
index 2053d31..5d7b934 100644 (file)
@@ -220,7 +220,7 @@ pcm_capture_hw_params(struct snd_pcm_substream *substream,
 
        if (substream->runtime->status->state == SNDRV_PCM_STATE_OPEN) {
                mutex_lock(&bebob->mutex);
-               atomic_inc(&bebob->substreams_counter);
+               bebob->substreams_counter++;
                mutex_unlock(&bebob->mutex);
        }
 
@@ -242,7 +242,7 @@ pcm_playback_hw_params(struct snd_pcm_substream *substream,
 
        if (substream->runtime->status->state == SNDRV_PCM_STATE_OPEN) {
                mutex_lock(&bebob->mutex);
-               atomic_inc(&bebob->substreams_counter);
+               bebob->substreams_counter++;
                mutex_unlock(&bebob->mutex);
        }
 
@@ -258,7 +258,7 @@ pcm_capture_hw_free(struct snd_pcm_substream *substream)
 
        if (substream->runtime->status->state != SNDRV_PCM_STATE_OPEN) {
                mutex_lock(&bebob->mutex);
-               atomic_dec(&bebob->substreams_counter);
+               bebob->substreams_counter--;
                mutex_unlock(&bebob->mutex);
        }
 
@@ -273,7 +273,7 @@ pcm_playback_hw_free(struct snd_pcm_substream *substream)
 
        if (substream->runtime->status->state != SNDRV_PCM_STATE_OPEN) {
                mutex_lock(&bebob->mutex);
-               atomic_dec(&bebob->substreams_counter);
+               bebob->substreams_counter--;
                mutex_unlock(&bebob->mutex);
        }
 
index 6809913..8c68745 100644 (file)
@@ -590,7 +590,7 @@ int snd_bebob_stream_start_duplex(struct snd_bebob *bebob, unsigned int rate)
        int err = 0;
 
        /* Need no substreams */
-       if (atomic_read(&bebob->substreams_counter) == 0)
+       if (bebob->substreams_counter == 0)
                goto end;
 
        err = get_sync_mode(bebob, &sync_mode);
@@ -735,7 +735,7 @@ void snd_bebob_stream_stop_duplex(struct snd_bebob *bebob)
                master = &bebob->tx_stream;
        }
 
-       if (atomic_read(&bebob->substreams_counter) == 0) {
+       if (bebob->substreams_counter == 0) {
                amdtp_stream_pcm_abort(master);
                amdtp_stream_stop(master);