ALSA: fireface: 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-9-o-takashi@sakamocchi.jp Signed-off-by: Takashi Iwai <tiwai@suse.de>
This commit is contained in:
parent
a49c6766df
commit
ee5f0b32ce
|
@ -42,22 +42,33 @@ static void ff_card_free(struct snd_card *card)
|
||||||
|
|
||||||
snd_ff_stream_destroy_duplex(ff);
|
snd_ff_stream_destroy_duplex(ff);
|
||||||
snd_ff_transaction_unregister(ff);
|
snd_ff_transaction_unregister(ff);
|
||||||
|
|
||||||
|
mutex_destroy(&ff->mutex);
|
||||||
|
fw_unit_put(ff->unit);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void do_registration(struct work_struct *work)
|
static int snd_ff_probe(struct fw_unit *unit, const struct ieee1394_device_id *entry)
|
||||||
{
|
{
|
||||||
struct snd_ff *ff = container_of(work, struct snd_ff, dwork.work);
|
struct snd_card *card;
|
||||||
|
struct snd_ff *ff;
|
||||||
int err;
|
int err;
|
||||||
|
|
||||||
if (ff->registered)
|
err = snd_card_new(&unit->device, -1, NULL, THIS_MODULE, sizeof(*ff), &card);
|
||||||
return;
|
|
||||||
|
|
||||||
err = snd_card_new(&ff->unit->device, -1, NULL, THIS_MODULE, 0,
|
|
||||||
&ff->card);
|
|
||||||
if (err < 0)
|
if (err < 0)
|
||||||
return;
|
return err;
|
||||||
ff->card->private_free = ff_card_free;
|
card->private_free = ff_card_free;
|
||||||
ff->card->private_data = ff;
|
|
||||||
|
ff = card->private_data;
|
||||||
|
ff->unit = fw_unit_get(unit);
|
||||||
|
dev_set_drvdata(&unit->device, ff);
|
||||||
|
ff->card = card;
|
||||||
|
|
||||||
|
mutex_init(&ff->mutex);
|
||||||
|
spin_lock_init(&ff->lock);
|
||||||
|
init_waitqueue_head(&ff->hwdep_wait);
|
||||||
|
|
||||||
|
ff->unit_version = entry->version;
|
||||||
|
ff->spec = (const struct snd_ff_spec *)entry->driver_data;
|
||||||
|
|
||||||
err = snd_ff_transaction_register(ff);
|
err = snd_ff_transaction_register(ff);
|
||||||
if (err < 0)
|
if (err < 0)
|
||||||
|
@ -83,76 +94,31 @@ static void do_registration(struct work_struct *work)
|
||||||
if (err < 0)
|
if (err < 0)
|
||||||
goto error;
|
goto error;
|
||||||
|
|
||||||
err = snd_card_register(ff->card);
|
err = snd_card_register(card);
|
||||||
if (err < 0)
|
if (err < 0)
|
||||||
goto error;
|
goto error;
|
||||||
|
|
||||||
ff->registered = true;
|
|
||||||
|
|
||||||
return;
|
|
||||||
error:
|
|
||||||
snd_card_free(ff->card);
|
|
||||||
dev_info(&ff->unit->device,
|
|
||||||
"Sound card registration failed: %d\n", err);
|
|
||||||
}
|
|
||||||
|
|
||||||
static int snd_ff_probe(struct fw_unit *unit,
|
|
||||||
const struct ieee1394_device_id *entry)
|
|
||||||
{
|
|
||||||
struct snd_ff *ff;
|
|
||||||
|
|
||||||
ff = devm_kzalloc(&unit->device, sizeof(struct snd_ff), GFP_KERNEL);
|
|
||||||
if (!ff)
|
|
||||||
return -ENOMEM;
|
|
||||||
ff->unit = fw_unit_get(unit);
|
|
||||||
dev_set_drvdata(&unit->device, ff);
|
|
||||||
|
|
||||||
mutex_init(&ff->mutex);
|
|
||||||
spin_lock_init(&ff->lock);
|
|
||||||
init_waitqueue_head(&ff->hwdep_wait);
|
|
||||||
|
|
||||||
ff->unit_version = entry->version;
|
|
||||||
ff->spec = (const struct snd_ff_spec *)entry->driver_data;
|
|
||||||
|
|
||||||
/* Register this sound card later. */
|
|
||||||
INIT_DEFERRABLE_WORK(&ff->dwork, do_registration);
|
|
||||||
snd_fw_schedule_registration(unit, &ff->dwork);
|
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
error:
|
||||||
|
snd_card_free(card);
|
||||||
|
return err;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void snd_ff_update(struct fw_unit *unit)
|
static void snd_ff_update(struct fw_unit *unit)
|
||||||
{
|
{
|
||||||
struct snd_ff *ff = dev_get_drvdata(&unit->device);
|
struct snd_ff *ff = dev_get_drvdata(&unit->device);
|
||||||
|
|
||||||
/* Postpone a workqueue for deferred registration. */
|
|
||||||
if (!ff->registered)
|
|
||||||
snd_fw_schedule_registration(unit, &ff->dwork);
|
|
||||||
|
|
||||||
snd_ff_transaction_reregister(ff);
|
snd_ff_transaction_reregister(ff);
|
||||||
|
|
||||||
if (ff->registered)
|
snd_ff_stream_update_duplex(ff);
|
||||||
snd_ff_stream_update_duplex(ff);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void snd_ff_remove(struct fw_unit *unit)
|
static void snd_ff_remove(struct fw_unit *unit)
|
||||||
{
|
{
|
||||||
struct snd_ff *ff = dev_get_drvdata(&unit->device);
|
struct snd_ff *ff = 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(ff->card);
|
||||||
* going to be released. The work is not scheduled again because bus
|
|
||||||
* reset handler is not called anymore.
|
|
||||||
*/
|
|
||||||
cancel_work_sync(&ff->dwork.work);
|
|
||||||
|
|
||||||
if (ff->registered) {
|
|
||||||
// Block till all of ALSA character devices are released.
|
|
||||||
snd_card_free(ff->card);
|
|
||||||
}
|
|
||||||
|
|
||||||
mutex_destroy(&ff->mutex);
|
|
||||||
fw_unit_put(ff->unit);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static const struct snd_ff_spec spec_ff800 = {
|
static const struct snd_ff_spec spec_ff800 = {
|
||||||
|
|
|
@ -69,9 +69,6 @@ struct snd_ff {
|
||||||
struct mutex mutex;
|
struct mutex mutex;
|
||||||
spinlock_t lock;
|
spinlock_t lock;
|
||||||
|
|
||||||
bool registered;
|
|
||||||
struct delayed_work dwork;
|
|
||||||
|
|
||||||
enum snd_ff_unit_version unit_version;
|
enum snd_ff_unit_version unit_version;
|
||||||
const struct snd_ff_spec *spec;
|
const struct snd_ff_spec *spec;
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue