From patchwork Thu Dec 15 02:32:22 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Li Qiang X-Patchwork-Id: 9475433 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 C324F607EE for ; Thu, 15 Dec 2016 02:34:15 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id B500028424 for ; Thu, 15 Dec 2016 02:34:15 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id A8BD72871D; Thu, 15 Dec 2016 02:34:15 +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.8 required=2.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_HI, 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 36CC828424 for ; Thu, 15 Dec 2016 02:34:15 +0000 (UTC) Received: from localhost ([::1]:51803 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cHLs6-0002aj-5k for patchwork-qemu-devel@patchwork.kernel.org; Wed, 14 Dec 2016 21:34:14 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:41203) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cHLre-0002VL-L3 for qemu-devel@nongnu.org; Wed, 14 Dec 2016 21:33:47 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1cHLra-0004gZ-O6 for qemu-devel@nongnu.org; Wed, 14 Dec 2016 21:33:46 -0500 Received: from mail-oi0-f68.google.com ([209.85.218.68]:34268) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1cHLra-0004gL-JA for qemu-devel@nongnu.org; Wed, 14 Dec 2016 21:33:42 -0500 Received: by mail-oi0-f68.google.com with SMTP id m75so4818344oig.1 for ; Wed, 14 Dec 2016 18:33:42 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=message-id:from:to:cc:subject:date; bh=SYSmUcaY5mm81sgCeOwXV5vDXvgqrfCVYHMMSOTTHEA=; b=O/ik0kiAx5AZMO8ruSI0GT71ohR5YKLxZbOBYSVt61JWDMJq1kzrZeRZOPzmQkPGnl oi1ixB80ChDqI/Zd2ZeyLA+HQ5TH1RFaqzcPz0XKxJgtYIi9pmO4xfZOP8TNxG3eRbvC UsUcAi8+EwoE0Sdz7KOdQ/ct9SxQN7/AWoA48nOdB4zy4N1ZIRFPgNMnZ4qkXBfqEyGS /yTI0pNWLdd+WUcJ+UdItHCdYtBGGpM4lECRKS/1TCX6p0L+CkPiQYhu/oY7JzfHohv/ CiXhLhtBHEakRFT8gh/qzyWkHottshETuoG+JmVpG1DW3WuyBC/MYhoPaDUX/7OgMtgZ yU/w== 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=SYSmUcaY5mm81sgCeOwXV5vDXvgqrfCVYHMMSOTTHEA=; b=gN0+Y6w4EdEhCE6wJ1KSnLTBSWXS6gG41WLQH4nS6odRcWr/CqBIEWm4l9UlrmsSHl +IcK23rJacPSfSNeM7GolmXHi9b0P28EvC1dSf51U23JP/69fmpYImIFkBEroANsE5xy JYF8gKhpb7p+vhQgH90PyWu3mS3bXmVOH+KfINm7UDFb3r5YZadNFyKMGeCuHQleAGTv 3/7+b4hxlFlGRfY0FZfifHrAQo3iS3hraiCeHFY/xjW7mdrkfDLOtvaMGNRLt2PVCIUD 0lmMx2bL0jPNbRlITPP+0nl0P+xZwEeW7bCBaeACeWMa+9is0sn6Uso4zSfiyfQiAun+ uTbw== X-Gm-Message-State: AKaTC00UBnPsnm3Wax8W5Nb0Z3hLvLgrWWDdTKYTmLNr6GiD1WYbw9bn6wQ814iuHZNa8g== X-Received: by 10.202.188.196 with SMTP id m187mr55998315oif.210.1481769161641; Wed, 14 Dec 2016 18:32:41 -0800 (PST) Received: from localhost.localdomain.localdomain ([104.192.110.250]) by smtp.gmail.com with ESMTPSA id o41sm22131806oik.3.2016.12.14.18.32.37 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 14 Dec 2016 18:32:41 -0800 (PST) Message-ID: <585200c9.a968ca0a.1ab80.4c98@mx.google.com> X-Google-Original-Message-ID: <1481769142-5969-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, marcandre.lureau@gmail.com, qemu-devel@nongnu.org Date: Wed, 14 Dec 2016 18:32:22 -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.68 Subject: [Qemu-devel] [PATCH v3] 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 Reviewed-by: Marc-André Lureau --- Changes since the v2: take out of the null check Changes since the v1: close the streams hw/audio/es1370.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/hw/audio/es1370.c b/hw/audio/es1370.c index 8449b5f..883ec69 100644 --- a/hw/audio/es1370.c +++ b/hw/audio/es1370.c @@ -1041,6 +1041,19 @@ static void es1370_realize(PCIDevice *dev, Error **errp) es1370_reset (s); } +static void es1370_exit(PCIDevice *dev) +{ + ES1370State *s = ES1370(dev); + int i; + + for (i = 0; i < 2; ++i) { + AUD_close_out(&s->card, s->dac_voice[i]); + } + + AUD_close_in(&s->card, s->adc_voice); + AUD_remove_card(&s->card); +} + static int es1370_init (PCIBus *bus) { pci_create_simple (bus, -1, TYPE_ES1370); @@ -1053,6 +1066,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;