From patchwork Fri May 24 06:23:58 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Crosthwaite X-Patchwork-Id: 246079 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 5D43D2C016F for ; Fri, 24 May 2013 16:28:01 +1000 (EST) Received: from localhost ([::1]:43522 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UflTr-0003ew-Bb for incoming@patchwork.ozlabs.org; Fri, 24 May 2013 02:27:59 -0400 Received: from eggs.gnu.org ([208.118.235.92]:56508) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UflTY-0003eK-5B for qemu-devel@nongnu.org; Fri, 24 May 2013 02:27:42 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1UflTW-0005s1-3r for qemu-devel@nongnu.org; Fri, 24 May 2013 02:27:40 -0400 Received: from mail-pd0-f175.google.com ([209.85.192.175]:33569) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UflTV-0005rt-U7 for qemu-devel@nongnu.org; Fri, 24 May 2013 02:27:38 -0400 Received: by mail-pd0-f175.google.com with SMTP id 6so3407028pdd.6 for ; Thu, 23 May 2013 23:27:37 -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=aG2h8WsWDBW0A8a74+q+APTItqCkP7DH5FZRRUlaJ+M=; b=oikpTGlrcmwPhx1dd1L7C8vepYsf40dPAJ+/wm1DmsX5uje994D6IbFH36/Qh4q6bB igDHCNy3cEK2tveALrRyHXXwJRaqD+DOZUpC8AFrRAU4dR1v8zhPqoh5VY10+e52Fx+t LOJJKEKli3v+c3+ph1CZYXKBrgwkRB7m4tSBVcz2BHkZ9qmJPnNuaKcJQT6HvA2LSLp2 ecgET1ZNg9QE2JOljPPhqQrV5J2PsOGC+3NQDS5J4lX0nCoux8w2vFXGECFkGTh69sPJ z9+9AcCGxwG5wLRZc73fb2kukzmeZKyLEXuCxBlruq2YSNWzrrr3ELnl84vcc/hvWzX/ ZvrQ== X-Received: by 10.66.121.132 with SMTP id lk4mr17111756pab.1.1369376857135; Thu, 23 May 2013 23:27:37 -0700 (PDT) Received: from localhost ([203.126.243.116]) by mx.google.com with ESMTPSA id kv2sm14912606pbc.28.2013.05.23.23.27.33 for (version=TLSv1.1 cipher=RC4-SHA bits=128/128); Thu, 23 May 2013 23:27:36 -0700 (PDT) From: peter.crosthwaite@xilinx.com To: qemu-devel@nongnu.org Date: Fri, 24 May 2013 16:23:58 +1000 Message-Id: X-Mailer: git-send-email 1.8.3.rc1.44.gb387c77.dirty X-Gm-Message-State: ALoCoQk4olBRYwlslZQgp9TCNR8GUQEBahq/V4Mvt43KYfU0eL9rTOZRFJCrQC10U3swvG6/CxsY X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.85.192.175 Cc: edgar.iglesias@gmail.com, av1474@comtv.ru, afaerber@suse.de Subject: [Qemu-devel] [RFC/RFT PATCH v1 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 --- hw/audio/intel-hda.c | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/hw/audio/intel-hda.c b/hw/audio/intel-hda.c index 1016af0..8a34337 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, };