From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1MLZbc-0008L8-2D for qemu-devel@nongnu.org; Tue, 30 Jun 2009 05:26:24 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1MLZbU-0008Gq-Lf for qemu-devel@nongnu.org; Tue, 30 Jun 2009 05:26:20 -0400 Received: from [199.232.76.173] (port=57915 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1MLZbT-0008Fm-KU for qemu-devel@nongnu.org; Tue, 30 Jun 2009 05:26:15 -0400 Received: from mx2.redhat.com ([66.187.237.31]:44735) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1MLZbT-0001wk-5j for qemu-devel@nongnu.org; Tue, 30 Jun 2009 05:26:15 -0400 Received: from int-mx2.corp.redhat.com (int-mx2.corp.redhat.com [172.16.27.26]) by mx2.redhat.com (8.13.8/8.13.8) with ESMTP id n5U9QEHZ006068 for ; Tue, 30 Jun 2009 05:26:14 -0400 From: Gerd Hoffmann Date: Tue, 30 Jun 2009 11:26:01 +0200 Message-Id: <1246353962-32308-8-git-send-email-kraxel@redhat.com> In-Reply-To: <1246353962-32308-1-git-send-email-kraxel@redhat.com> References: <1246353962-32308-1-git-send-email-kraxel@redhat.com> Subject: [Qemu-devel] [PATCH 7/8] qdev: convert es1370. List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: Gerd Hoffmann Signed-off-by: Gerd Hoffmann --- hw/es1370.c | 41 ++++++++++++++++++++++------------------- 1 files changed, 22 insertions(+), 19 deletions(-) diff --git a/hw/es1370.c b/hw/es1370.c index f730766..9e860f9 100644 --- a/hw/es1370.c +++ b/hw/es1370.c @@ -1005,27 +1005,12 @@ static void es1370_on_reset (void *opaque) es1370_reset (s); } -int es1370_init (PCIBus *bus) +static void es1370_initfn(PCIDevice *dev) { - PCIES1370State *d; - ES1370State *s; - uint8_t *c; - - if (!bus) { - dolog ("No PCI bus\n"); - return -1; - } - - d = (PCIES1370State *) pci_register_device (bus, "ES1370", - sizeof (PCIES1370State), - -1, NULL, NULL); - - if (!d) { - AUD_log (NULL, "Failed to register PCI device for ES1370\n"); - return -1; - } + PCIES1370State *d = DO_UPCAST(PCIES1370State, dev, dev); + ES1370State *s = &d->es1370; + uint8_t *c = d->dev.config; - c = d->dev.config; pci_config_set_vendor_id (c, PCI_VENDOR_ID_ENSONIQ); pci_config_set_device_id (c, PCI_DEVICE_ID_ENSONIQ_ES1370); c[0x07] = 2 << 1; @@ -1059,5 +1044,23 @@ int es1370_init (PCIBus *bus) AUD_register_card ("es1370", &s->card); es1370_reset (s); +} + +int es1370_init (PCIBus *bus) +{ + pci_create_simple(bus, -1, "ES1370"); return 0; } + +static PCIDeviceInfo es1370_info = { + .qdev.name = "ES1370", + .qdev.size = sizeof(PCIES1370State), + .init = es1370_initfn, +}; + +static void es1370_register(void) +{ + pci_qdev_register(&es1370_info); +} +device_init(es1370_register); + -- 1.6.2.5