diff options
author | Takashi Sakamoto <o-takashi@sakamocchi.jp> | 2018-10-10 15:35:01 +0900 |
---|---|---|
committer | Takashi Iwai <tiwai@suse.de> | 2018-10-10 12:11:47 +0200 |
commit | 873608dc6b5da7a2571419bfa10e0d088d39cee0 (patch) | |
tree | b0f7ec34dc4186fa69a91f15fb9782b41f0826b5 /sound/firewire/bebob | |
parent | 5b14ec25a79bf60fc9a663fe579a500b6ac9d8ab (diff) | |
download | linux-873608dc6b5da7a2571419bfa10e0d088d39cee0.tar.gz linux-873608dc6b5da7a2571419bfa10e0d088d39cee0.tar.bz2 linux-873608dc6b5da7a2571419bfa10e0d088d39cee0.zip |
ALSA: bebob/fireworks: simplify handling of local device entry table
In drivers of ALSA firewire stack, bebob and fireworks drivers have
local device entry table. At present, critical section to operate the
table is from the beginning/end of 'do_registration' call. This can be
more narrow and simplify codes.
This commit applies small refactoring for the above purpose.
Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
Diffstat (limited to 'sound/firewire/bebob')
-rw-r--r-- | sound/firewire/bebob/bebob.c | 17 |
1 files changed, 6 insertions, 11 deletions
diff --git a/sound/firewire/bebob/bebob.c b/sound/firewire/bebob/bebob.c index 34ed8afbb30c..3bc68499974a 100644 --- a/sound/firewire/bebob/bebob.c +++ b/sound/firewire/bebob/bebob.c @@ -128,6 +128,10 @@ end: static void bebob_free(struct snd_bebob *bebob) { + mutex_lock(&devices_mutex); + clear_bit(bebob->card_index, devices_used); + mutex_unlock(&devices_mutex); + snd_bebob_stream_destroy_duplex(bebob); } @@ -140,12 +144,6 @@ static void bebob_free(struct snd_bebob *bebob) static void bebob_card_free(struct snd_card *card) { - struct snd_bebob *bebob = card->private_data; - - mutex_lock(&devices_mutex); - clear_bit(bebob->card_index, devices_used); - mutex_unlock(&devices_mutex); - bebob_free(card->private_data); } @@ -186,7 +184,6 @@ do_registration(struct work_struct *work) return; mutex_lock(&devices_mutex); - for (card_index = 0; card_index < SNDRV_CARDS; card_index++) { if (!test_bit(card_index, devices_used) && enable[card_index]) break; @@ -202,6 +199,8 @@ do_registration(struct work_struct *work) mutex_unlock(&devices_mutex); return; } + set_bit(card_index, devices_used); + mutex_unlock(&devices_mutex); err = name_device(bebob); if (err < 0) @@ -242,9 +241,6 @@ do_registration(struct work_struct *work) if (err < 0) goto error; - set_bit(card_index, devices_used); - mutex_unlock(&devices_mutex); - /* * After registered, bebob instance can be released corresponding to * releasing the sound card instance. @@ -255,7 +251,6 @@ do_registration(struct work_struct *work) return; error: - mutex_unlock(&devices_mutex); snd_bebob_stream_destroy_duplex(bebob); snd_card_free(bebob->card); dev_info(&bebob->unit->device, |