From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from [140.186.70.92] (port=53720 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1PFlk2-0005Dq-5b for qemu-devel@nongnu.org; Tue, 09 Nov 2010 05:47:55 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1PFlk1-0002mz-2v for qemu-devel@nongnu.org; Tue, 09 Nov 2010 05:47:54 -0500 Received: from mx1.redhat.com ([209.132.183.28]:57177) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1PFlk0-0002mb-Ru for qemu-devel@nongnu.org; Tue, 09 Nov 2010 05:47:53 -0500 Received: from int-mx01.intmail.prod.int.phx2.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) by mx1.redhat.com (8.13.8/8.13.8) with ESMTP id oA9AlqOU008433 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Tue, 9 Nov 2010 05:47:52 -0500 From: Gerd Hoffmann Date: Tue, 9 Nov 2010 11:47:45 +0100 Message-Id: <1289299669-5504-3-git-send-email-kraxel@redhat.com> In-Reply-To: <1289299669-5504-1-git-send-email-kraxel@redhat.com> References: <1289299669-5504-1-git-send-email-kraxel@redhat.com> Subject: [Qemu-devel] [PATCH v2 2/6] hda-audio: exit cleanup List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: Gerd Hoffmann Add exit callback to the driver. Unregister the sound card properly on exit. [ v2: codestyle: add braces ] Signed-off-by: Gerd Hoffmann --- hw/hda-audio.c | 24 ++++++++++++++++++++++++ 1 files changed, 24 insertions(+), 0 deletions(-) diff --git a/hw/hda-audio.c b/hw/hda-audio.c index 1035774..c699d6f 100644 --- a/hw/hda-audio.c +++ b/hw/hda-audio.c @@ -808,6 +808,28 @@ static int hda_audio_init(HDACodecDevice *hda, const struct desc_codec *desc) return 0; } +static int hda_audio_exit(HDACodecDevice *hda) +{ + HDAAudioState *a = DO_UPCAST(HDAAudioState, hda, hda); + HDAAudioStream *st; + int i; + + dprint(a, 1, "%s\n", __FUNCTION__); + for (i = 0; i < ARRAY_SIZE(a->st); i++) { + st = a->st + i; + if (st->node == NULL) { + continue; + } + if (st->output) { + AUD_close_out(&a->card, st->voice.out); + } else { + AUD_close_in(&a->card, st->voice.in); + } + } + AUD_remove_card(&a->card); + return 0; +} + static int hda_audio_post_load(void *opaque, int version) { HDAAudioState *a = opaque; @@ -879,6 +901,7 @@ static HDACodecDeviceInfo hda_audio_info_output = { .qdev.vmsd = &vmstate_hda_audio, .qdev.props = hda_audio_properties, .init = hda_audio_init_output, + .exit = hda_audio_exit, .command = hda_audio_command, .stream = hda_audio_stream, }; @@ -890,6 +913,7 @@ static HDACodecDeviceInfo hda_audio_info_duplex = { .qdev.vmsd = &vmstate_hda_audio, .qdev.props = hda_audio_properties, .init = hda_audio_init_duplex, + .exit = hda_audio_exit, .command = hda_audio_command, .stream = hda_audio_stream, }; -- 1.7.1