diff options
author | Takashi Sakamoto <o-takashi@sakamocchi.jp> | 2016-02-20 16:18:57 +0900 |
---|---|---|
committer | Takashi Iwai <tiwai@suse.de> | 2016-02-20 15:45:25 +0100 |
commit | 2a71e701660d7aa9ce1a740588dbf13b975deb10 (patch) | |
tree | 39d699e3e8a66be4bd363df9d1cdb97570072a22 /sound/firewire/bebob/bebob_midi.c | |
parent | 14a37ac1bf8a2ba9b19032195c371c7b0857ca87 (diff) |
ALSA: bebob: move mutex from function callee to callers
Currently, critical section is protected by mutex in functions of
fireworks_stream.c. Callers increments/decrements substreams counter
before calling the functions. Moving mutex to the callers code allows
to change type of the substream counter from atomic_t to unsigned int.
This commit is a preparation for obsoleting usage of atomic_t for
substream counter.
Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
Diffstat (limited to 'sound/firewire/bebob/bebob_midi.c')
-rw-r--r-- | sound/firewire/bebob/bebob_midi.c | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/sound/firewire/bebob/bebob_midi.c b/sound/firewire/bebob/bebob_midi.c index 90d95be499b0..cb1b385b3551 100644 --- a/sound/firewire/bebob/bebob_midi.c +++ b/sound/firewire/bebob/bebob_midi.c @@ -17,8 +17,10 @@ static int midi_capture_open(struct snd_rawmidi_substream *substream) if (err < 0) goto end; + mutex_lock(&bebob->mutex); atomic_inc(&bebob->substreams_counter); err = snd_bebob_stream_start_duplex(bebob, 0); + mutex_unlock(&bebob->mutex); if (err < 0) snd_bebob_stream_lock_release(bebob); end: @@ -34,8 +36,10 @@ static int midi_playback_open(struct snd_rawmidi_substream *substream) if (err < 0) goto end; + mutex_lock(&bebob->mutex); atomic_inc(&bebob->substreams_counter); err = snd_bebob_stream_start_duplex(bebob, 0); + mutex_unlock(&bebob->mutex); if (err < 0) snd_bebob_stream_lock_release(bebob); end: @@ -46,8 +50,10 @@ 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); snd_bebob_stream_stop_duplex(bebob); + mutex_unlock(&bebob->mutex); snd_bebob_stream_lock_release(bebob); return 0; @@ -57,8 +63,10 @@ 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); snd_bebob_stream_stop_duplex(bebob); + mutex_unlock(&bebob->mutex); snd_bebob_stream_lock_release(bebob); return 0; |