ALSA: firewire-tascam: cease from delayed card registration
The delayed registration of sound card instance brings less benefit than complication of kobject management. This commit ceases from it. Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp> Link: https://lore.kernel.org/r/20210607081250.13397-7-o-takashi@sakamocchi.jp Signed-off-by: Takashi Iwai <tiwai@suse.de>
This commit is contained in:
parent
9067c181c3
commit
7ae2f179a4
@ -90,19 +90,31 @@ static void tscm_card_free(struct snd_card *card)
|
|||||||
|
|
||||||
snd_tscm_transaction_unregister(tscm);
|
snd_tscm_transaction_unregister(tscm);
|
||||||
snd_tscm_stream_destroy_duplex(tscm);
|
snd_tscm_stream_destroy_duplex(tscm);
|
||||||
|
|
||||||
|
mutex_destroy(&tscm->mutex);
|
||||||
|
fw_unit_put(tscm->unit);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void do_registration(struct work_struct *work)
|
static int snd_tscm_probe(struct fw_unit *unit,
|
||||||
|
const struct ieee1394_device_id *entry)
|
||||||
{
|
{
|
||||||
struct snd_tscm *tscm = container_of(work, struct snd_tscm, dwork.work);
|
struct snd_card *card;
|
||||||
|
struct snd_tscm *tscm;
|
||||||
int err;
|
int err;
|
||||||
|
|
||||||
err = snd_card_new(&tscm->unit->device, -1, NULL, THIS_MODULE, 0,
|
err = snd_card_new(&unit->device, -1, NULL, THIS_MODULE, sizeof(*tscm), &card);
|
||||||
&tscm->card);
|
|
||||||
if (err < 0)
|
if (err < 0)
|
||||||
return;
|
return err;
|
||||||
tscm->card->private_free = tscm_card_free;
|
card->private_free = tscm_card_free;
|
||||||
tscm->card->private_data = tscm;
|
|
||||||
|
tscm = card->private_data;
|
||||||
|
tscm->unit = fw_unit_get(unit);
|
||||||
|
dev_set_drvdata(&unit->device, tscm);
|
||||||
|
tscm->card = card;
|
||||||
|
|
||||||
|
mutex_init(&tscm->mutex);
|
||||||
|
spin_lock_init(&tscm->lock);
|
||||||
|
init_waitqueue_head(&tscm->hwdep_wait);
|
||||||
|
|
||||||
err = identify_model(tscm);
|
err = identify_model(tscm);
|
||||||
if (err < 0)
|
if (err < 0)
|
||||||
@ -130,81 +142,33 @@ static void do_registration(struct work_struct *work)
|
|||||||
if (err < 0)
|
if (err < 0)
|
||||||
goto error;
|
goto error;
|
||||||
|
|
||||||
err = snd_card_register(tscm->card);
|
err = snd_card_register(card);
|
||||||
if (err < 0)
|
if (err < 0)
|
||||||
goto error;
|
goto error;
|
||||||
|
|
||||||
tscm->registered = true;
|
|
||||||
|
|
||||||
return;
|
|
||||||
error:
|
|
||||||
snd_card_free(tscm->card);
|
|
||||||
dev_info(&tscm->unit->device,
|
|
||||||
"Sound card registration failed: %d\n", err);
|
|
||||||
}
|
|
||||||
|
|
||||||
static int snd_tscm_probe(struct fw_unit *unit,
|
|
||||||
const struct ieee1394_device_id *entry)
|
|
||||||
{
|
|
||||||
struct snd_tscm *tscm;
|
|
||||||
|
|
||||||
/* Allocate this independent of sound card instance. */
|
|
||||||
tscm = devm_kzalloc(&unit->device, sizeof(struct snd_tscm), GFP_KERNEL);
|
|
||||||
if (!tscm)
|
|
||||||
return -ENOMEM;
|
|
||||||
tscm->unit = fw_unit_get(unit);
|
|
||||||
dev_set_drvdata(&unit->device, tscm);
|
|
||||||
|
|
||||||
mutex_init(&tscm->mutex);
|
|
||||||
spin_lock_init(&tscm->lock);
|
|
||||||
init_waitqueue_head(&tscm->hwdep_wait);
|
|
||||||
|
|
||||||
/* Allocate and register this sound card later. */
|
|
||||||
INIT_DEFERRABLE_WORK(&tscm->dwork, do_registration);
|
|
||||||
snd_fw_schedule_registration(unit, &tscm->dwork);
|
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
error:
|
||||||
|
snd_card_free(card);
|
||||||
|
return err;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void snd_tscm_update(struct fw_unit *unit)
|
static void snd_tscm_update(struct fw_unit *unit)
|
||||||
{
|
{
|
||||||
struct snd_tscm *tscm = dev_get_drvdata(&unit->device);
|
struct snd_tscm *tscm = dev_get_drvdata(&unit->device);
|
||||||
|
|
||||||
/* Postpone a workqueue for deferred registration. */
|
|
||||||
if (!tscm->registered)
|
|
||||||
snd_fw_schedule_registration(unit, &tscm->dwork);
|
|
||||||
|
|
||||||
snd_tscm_transaction_reregister(tscm);
|
snd_tscm_transaction_reregister(tscm);
|
||||||
|
|
||||||
/*
|
mutex_lock(&tscm->mutex);
|
||||||
* After registration, userspace can start packet streaming, then this
|
snd_tscm_stream_update_duplex(tscm);
|
||||||
* code block works fine.
|
mutex_unlock(&tscm->mutex);
|
||||||
*/
|
|
||||||
if (tscm->registered) {
|
|
||||||
mutex_lock(&tscm->mutex);
|
|
||||||
snd_tscm_stream_update_duplex(tscm);
|
|
||||||
mutex_unlock(&tscm->mutex);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void snd_tscm_remove(struct fw_unit *unit)
|
static void snd_tscm_remove(struct fw_unit *unit)
|
||||||
{
|
{
|
||||||
struct snd_tscm *tscm = dev_get_drvdata(&unit->device);
|
struct snd_tscm *tscm = dev_get_drvdata(&unit->device);
|
||||||
|
|
||||||
/*
|
// Block till all of ALSA character devices are released.
|
||||||
* Confirm to stop the work for registration before the sound card is
|
snd_card_free(tscm->card);
|
||||||
* going to be released. The work is not scheduled again because bus
|
|
||||||
* reset handler is not called anymore.
|
|
||||||
*/
|
|
||||||
cancel_delayed_work_sync(&tscm->dwork);
|
|
||||||
|
|
||||||
if (tscm->registered) {
|
|
||||||
// Block till all of ALSA character devices are released.
|
|
||||||
snd_card_free(tscm->card);
|
|
||||||
}
|
|
||||||
|
|
||||||
mutex_destroy(&tscm->mutex);
|
|
||||||
fw_unit_put(tscm->unit);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static const struct ieee1394_device_id snd_tscm_id_table[] = {
|
static const struct ieee1394_device_id snd_tscm_id_table[] = {
|
||||||
|
@ -70,8 +70,6 @@ struct snd_tscm {
|
|||||||
struct mutex mutex;
|
struct mutex mutex;
|
||||||
spinlock_t lock;
|
spinlock_t lock;
|
||||||
|
|
||||||
bool registered;
|
|
||||||
struct delayed_work dwork;
|
|
||||||
const struct snd_tscm_spec *spec;
|
const struct snd_tscm_spec *spec;
|
||||||
|
|
||||||
struct fw_iso_resources tx_resources;
|
struct fw_iso_resources tx_resources;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user