aboutsummaryrefslogtreecommitdiffstats
path: root/sound
diff options
context:
space:
mode:
authorTakashi Sakamoto <o-takashi@sakamocchi.jp>2015-02-21 09:55:00 -0500
committerTakashi Iwai <tiwai@suse.de>2015-02-23 03:11:24 -0500
commitdec84316dd53c90e93b4ee849483bd4bd1e9a585 (patch)
tree3725938633e83ba9bf303e171323bbb911a0ba9f /sound
parentd23c2cc4485d10f0cedfef99dd2961d9652b1b3f (diff)
ALSA: fireworks/bebob/dice/oxfw: make it possible to shutdown safely
A part of these drivers, especially BeBoB driver, are programmed to wait some events. Thus the drivers should not destroy any data in .remove() context. This commit moves some destructors from 'struct fw_driver.remove()' to 'struct snd_card.private_free()' to shutdown safely. Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp> Cc: <stable@vger.kernel.org> # 3.19+ Signed-off-by: Takashi Iwai <tiwai@suse.de>
Diffstat (limited to 'sound')
-rw-r--r--sound/firewire/bebob/bebob.c10
-rw-r--r--sound/firewire/bebob/bebob_stream.c4
-rw-r--r--sound/firewire/dice/dice.c5
-rw-r--r--sound/firewire/fireworks/fireworks.c10
-rw-r--r--sound/firewire/fireworks/fireworks_stream.c4
-rw-r--r--sound/firewire/oxfw/oxfw.c10
6 files changed, 15 insertions, 28 deletions
diff --git a/sound/firewire/bebob/bebob.c b/sound/firewire/bebob/bebob.c
index b612599fb543..611b7dae7ee5 100644
--- a/sound/firewire/bebob/bebob.c
+++ b/sound/firewire/bebob/bebob.c
@@ -127,8 +127,11 @@ bebob_card_free(struct snd_card *card)
127{ 127{
128 struct snd_bebob *bebob = card->private_data; 128 struct snd_bebob *bebob = card->private_data;
129 129
130 snd_bebob_stream_destroy_duplex(bebob);
130 fw_unit_put(bebob->unit); 131 fw_unit_put(bebob->unit);
131 132
133 kfree(bebob->maudio_special_quirk);
134
132 if (bebob->card_index >= 0) { 135 if (bebob->card_index >= 0) {
133 mutex_lock(&devices_mutex); 136 mutex_lock(&devices_mutex);
134 clear_bit(bebob->card_index, devices_used); 137 clear_bit(bebob->card_index, devices_used);
@@ -314,10 +317,9 @@ static void bebob_remove(struct fw_unit *unit)
314 if (bebob == NULL) 317 if (bebob == NULL)
315 return; 318 return;
316 319
317 kfree(bebob->maudio_special_quirk); 320 /* Awake bus-reset waiters. */
318 321 if (!completion_done(&bebob->bus_reset))
319 snd_bebob_stream_destroy_duplex(bebob); 322 complete_all(&bebob->bus_reset);
320 snd_card_disconnect(bebob->card);
321 323
322 /* No need to wait for releasing card object in this context. */ 324 /* No need to wait for releasing card object in this context. */
323 snd_card_free_when_closed(bebob->card); 325 snd_card_free_when_closed(bebob->card);
diff --git a/sound/firewire/bebob/bebob_stream.c b/sound/firewire/bebob/bebob_stream.c
index fcca3eebc91f..98e4fc8121a1 100644
--- a/sound/firewire/bebob/bebob_stream.c
+++ b/sound/firewire/bebob/bebob_stream.c
@@ -716,14 +716,10 @@ void snd_bebob_stream_update_duplex(struct snd_bebob *bebob)
716 */ 716 */
717void snd_bebob_stream_destroy_duplex(struct snd_bebob *bebob) 717void snd_bebob_stream_destroy_duplex(struct snd_bebob *bebob)
718{ 718{
719 mutex_lock(&bebob->mutex);
720
721 amdtp_stream_destroy(&bebob->rx_stream); 719 amdtp_stream_destroy(&bebob->rx_stream);
722 amdtp_stream_destroy(&bebob->tx_stream); 720 amdtp_stream_destroy(&bebob->tx_stream);
723 721
724 destroy_both_connections(bebob); 722 destroy_both_connections(bebob);
725
726 mutex_unlock(&bebob->mutex);
727} 723}
728 724
729/* 725/*
diff --git a/sound/firewire/dice/dice.c b/sound/firewire/dice/dice.c
index 797f0726fc74..70a111d7f428 100644
--- a/sound/firewire/dice/dice.c
+++ b/sound/firewire/dice/dice.c
@@ -236,6 +236,7 @@ static void dice_card_free(struct snd_card *card)
236{ 236{
237 struct snd_dice *dice = card->private_data; 237 struct snd_dice *dice = card->private_data;
238 238
239 snd_dice_stream_destroy_duplex(dice);
239 snd_dice_transaction_destroy(dice); 240 snd_dice_transaction_destroy(dice);
240 fw_unit_put(dice->unit); 241 fw_unit_put(dice->unit);
241 242
@@ -313,10 +314,6 @@ static void dice_remove(struct fw_unit *unit)
313{ 314{
314 struct snd_dice *dice = dev_get_drvdata(&unit->device); 315 struct snd_dice *dice = dev_get_drvdata(&unit->device);
315 316
316 snd_card_disconnect(dice->card);
317
318 snd_dice_stream_destroy_duplex(dice);
319
320 /* No need to wait for releasing card object in this context. */ 317 /* No need to wait for releasing card object in this context. */
321 snd_card_free_when_closed(dice->card); 318 snd_card_free_when_closed(dice->card);
322} 319}
diff --git a/sound/firewire/fireworks/fireworks.c b/sound/firewire/fireworks/fireworks.c
index 1e33394d8a93..2682e7e3e5c9 100644
--- a/sound/firewire/fireworks/fireworks.c
+++ b/sound/firewire/fireworks/fireworks.c
@@ -184,8 +184,12 @@ efw_card_free(struct snd_card *card)
184{ 184{
185 struct snd_efw *efw = card->private_data; 185 struct snd_efw *efw = card->private_data;
186 186
187 snd_efw_stream_destroy_duplex(efw);
188 snd_efw_transaction_remove_instance(efw);
187 fw_unit_put(efw->unit); 189 fw_unit_put(efw->unit);
188 190
191 kfree(efw->resp_buf);
192
189 if (efw->card_index >= 0) { 193 if (efw->card_index >= 0) {
190 mutex_lock(&devices_mutex); 194 mutex_lock(&devices_mutex);
191 clear_bit(efw->card_index, devices_used); 195 clear_bit(efw->card_index, devices_used);
@@ -193,7 +197,6 @@ efw_card_free(struct snd_card *card)
193 } 197 }
194 198
195 mutex_destroy(&efw->mutex); 199 mutex_destroy(&efw->mutex);
196 kfree(efw->resp_buf);
197} 200}
198 201
199static int 202static int
@@ -297,11 +300,6 @@ static void efw_remove(struct fw_unit *unit)
297{ 300{
298 struct snd_efw *efw = dev_get_drvdata(&unit->device); 301 struct snd_efw *efw = dev_get_drvdata(&unit->device);
299 302
300 snd_efw_stream_destroy_duplex(efw);
301 snd_efw_transaction_remove_instance(efw);
302
303 snd_card_disconnect(efw->card);
304
305 /* No need to wait for releasing card object in this context. */ 303 /* No need to wait for releasing card object in this context. */
306 snd_card_free_when_closed(efw->card); 304 snd_card_free_when_closed(efw->card);
307} 305}
diff --git a/sound/firewire/fireworks/fireworks_stream.c b/sound/firewire/fireworks/fireworks_stream.c
index f817b7ae097e..c55db1bddc80 100644
--- a/sound/firewire/fireworks/fireworks_stream.c
+++ b/sound/firewire/fireworks/fireworks_stream.c
@@ -324,12 +324,8 @@ void snd_efw_stream_update_duplex(struct snd_efw *efw)
324 324
325void snd_efw_stream_destroy_duplex(struct snd_efw *efw) 325void snd_efw_stream_destroy_duplex(struct snd_efw *efw)
326{ 326{
327 mutex_lock(&efw->mutex);
328
329 destroy_stream(efw, &efw->rx_stream); 327 destroy_stream(efw, &efw->rx_stream);
330 destroy_stream(efw, &efw->tx_stream); 328 destroy_stream(efw, &efw->tx_stream);
331
332 mutex_unlock(&efw->mutex);
333} 329}
334 330
335void snd_efw_stream_lock_changed(struct snd_efw *efw) 331void snd_efw_stream_lock_changed(struct snd_efw *efw)
diff --git a/sound/firewire/oxfw/oxfw.c b/sound/firewire/oxfw/oxfw.c
index 1607b26404c3..8c6ce019f437 100644
--- a/sound/firewire/oxfw/oxfw.c
+++ b/sound/firewire/oxfw/oxfw.c
@@ -115,6 +115,10 @@ static void oxfw_card_free(struct snd_card *card)
115 struct snd_oxfw *oxfw = card->private_data; 115 struct snd_oxfw *oxfw = card->private_data;
116 unsigned int i; 116 unsigned int i;
117 117
118 snd_oxfw_stream_destroy_simplex(oxfw, &oxfw->rx_stream);
119 if (oxfw->has_output)
120 snd_oxfw_stream_destroy_simplex(oxfw, &oxfw->tx_stream);
121
118 fw_unit_put(oxfw->unit); 122 fw_unit_put(oxfw->unit);
119 123
120 for (i = 0; i < SND_OXFW_STREAM_FORMAT_ENTRIES; i++) { 124 for (i = 0; i < SND_OXFW_STREAM_FORMAT_ENTRIES; i++) {
@@ -220,12 +224,6 @@ static void oxfw_remove(struct fw_unit *unit)
220{ 224{
221 struct snd_oxfw *oxfw = dev_get_drvdata(&unit->device); 225 struct snd_oxfw *oxfw = dev_get_drvdata(&unit->device);
222 226
223 snd_card_disconnect(oxfw->card);
224
225 snd_oxfw_stream_destroy_simplex(oxfw, &oxfw->rx_stream);
226 if (oxfw->has_output)
227 snd_oxfw_stream_destroy_simplex(oxfw, &oxfw->tx_stream);
228
229 /* No need to wait for releasing card object in this context. */ 227 /* No need to wait for releasing card object in this context. */
230 snd_card_free_when_closed(oxfw->card); 228 snd_card_free_when_closed(oxfw->card);
231} 229}