Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

ALSA: firewire: release reference count of firewire unit in .remove callback of bus driver

In a previous commit, drivers in ALSA firewire stack blocks .remove
callback of bus driver. This enables to release members of private
data in the callback after releasing device of sound card.

This commit simplifies codes to release the members.

Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
Signed-off-by: Takashi Iwai <tiwai@suse.de>

authored by

Takashi Sakamoto and committed by
Takashi Iwai
5b14ec25 61ccc6f6

+27 -50
+3 -6
sound/firewire/bebob/bebob.c
··· 129 129 static void bebob_free(struct snd_bebob *bebob) 130 130 { 131 131 snd_bebob_stream_destroy_duplex(bebob); 132 - 133 - mutex_destroy(&bebob->mutex); 134 - fw_unit_put(bebob->unit); 135 132 } 136 133 137 134 /* ··· 373 376 if (bebob->registered) { 374 377 // Block till all of ALSA character devices are released. 375 378 snd_card_free(bebob->card); 376 - } else { 377 - /* Don't forget this case. */ 378 - bebob_free(bebob); 379 379 } 380 + 381 + mutex_destroy(&bebob->mutex); 382 + fw_unit_put(bebob->unit); 380 383 } 381 384 382 385 static const struct snd_bebob_rate_spec normal_rate_spec = {
+3 -6
sound/firewire/dice/dice.c
··· 126 126 { 127 127 snd_dice_stream_destroy_duplex(dice); 128 128 snd_dice_transaction_destroy(dice); 129 - 130 - mutex_destroy(&dice->mutex); 131 - fw_unit_put(dice->unit); 132 129 } 133 130 134 131 /* ··· 258 261 if (dice->registered) { 259 262 /* No need to wait for releasing card object in this context. */ 260 263 snd_card_free_when_closed(dice->card); 261 - } else { 262 - /* Don't forget this case. */ 263 - dice_free(dice); 264 264 } 265 + 266 + mutex_destroy(&dice->mutex); 267 + fw_unit_put(dice->unit); 265 268 } 266 269 267 270 static void dice_bus_reset(struct fw_unit *unit)
+3 -6
sound/firewire/digi00x/digi00x.c
··· 45 45 { 46 46 snd_dg00x_stream_destroy_duplex(dg00x); 47 47 snd_dg00x_transaction_unregister(dg00x); 48 - 49 - mutex_destroy(&dg00x->mutex); 50 - fw_unit_put(dg00x->unit); 51 48 } 52 49 53 50 static void dg00x_card_free(struct snd_card *card) ··· 171 174 if (dg00x->registered) { 172 175 // Block till all of ALSA character devices are released. 173 176 snd_card_free(dg00x->card); 174 - } else { 175 - /* Don't forget this case. */ 176 - dg00x_free(dg00x); 177 177 } 178 + 179 + mutex_destroy(&dg00x->mutex); 180 + fw_unit_put(dg00x->unit); 178 181 } 179 182 180 183 static const struct ieee1394_device_id snd_dg00x_id_table[] = {
+3 -6
sound/firewire/fireface/ff.c
··· 31 31 { 32 32 snd_ff_stream_destroy_duplex(ff); 33 33 snd_ff_transaction_unregister(ff); 34 - 35 - mutex_destroy(&ff->mutex); 36 - fw_unit_put(ff->unit); 37 34 } 38 35 39 36 static void ff_card_free(struct snd_card *card) ··· 144 147 if (ff->registered) { 145 148 // Block till all of ALSA character devices are released. 146 149 snd_card_free(ff->card); 147 - } else { 148 - /* Don't forget this case. */ 149 - ff_free(ff); 150 150 } 151 + 152 + mutex_destroy(&ff->mutex); 153 + fw_unit_put(ff->unit); 151 154 } 152 155 153 156 static const struct snd_ff_spec spec_ff400 = {
+3 -6
sound/firewire/fireworks/fireworks.c
··· 188 188 { 189 189 snd_efw_stream_destroy_duplex(efw); 190 190 snd_efw_transaction_remove_instance(efw); 191 - 192 - mutex_destroy(&efw->mutex); 193 - fw_unit_put(efw->unit); 194 191 } 195 192 196 193 /* ··· 357 360 if (efw->registered) { 358 361 // Block till all of ALSA character devices are released. 359 362 snd_card_free(efw->card); 360 - } else { 361 - /* Don't forget this case. */ 362 - efw_free(efw); 363 363 } 364 + 365 + mutex_destroy(&efw->mutex); 366 + fw_unit_put(efw->unit); 364 367 } 365 368 366 369 static const struct ieee1394_device_id efw_id_table[] = {
+3 -2
sound/firewire/isight.c
··· 602 602 struct isight *isight = card->private_data; 603 603 604 604 fw_iso_resources_destroy(&isight->resources); 605 - fw_unit_put(isight->unit); 606 - mutex_destroy(&isight->mutex); 607 605 } 608 606 609 607 static u64 get_unit_base(struct fw_unit *unit) ··· 703 705 704 706 // Block till all of ALSA character devices are released. 705 707 snd_card_free(isight->card); 708 + 709 + mutex_destroy(&isight->mutex); 710 + fw_unit_put(isight->unit); 706 711 } 707 712 708 713 static const struct ieee1394_device_id isight_id_table[] = {
+3 -6
sound/firewire/motu/motu.c
··· 57 57 snd_motu_transaction_unregister(motu); 58 58 59 59 snd_motu_stream_destroy_duplex(motu); 60 - 61 - mutex_destroy(&motu->mutex); 62 - fw_unit_put(motu->unit); 63 60 } 64 61 65 62 /* ··· 171 174 if (motu->registered) { 172 175 // Block till all of ALSA character devices are released. 173 176 snd_card_free(motu->card); 174 - } else { 175 - /* Don't forget this case. */ 176 - motu_free(motu); 177 177 } 178 + 179 + mutex_destroy(&motu->mutex); 180 + fw_unit_put(motu->unit); 178 181 } 179 182 180 183 static void motu_bus_update(struct fw_unit *unit)
+3 -6
sound/firewire/oxfw/oxfw.c
··· 118 118 snd_oxfw_stream_destroy_simplex(oxfw, &oxfw->rx_stream); 119 119 if (oxfw->has_output) 120 120 snd_oxfw_stream_destroy_simplex(oxfw, &oxfw->tx_stream); 121 - 122 - mutex_destroy(&oxfw->mutex); 123 - fw_unit_put(oxfw->unit); 124 121 } 125 122 126 123 /* ··· 326 329 if (oxfw->registered) { 327 330 // Block till all of ALSA character devices are released. 328 331 snd_card_free(oxfw->card); 329 - } else { 330 - /* Don't forget this case. */ 331 - oxfw_free(oxfw); 332 332 } 333 + 334 + mutex_destroy(&oxfw->mutex); 335 + fw_unit_put(oxfw->unit); 333 336 } 334 337 335 338 static const struct compat_info griffin_firewave = {
+3 -6
sound/firewire/tascam/tascam.c
··· 89 89 { 90 90 snd_tscm_transaction_unregister(tscm); 91 91 snd_tscm_stream_destroy_duplex(tscm); 92 - 93 - mutex_destroy(&tscm->mutex); 94 - fw_unit_put(tscm->unit); 95 92 } 96 93 97 94 static void tscm_card_free(struct snd_card *card) ··· 211 214 if (tscm->registered) { 212 215 // Block till all of ALSA character devices are released. 213 216 snd_card_free(tscm->card); 214 - } else { 215 - /* Don't forget this case. */ 216 - tscm_free(tscm); 217 217 } 218 + 219 + mutex_destroy(&tscm->mutex); 220 + fw_unit_put(tscm->unit); 218 221 } 219 222 220 223 static const struct ieee1394_device_id snd_tscm_id_table[] = {