static void do_registration(struct work_struct *work) { struct snd_motu *motu = container_of(work, struct snd_motu, dwork.work); int err; if (motu->registered) return; err = snd_card_new(&motu->unit->device, -1, NULL, THIS_MODULE, 0, &motu->card); if (err < 0) return; name_card(motu); err = snd_motu_transaction_register(motu); if (err < 0) goto error; err = snd_motu_stream_init_duplex(motu); if (err < 0) goto error; snd_motu_proc_init(motu); err = snd_motu_create_pcm_devices(motu); if (err < 0) goto error; if (motu->spec->flags & SND_MOTU_SPEC_HAS_MIDI) { err = snd_motu_create_midi_devices(motu); if (err < 0) goto error; } err = snd_motu_create_hwdep_device(motu); if (err < 0) goto error; err = snd_card_register(motu->card); if (err < 0) goto error; /* * After registered, motu instance can be released corresponding to * releasing the sound card instance. */ motu->card->private_free = motu_card_free; motu->card->private_data = motu; motu->registered = true; return; error: snd_motu_transaction_unregister(motu); snd_card_free(motu->card); dev_info(&motu->unit->device, "Sound card registration failed: %d\n", err); }
static void do_registration(struct work_struct *work) { struct snd_motu *motu = container_of(work, struct snd_motu, dwork.work); int err; if (motu->registered) return; err = snd_card_new(&motu->unit->device, -1, NULL, THIS_MODULE, 0, &motu->card); if (err < 0) return; motu->card->private_free = motu_card_free; motu->card->private_data = motu; name_card(motu); err = snd_motu_transaction_register(motu); if (err < 0) goto error; err = snd_motu_stream_init_duplex(motu); if (err < 0) goto error; snd_motu_proc_init(motu); err = snd_motu_create_pcm_devices(motu); if (err < 0) goto error; if ((motu->spec->flags & SND_MOTU_SPEC_RX_MIDI_2ND_Q) || (motu->spec->flags & SND_MOTU_SPEC_RX_MIDI_3RD_Q) || (motu->spec->flags & SND_MOTU_SPEC_TX_MIDI_2ND_Q) || (motu->spec->flags & SND_MOTU_SPEC_TX_MIDI_3RD_Q)) { err = snd_motu_create_midi_devices(motu); if (err < 0) goto error; } err = snd_motu_create_hwdep_device(motu); if (err < 0) goto error; err = snd_card_register(motu->card); if (err < 0) goto error; motu->registered = true; return; error: snd_card_free(motu->card); dev_info(&motu->unit->device, "Sound card registration failed: %d\n", err); }