From 1f93a7dfd1f8d5ff7a5c53246c7534fe2332d6f4 Mon Sep 17 00:00:00 2001 From: hc <hc@nodka.com> Date: Mon, 11 Dec 2023 02:46:07 +0000 Subject: [PATCH] add audio --- kernel/sound/firewire/tascam/tascam.c | 48 +++++++++++++++--------------------------------- 1 files changed, 15 insertions(+), 33 deletions(-) diff --git a/kernel/sound/firewire/tascam/tascam.c b/kernel/sound/firewire/tascam/tascam.c index 1e61cdc..75f2edd 100644 --- a/kernel/sound/firewire/tascam/tascam.c +++ b/kernel/sound/firewire/tascam/tascam.c @@ -1,9 +1,8 @@ +// SPDX-License-Identifier: GPL-2.0-only /* * tascam.c - a part of driver for TASCAM FireWire series * * Copyright (c) 2015 Takashi Sakamoto - * - * Licensed under the terms of the GNU General Public License, version 2. */ #include "tascam.h" @@ -85,20 +84,12 @@ return 0; } -static void tscm_free(struct snd_tscm *tscm) -{ - snd_tscm_transaction_unregister(tscm); - snd_tscm_stream_destroy_duplex(tscm); - - fw_unit_put(tscm->unit); - - mutex_destroy(&tscm->mutex); - kfree(tscm); -} - static void tscm_card_free(struct snd_card *card) { - tscm_free(card->private_data); + struct snd_tscm *tscm = card->private_data; + + snd_tscm_transaction_unregister(tscm); + snd_tscm_stream_destroy_duplex(tscm); } static void do_registration(struct work_struct *work) @@ -110,6 +101,8 @@ &tscm->card); if (err < 0) return; + tscm->card->private_free = tscm_card_free; + tscm->card->private_data = tscm; err = identify_model(tscm); if (err < 0) @@ -141,18 +134,10 @@ if (err < 0) goto error; - /* - * After registered, tscm instance can be released corresponding to - * releasing the sound card instance. - */ - tscm->card->private_free = tscm_card_free; - tscm->card->private_data = tscm; tscm->registered = true; return; error: - snd_tscm_transaction_unregister(tscm); - snd_tscm_stream_destroy_duplex(tscm); snd_card_free(tscm->card); dev_info(&tscm->unit->device, "Sound card registration failed: %d\n", err); @@ -164,11 +149,9 @@ struct snd_tscm *tscm; /* Allocate this independent of sound card instance. */ - tscm = kzalloc(sizeof(struct snd_tscm), GFP_KERNEL); - if (tscm == NULL) + tscm = devm_kzalloc(&unit->device, sizeof(struct snd_tscm), GFP_KERNEL); + if (!tscm) return -ENOMEM; - - /* initialize myself */ tscm->unit = fw_unit_get(unit); dev_set_drvdata(&unit->device, tscm); @@ -216,12 +199,12 @@ cancel_delayed_work_sync(&tscm->dwork); if (tscm->registered) { - /* No need to wait for releasing card object in this context. */ - snd_card_free_when_closed(tscm->card); - } else { - /* Don't forget this case. */ - tscm_free(tscm); + // 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[] = { @@ -259,7 +242,6 @@ .specifier_id = 0x00022e, .version = 0x800004, }, - /* FE-08 requires reverse-engineering because it just has faders. */ {} }; MODULE_DEVICE_TABLE(ieee1394, snd_tscm_id_table); @@ -267,7 +249,7 @@ static struct fw_driver tscm_driver = { .driver = { .owner = THIS_MODULE, - .name = "snd-firewire-tascam", + .name = KBUILD_MODNAME, .bus = &fw_bus_type, }, .probe = snd_tscm_probe, -- Gitblit v1.6.2