qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [Qemu-devel] [PATCH v2 1/2] audio/intel-hda: Fix Inheritance hierachy
@ 2013-06-06  5:34 peter.crosthwaite
  2013-06-06  5:34 ` [Qemu-devel] [PATCH v2 2/2] audio/intel-hda: QOM casting sweep peter.crosthwaite
                   ` (3 more replies)
  0 siblings, 4 replies; 7+ messages in thread
From: peter.crosthwaite @ 2013-06-06  5:34 UTC (permalink / raw)
  To: qemu-devel; +Cc: edgar.iglesias, kraxel, afaerber

From: Peter Crosthwaite <peter.crosthwaite@xilinx.com>

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 <peter.crosthwaite@xilinx.com>
---
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);
-- 
1.8.3.rc1.44.gb387c77.dirty

^ permalink raw reply related	[flat|nested] 7+ messages in thread

* [Qemu-devel] [PATCH v2 2/2] audio/intel-hda: QOM casting sweep
  2013-06-06  5:34 [Qemu-devel] [PATCH v2 1/2] audio/intel-hda: Fix Inheritance hierachy peter.crosthwaite
@ 2013-06-06  5:34 ` peter.crosthwaite
  2013-06-06 11:47   ` Andreas Färber
  2013-06-06 13:49   ` Gerd Hoffmann
  2013-06-06 11:47 ` [Qemu-devel] [PATCH v2 1/2] audio/intel-hda: Fix Inheritance hierachy Andreas Färber
                   ` (2 subsequent siblings)
  3 siblings, 2 replies; 7+ messages in thread
From: peter.crosthwaite @ 2013-06-06  5:34 UTC (permalink / raw)
  To: qemu-devel; +Cc: edgar.iglesias, kraxel, afaerber

From: Peter Crosthwaite <peter.crosthwaite@xilinx.com>

Define and use standard QOM cast macro. Remove usages of DO_UPCAST and
direct -> style casting.

Signed-off-by: Peter Crosthwaite <peter.crosthwaite@xilinx.com>
---

 hw/audio/intel-hda.c | 19 +++++++++++--------
 1 file changed, 11 insertions(+), 8 deletions(-)

diff --git a/hw/audio/intel-hda.c b/hw/audio/intel-hda.c
index eac0cf3..3ac90d5 100644
--- a/hw/audio/intel-hda.c
+++ b/hw/audio/intel-hda.c
@@ -191,6 +191,9 @@ struct IntelHDAState {
 
 #define TYPE_INTEL_HDA_GENERIC "intel-hda-generic"
 
+#define INTEL_HDA(obj) \
+    OBJECT_CHECK(IntelHDAState, (obj), TYPE_INTEL_HDA_GENERIC)
+
 struct IntelHDAReg {
     const char *name;      /* register name */
     uint32_t   size;       /* size in bytes */
@@ -500,7 +503,7 @@ static void intel_hda_notify_codecs(IntelHDAState *d, uint32_t stream, bool runn
 static void intel_hda_set_g_ctl(IntelHDAState *d, const IntelHDAReg *reg, uint32_t old)
 {
     if ((d->g_ctl & ICH6_GCTL_RESET) == 0) {
-        intel_hda_reset(&d->pci.qdev);
+        intel_hda_reset(DEVICE(d));
     }
 }
 
@@ -1104,7 +1107,7 @@ static const MemoryRegionOps intel_hda_mmio_ops = {
 static void intel_hda_reset(DeviceState *dev)
 {
     BusChild *kid;
-    IntelHDAState *d = DO_UPCAST(IntelHDAState, pci.qdev, dev);
+    IntelHDAState *d = INTEL_HDA(dev);
     HDACodecDevice *cdev;
 
     intel_hda_regs_reset(d);
@@ -1122,7 +1125,7 @@ static void intel_hda_reset(DeviceState *dev)
 
 static int intel_hda_init(PCIDevice *pci)
 {
-    IntelHDAState *d = DO_UPCAST(IntelHDAState, pci, pci);
+    IntelHDAState *d = INTEL_HDA(pci);
     uint8_t *conf = d->pci.config;
 
     d->name = object_get_typename(OBJECT(d));
@@ -1139,7 +1142,7 @@ static int intel_hda_init(PCIDevice *pci)
         msi_init(&d->pci, 0x50, 1, true, false);
     }
 
-    hda_codec_bus_init(&d->pci.qdev, &d->codecs,
+    hda_codec_bus_init(DEVICE(pci), &d->codecs,
                        intel_hda_response, intel_hda_xfer);
 
     return 0;
@@ -1147,7 +1150,7 @@ static int intel_hda_init(PCIDevice *pci)
 
 static void intel_hda_exit(PCIDevice *pci)
 {
-    IntelHDAState *d = DO_UPCAST(IntelHDAState, pci, pci);
+    IntelHDAState *d = INTEL_HDA(pci);
 
     msi_uninit(&d->pci);
     memory_region_destroy(&d->mmio);
@@ -1312,12 +1315,12 @@ static const TypeInfo hda_codec_device_type_info = {
  */
 static int intel_hda_and_codec_init(PCIBus *bus)
 {
-    PCIDevice *controller;
+    DeviceState *controller;
     BusState *hdabus;
     DeviceState *codec;
 
-    controller = pci_create_simple(bus, -1, "intel-hda");
-    hdabus = QLIST_FIRST(&controller->qdev.child_bus);
+    controller = DEVICE(pci_create_simple(bus, -1, "intel-hda"));
+    hdabus = QLIST_FIRST(&controller->child_bus);
     codec = qdev_create(hdabus, "hda-duplex");
     qdev_init_nofail(codec);
     return 0;
-- 
1.8.3.rc1.44.gb387c77.dirty

^ permalink raw reply related	[flat|nested] 7+ messages in thread

* Re: [Qemu-devel] [PATCH v2 1/2] audio/intel-hda: Fix Inheritance hierachy
  2013-06-06  5:34 [Qemu-devel] [PATCH v2 1/2] audio/intel-hda: Fix Inheritance hierachy peter.crosthwaite
  2013-06-06  5:34 ` [Qemu-devel] [PATCH v2 2/2] audio/intel-hda: QOM casting sweep peter.crosthwaite
@ 2013-06-06 11:47 ` Andreas Färber
  2013-06-06 13:49 ` Gerd Hoffmann
  2013-06-17 21:06 ` Anthony Liguori
  3 siblings, 0 replies; 7+ messages in thread
From: Andreas Färber @ 2013-06-06 11:47 UTC (permalink / raw)
  To: peter.crosthwaite; +Cc: edgar.iglesias, qemu-devel, kraxel

Am 06.06.2013 07:34, schrieb peter.crosthwaite@xilinx.com:
> From: Peter Crosthwaite <peter.crosthwaite@xilinx.com>
> 
> 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 <peter.crosthwaite@xilinx.com>

Looks fine,

Reviewed-by: Andreas Färber <afaerber@suse.de>

Andreas

-- 
SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 Nürnberg, Germany
GF: Jeff Hawn, Jennifer Guild, Felix Imendörffer; HRB 16746 AG Nürnberg

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [Qemu-devel] [PATCH v2 2/2] audio/intel-hda: QOM casting sweep
  2013-06-06  5:34 ` [Qemu-devel] [PATCH v2 2/2] audio/intel-hda: QOM casting sweep peter.crosthwaite
@ 2013-06-06 11:47   ` Andreas Färber
  2013-06-06 13:49   ` Gerd Hoffmann
  1 sibling, 0 replies; 7+ messages in thread
From: Andreas Färber @ 2013-06-06 11:47 UTC (permalink / raw)
  To: peter.crosthwaite; +Cc: edgar.iglesias, qemu-devel, kraxel

Am 06.06.2013 07:34, schrieb peter.crosthwaite@xilinx.com:
> From: Peter Crosthwaite <peter.crosthwaite@xilinx.com>
> 
> Define and use standard QOM cast macro. Remove usages of DO_UPCAST and
> direct -> style casting.
> 
> Signed-off-by: Peter Crosthwaite <peter.crosthwaite@xilinx.com>

Reviewed-by: Andreas Färber <afaerber@suse.de>

Thanks,
Andreas

-- 
SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 Nürnberg, Germany
GF: Jeff Hawn, Jennifer Guild, Felix Imendörffer; HRB 16746 AG Nürnberg

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [Qemu-devel] [PATCH v2 1/2] audio/intel-hda: Fix Inheritance hierachy
  2013-06-06  5:34 [Qemu-devel] [PATCH v2 1/2] audio/intel-hda: Fix Inheritance hierachy peter.crosthwaite
  2013-06-06  5:34 ` [Qemu-devel] [PATCH v2 2/2] audio/intel-hda: QOM casting sweep peter.crosthwaite
  2013-06-06 11:47 ` [Qemu-devel] [PATCH v2 1/2] audio/intel-hda: Fix Inheritance hierachy Andreas Färber
@ 2013-06-06 13:49 ` Gerd Hoffmann
  2013-06-17 21:06 ` Anthony Liguori
  3 siblings, 0 replies; 7+ messages in thread
From: Gerd Hoffmann @ 2013-06-06 13:49 UTC (permalink / raw)
  To: peter.crosthwaite; +Cc: edgar.iglesias, qemu-devel, afaerber

On 06/06/13 07:34, peter.crosthwaite@xilinx.com wrote:
> From: Peter Crosthwaite <peter.crosthwaite@xilinx.com>
> 
> 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 <peter.crosthwaite@xilinx.com>

Reviewed-by: Gerd Hoffmann <kraxel@redhat.com>

cheers,
  Gerd

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [Qemu-devel] [PATCH v2 2/2] audio/intel-hda: QOM casting sweep
  2013-06-06  5:34 ` [Qemu-devel] [PATCH v2 2/2] audio/intel-hda: QOM casting sweep peter.crosthwaite
  2013-06-06 11:47   ` Andreas Färber
@ 2013-06-06 13:49   ` Gerd Hoffmann
  1 sibling, 0 replies; 7+ messages in thread
From: Gerd Hoffmann @ 2013-06-06 13:49 UTC (permalink / raw)
  To: peter.crosthwaite; +Cc: edgar.iglesias, qemu-devel, afaerber

On 06/06/13 07:34, peter.crosthwaite@xilinx.com wrote:
> From: Peter Crosthwaite <peter.crosthwaite@xilinx.com>
> 
> Define and use standard QOM cast macro. Remove usages of DO_UPCAST and
> direct -> style casting.
> 
> Signed-off-by: Peter Crosthwaite <peter.crosthwaite@xilinx.com>

Reviewed-by: Gerd Hoffmann <kraxel@redhat.com>

cheers,
  Gerd

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [Qemu-devel] [PATCH v2 1/2] audio/intel-hda: Fix Inheritance hierachy
  2013-06-06  5:34 [Qemu-devel] [PATCH v2 1/2] audio/intel-hda: Fix Inheritance hierachy peter.crosthwaite
                   ` (2 preceding siblings ...)
  2013-06-06 13:49 ` Gerd Hoffmann
@ 2013-06-17 21:06 ` Anthony Liguori
  3 siblings, 0 replies; 7+ messages in thread
From: Anthony Liguori @ 2013-06-17 21:06 UTC (permalink / raw)
  To: peter.crosthwaite, qemu-devel; +Cc: edgar.iglesias, kraxel, afaerber

Applied.  Thanks.

Regards,

Anthony Liguori

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2013-06-17 21:07 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-06-06  5:34 [Qemu-devel] [PATCH v2 1/2] audio/intel-hda: Fix Inheritance hierachy peter.crosthwaite
2013-06-06  5:34 ` [Qemu-devel] [PATCH v2 2/2] audio/intel-hda: QOM casting sweep peter.crosthwaite
2013-06-06 11:47   ` Andreas Färber
2013-06-06 13:49   ` Gerd Hoffmann
2013-06-06 11:47 ` [Qemu-devel] [PATCH v2 1/2] audio/intel-hda: Fix Inheritance hierachy Andreas Färber
2013-06-06 13:49 ` Gerd Hoffmann
2013-06-17 21:06 ` Anthony Liguori

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).