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

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>

authored by

Takashi Sakamoto and committed by
Takashi Iwai
ee5f0b32 a49c6766

+28 -65
+28 -62
sound/firewire/fireface/ff.c
··· 42 42 43 43 snd_ff_stream_destroy_duplex(ff); 44 44 snd_ff_transaction_unregister(ff); 45 + 46 + mutex_destroy(&ff->mutex); 47 + fw_unit_put(ff->unit); 45 48 } 46 49 47 - static void do_registration(struct work_struct *work) 50 + static int snd_ff_probe(struct fw_unit *unit, const struct ieee1394_device_id *entry) 48 51 { 49 - struct snd_ff *ff = container_of(work, struct snd_ff, dwork.work); 52 + struct snd_card *card; 53 + struct snd_ff *ff; 50 54 int err; 51 55 52 - if (ff->registered) 53 - return; 54 - 55 - err = snd_card_new(&ff->unit->device, -1, NULL, THIS_MODULE, 0, 56 - &ff->card); 56 + err = snd_card_new(&unit->device, -1, NULL, THIS_MODULE, sizeof(*ff), &card); 57 57 if (err < 0) 58 - return; 59 - ff->card->private_free = ff_card_free; 60 - ff->card->private_data = ff; 58 + return err; 59 + card->private_free = ff_card_free; 60 + 61 + ff = card->private_data; 62 + ff->unit = fw_unit_get(unit); 63 + dev_set_drvdata(&unit->device, ff); 64 + ff->card = card; 65 + 66 + mutex_init(&ff->mutex); 67 + spin_lock_init(&ff->lock); 68 + init_waitqueue_head(&ff->hwdep_wait); 69 + 70 + ff->unit_version = entry->version; 71 + ff->spec = (const struct snd_ff_spec *)entry->driver_data; 61 72 62 73 err = snd_ff_transaction_register(ff); 63 74 if (err < 0) ··· 94 83 if (err < 0) 95 84 goto error; 96 85 97 - err = snd_card_register(ff->card); 86 + err = snd_card_register(card); 98 87 if (err < 0) 99 88 goto error; 100 89 101 - ff->registered = true; 102 - 103 - return; 104 - error: 105 - snd_card_free(ff->card); 106 - dev_info(&ff->unit->device, 107 - "Sound card registration failed: %d\n", err); 108 - } 109 - 110 - static int snd_ff_probe(struct fw_unit *unit, 111 - const struct ieee1394_device_id *entry) 112 - { 113 - struct snd_ff *ff; 114 - 115 - ff = devm_kzalloc(&unit->device, sizeof(struct snd_ff), GFP_KERNEL); 116 - if (!ff) 117 - return -ENOMEM; 118 - ff->unit = fw_unit_get(unit); 119 - dev_set_drvdata(&unit->device, ff); 120 - 121 - mutex_init(&ff->mutex); 122 - spin_lock_init(&ff->lock); 123 - init_waitqueue_head(&ff->hwdep_wait); 124 - 125 - ff->unit_version = entry->version; 126 - ff->spec = (const struct snd_ff_spec *)entry->driver_data; 127 - 128 - /* Register this sound card later. */ 129 - INIT_DEFERRABLE_WORK(&ff->dwork, do_registration); 130 - snd_fw_schedule_registration(unit, &ff->dwork); 131 - 132 90 return 0; 91 + error: 92 + snd_card_free(card); 93 + return err; 133 94 } 134 95 135 96 static void snd_ff_update(struct fw_unit *unit) 136 97 { 137 98 struct snd_ff *ff = dev_get_drvdata(&unit->device); 138 99 139 - /* Postpone a workqueue for deferred registration. */ 140 - if (!ff->registered) 141 - snd_fw_schedule_registration(unit, &ff->dwork); 142 - 143 100 snd_ff_transaction_reregister(ff); 144 101 145 - if (ff->registered) 146 - snd_ff_stream_update_duplex(ff); 102 + snd_ff_stream_update_duplex(ff); 147 103 } 148 104 149 105 static void snd_ff_remove(struct fw_unit *unit) 150 106 { 151 107 struct snd_ff *ff = dev_get_drvdata(&unit->device); 152 108 153 - /* 154 - * Confirm to stop the work for registration before the sound card is 155 - * going to be released. The work is not scheduled again because bus 156 - * reset handler is not called anymore. 157 - */ 158 - cancel_work_sync(&ff->dwork.work); 159 - 160 - if (ff->registered) { 161 - // Block till all of ALSA character devices are released. 162 - snd_card_free(ff->card); 163 - } 164 - 165 - mutex_destroy(&ff->mutex); 166 - fw_unit_put(ff->unit); 109 + // Block till all of ALSA character devices are released. 110 + snd_card_free(ff->card); 167 111 } 168 112 169 113 static const struct snd_ff_spec spec_ff800 = {
-3
sound/firewire/fireface/ff.h
··· 69 69 struct mutex mutex; 70 70 spinlock_t lock; 71 71 72 - bool registered; 73 - struct delayed_work dwork; 74 - 75 72 enum snd_ff_unit_version unit_version; 76 73 const struct snd_ff_spec *spec; 77 74