From patchwork Wed Dec 14 03:03:09 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Li Qiang X-Patchwork-Id: 9473655 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id C5A8660823 for ; Wed, 14 Dec 2016 03:04:40 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id B1B5A286B3 for ; Wed, 14 Dec 2016 03:04:40 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id A3822286E3; Wed, 14 Dec 2016 03:04:40 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.3 required=2.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_HI, RCVD_IN_SORBS_SPAM, T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id A7B8A286B3 for ; Wed, 14 Dec 2016 03:04:38 +0000 (UTC) Received: from localhost ([::1]:45212 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cGzrx-00066c-GK for patchwork-qemu-devel@patchwork.kernel.org; Tue, 13 Dec 2016 22:04:37 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:58769) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cGzri-0005xO-0I for qemu-devel@nongnu.org; Tue, 13 Dec 2016 22:04:22 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1cGzre-0008Cp-2F for qemu-devel@nongnu.org; Tue, 13 Dec 2016 22:04:22 -0500 Received: from mail-oi0-f67.google.com ([209.85.218.67]:35830) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1cGzrd-0008Cl-U7 for qemu-devel@nongnu.org; Tue, 13 Dec 2016 22:04:17 -0500 Received: by mail-oi0-f67.google.com with SMTP id v84so850749oie.2 for ; Tue, 13 Dec 2016 19:04:17 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=message-id:from:to:cc:subject:date; bh=jIwHorYgwsKnyrB3ROxReu34TkVArtl+tyBTJtvXAN4=; b=abDhT2c/Rbk6iWgoLOP2vZvuFckqcclPSU9FUR0+Ci/Z4CrVZO8hxt7iqaZDL5t9Gi q6LN0aZ5Fdj/MY45FrOizUfjv5d0z6kFrAQnhNF78NlZaDOQ+wpwAQUocUO3smxeDk57 MZOZkWQBSXiMtTgrnYKdZtMtxdNsEcpnaB4kJPLSw8AC2NkIXE3VeniVdyPFms9Sl8rQ p/yHDh7VRhYWQHa3ACWSRljDHAC9TpA3PNd3PkCjw4sjru36KFG0yrGcEAmMaGUF0Ex7 ChKUHyGXUedk4xwTLFuzlbvg5yK1Q2f0fJ4vZn0bB/5FubuPBlY4REoQ37V839Pc2JPT bzEw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:message-id:from:to:cc:subject:date; bh=jIwHorYgwsKnyrB3ROxReu34TkVArtl+tyBTJtvXAN4=; b=ixuiB+xL2OGnCDRXj4cGZIWbTzIjFqYYZIoQE1XDxeLHvsHjQlj+X6qxtrgSNg6pk+ sPM1BWCWgKOfLIO8rtd9hWJYPU2TkZu5mx5ScAcNkfikTBMaN9etR5cRw3+2YBQSUOm4 39Qp+FcPODkkDaQ1mYSsRc5gU3yiLXE9o+1HbIA8I/BJwKzxwUVvqKJY0PFsmzIdbswN yzozlgWGPFupwTemXFXR7nn1IItSdwE+QfGOEYLQdi29zMK13Qmmn38YWTB3Rwmkt/F/ +QCKGmq0Y8cwxztSvXTqoMsJl6pyGiciDfikAjfpNA8bq3OT8ftem+WUrY+WQyxLdrx4 gGhw== X-Gm-Message-State: AKaTC03oWiPuHBYFAduYRF/iqD1YimZOVUwEmwQE7npGZQcT/5aPTJqNlQJlOZGuqgDb0A== X-Received: by 10.157.50.138 with SMTP id u10mr52843997otb.83.1481684597129; Tue, 13 Dec 2016 19:03:17 -0800 (PST) Received: from localhost.localdomain.localdomain ([104.192.110.250]) by smtp.gmail.com with ESMTPSA id r50sm19645432otc.40.2016.12.13.19.03.14 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 13 Dec 2016 19:03:16 -0800 (PST) Message-ID: <5850b674.b53f9d0a.6452f.717a@mx.google.com> X-Google-Original-Message-ID: <1481684589-4814-1-git-send-email-Qiang(liqiang6-s@360.cn)> From: Li Qiang X-Google-Original-From: Li Qiang(liqiang6-s@360.cn) To: kraxel@redhat.com, qemu-devel@nongnu.org, marcandre.lureau@gmail.com Date: Tue, 13 Dec 2016 19:03:09 -0800 X-Mailer: git-send-email 1.8.3.1 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.85.218.67 Subject: [Qemu-devel] [PATCH v2] audio: es1370: add exit function X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Li Qiang Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP From: Li Qiang Currently the es1370 device emulation doesn't have a exit function, hot unplug this device will leak some memory. Add a exit function to avoid this. Signed-off-by: Li Qiang --- Changes since the v1: close the streams hw/audio/es1370.c | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/hw/audio/es1370.c b/hw/audio/es1370.c index 8449b5f..8fc79fe 100644 --- a/hw/audio/es1370.c +++ b/hw/audio/es1370.c @@ -1041,6 +1041,24 @@ static void es1370_realize(PCIDevice *dev, Error **errp) es1370_reset (s); } +static void es1370_exit(PCIDevice *dev) +{ + ES1370State *s = ES1370(dev); + int i; + + if (s->adc_voice) { + AUD_close_in (&s->card, s->adc_voice); + } + + for (i = 0; i < 2; ++i) { + if (s->dac_voice[i]) { + AUD_close_out (&s->card, s->dac_voice[i]); + } + } + + AUD_remove_card(&s->card); +} + static int es1370_init (PCIBus *bus) { pci_create_simple (bus, -1, TYPE_ES1370); @@ -1053,6 +1071,7 @@ static void es1370_class_init (ObjectClass *klass, void *data) PCIDeviceClass *k = PCI_DEVICE_CLASS (klass); k->realize = es1370_realize; + k->exit = es1370_exit; k->vendor_id = PCI_VENDOR_ID_ENSONIQ; k->device_id = PCI_DEVICE_ID_ENSONIQ_ES1370; k->class_id = PCI_CLASS_MULTIMEDIA_AUDIO;