From patchwork Thu Jun 6 05:34:08 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Peter Crosthwaite X-Patchwork-Id: 249275 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id C726D2C00B8 for ; Thu, 6 Jun 2013 15:35:13 +1000 (EST) Received: from localhost ([::1]:50455 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UkSqr-0001eE-0I for incoming@patchwork.ozlabs.org; Thu, 06 Jun 2013 01:35:09 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:60342) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UkSqc-0001e9-Tu for qemu-devel@nongnu.org; Thu, 06 Jun 2013 01:34:55 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1UkSqb-0004ta-7b for qemu-devel@nongnu.org; Thu, 06 Jun 2013 01:34:54 -0400 Received: from mail-pb0-x229.google.com ([2607:f8b0:400e:c01::229]:61759) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UkSqb-0004tS-1J for qemu-devel@nongnu.org; Thu, 06 Jun 2013 01:34:53 -0400 Received: by mail-pb0-f41.google.com with SMTP id rp2so2798066pbb.14 for ; Wed, 05 Jun 2013 22:34:52 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=sender:from:to:cc:subject:date:message-id:x-mailer :x-gm-message-state; bh=1HMTHCZGdXcPRfiN6iuVx59LojGjS7uxZaodc90Xojk=; b=nWz4SA6VOEVSDTw55GfvljSzK81D5MkbvEcG1XtTiwRvFsS6JJiG3xAxTLOnhYwOFo /xvts+gQ92gROlhKVAsZ6rOsTseSKngPhOKrPgH3HPvzaKPikgs2Bu2hAEucN/nl8WJB gxwosbLUM/95epMDH/OjnXWceTkljkRP9CQCsMrhOEnt1DNp07q2UQOE+GhNwLEY8kAm gZIlWoKmGTg4E/tWw2a8O6Kwfc0iXGKkdRYh+MCPAhhlBrlM+AMZ+SeSZy/sjV3JL6Xt TPtlleBSclfFgQrxQ78RwrqNodNz1beIX0A232fmGeSbC8SWoNLOho7gAYrwLuyMxrSN TE0g== X-Received: by 10.68.170.97 with SMTP id al1mr37487453pbc.0.1370496892175; Wed, 05 Jun 2013 22:34:52 -0700 (PDT) Received: from localhost ([203.126.243.116]) by mx.google.com with ESMTPSA id i16sm27234409pag.18.2013.06.05.22.34.48 for (version=TLSv1.1 cipher=RC4-SHA bits=128/128); Wed, 05 Jun 2013 22:34:51 -0700 (PDT) From: peter.crosthwaite@xilinx.com To: qemu-devel@nongnu.org Date: Thu, 6 Jun 2013 15:34:08 +1000 Message-Id: <54453b6aa8afa1a76b2ec1932f1d7fd25205d0bc.1370496582.git.peter.crosthwaite@xilinx.com> X-Mailer: git-send-email 1.8.3.rc1.44.gb387c77.dirty X-Gm-Message-State: ALoCoQkoIwWIDY5aG3fY/ebZXEnxX3nZKqpQ4xkNDb2Avltmvuo9m91tZWXMbLE9AelncbPAaDGA X-detected-operating-system: by eggs.gnu.org: Error: Malformed IPv6 address (bad octet value). X-Received-From: 2607:f8b0:400e:c01::229 Cc: edgar.iglesias@gmail.com, kraxel@redhat.com, afaerber@suse.de Subject: [Qemu-devel] [PATCH v2 1/2] audio/intel-hda: Fix Inheritance hierachy X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org From: Peter Crosthwaite The ich6 and ich9 variants either need to inherit one from the other, or both from a common base class, otherwise its not possible to create a QOM cast macro for use by the shared implementation functions. Went for option B, with a common base class. Signed-off-by: Peter Crosthwaite Reviewed-by: Andreas Färber Reviewed-by: Gerd Hoffmann --- Now tested (x86_64 q35 KVM) change since v1: add missing type registration for intel_hda_info hw/audio/intel-hda.c | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/hw/audio/intel-hda.c b/hw/audio/intel-hda.c index 1016af0..eac0cf3 100644 --- a/hw/audio/intel-hda.c +++ b/hw/audio/intel-hda.c @@ -189,6 +189,8 @@ struct IntelHDAState { uint32_t msi; }; +#define TYPE_INTEL_HDA_GENERIC "intel-hda-generic" + struct IntelHDAReg { const char *name; /* register name */ uint32_t size; /* size in bytes */ @@ -1232,7 +1234,7 @@ static Property intel_hda_properties[] = { DEFINE_PROP_END_OF_LIST(), }; -static void intel_hda_class_init_common(ObjectClass *klass) +static void intel_hda_class_init(ObjectClass *klass, void *data) { DeviceClass *dc = DEVICE_CLASS(klass); PCIDeviceClass *k = PCI_DEVICE_CLASS(klass); @@ -1251,7 +1253,6 @@ static void intel_hda_class_init_ich6(ObjectClass *klass, void *data) DeviceClass *dc = DEVICE_CLASS(klass); PCIDeviceClass *k = PCI_DEVICE_CLASS(klass); - intel_hda_class_init_common(klass); k->device_id = 0x2668; k->revision = 1; dc->desc = "Intel HD Audio Controller (ich6)"; @@ -1262,23 +1263,28 @@ static void intel_hda_class_init_ich9(ObjectClass *klass, void *data) DeviceClass *dc = DEVICE_CLASS(klass); PCIDeviceClass *k = PCI_DEVICE_CLASS(klass); - intel_hda_class_init_common(klass); k->device_id = 0x293e; k->revision = 3; dc->desc = "Intel HD Audio Controller (ich9)"; } -static const TypeInfo intel_hda_info_ich6 = { - .name = "intel-hda", +static const TypeInfo intel_hda_info = { + .name = TYPE_INTEL_HDA_GENERIC, .parent = TYPE_PCI_DEVICE, .instance_size = sizeof(IntelHDAState), + .class_init = intel_hda_class_init, + .abstract = true, +}; + +static const TypeInfo intel_hda_info_ich6 = { + .name = "intel-hda", + .parent = TYPE_INTEL_HDA_GENERIC, .class_init = intel_hda_class_init_ich6, }; static const TypeInfo intel_hda_info_ich9 = { .name = "ich9-intel-hda", - .parent = TYPE_PCI_DEVICE, - .instance_size = sizeof(IntelHDAState), + .parent = TYPE_INTEL_HDA_GENERIC, .class_init = intel_hda_class_init_ich9, }; @@ -1320,6 +1326,7 @@ static int intel_hda_and_codec_init(PCIBus *bus) static void intel_hda_register_types(void) { type_register_static(&hda_codec_bus_info); + type_register_static(&intel_hda_info); type_register_static(&intel_hda_info_ich6); type_register_static(&intel_hda_info_ich9); type_register_static(&hda_codec_device_type_info);