9ae3a8
From 8aa43c6e4e8def26812cb435b9f3c3146488e3bd Mon Sep 17 00:00:00 2001
9ae3a8
From: Markus Armbruster <armbru@redhat.com>
9ae3a8
Date: Thu, 16 Jan 2014 15:25:18 -0500
9ae3a8
Subject: [PATCH 12/14] hw: cannot_instantiate_with_device_add_yet due to
9ae3a8
 pointer props
9ae3a8
MIME-Version: 1.0
9ae3a8
Content-Type: text/plain; charset=UTF-8
9ae3a8
Content-Transfer-Encoding: 8bit
9ae3a8
9ae3a8
Message-id: <1389885919-16158-2-git-send-email-armbru@redhat.com>
9ae3a8
Patchwork-id: 56750
9ae3a8
O-Subject: [PATCH 7.0 qemu-kvm 1/2] hw: cannot_instantiate_with_device_add_yet due to pointer props
9ae3a8
Bugzilla: 1031098
9ae3a8
RH-Acked-by: Paolo Bonzini <pbonzini@redhat.com>
9ae3a8
RH-Acked-by: Laszlo Ersek <lersek@redhat.com>
9ae3a8
RH-Acked-by: Miroslav Rezanina <mrezanin@redhat.com>
9ae3a8
9ae3a8
Pointer properties can be set only by code, not by device_add.  A
9ae3a8
device with a pointer property can work with device_add only when the
9ae3a8
property may remain null.
9ae3a8
9ae3a8
This is the case for property "interrupt_vector" of device
9ae3a8
"etraxfs,pic".  Add a comment there.
9ae3a8
9ae3a8
Set cannot_instantiate_with_device_add_yet for the other devices with
9ae3a8
pointer properties, with a comment explaining why.
9ae3a8
9ae3a8
Juha Riihimäki and Peter Maydell deserve my thanks for making "pointer
9ae3a8
property must not remain null" blatantly obvious in the OMAP devices.
9ae3a8
9ae3a8
Only device "smbus-eeprom" is actually changed.  The others are all
9ae3a8
sysbus devices, which get cannot_instantiate_with_device_add_yet set
9ae3a8
in their abstract base's class init function.  Setting it again in
9ae3a8
their class init function is technically redundant, but serves as
9ae3a8
insurance for when sysbus devices become available with device_add,
9ae3a8
and as documentation.
9ae3a8
9ae3a8
Signed-off-by: Markus Armbruster <armbru@redhat.com>
9ae3a8
Reviewed-by: Edgar E. Iglesias <edgar.iglesias@gmail.com> (for ETRAX)
9ae3a8
Signed-off-by: Andreas Färber <afaerber@suse.de>
9ae3a8
(cherry picked from commit 1b111dc1216be2a89770fdc1ab3dfa8025957442)
9ae3a8
---
9ae3a8
 hw/audio/marvell_88w8618.c | 2 ++
9ae3a8
 hw/dma/sparc32_dma.c       | 2 ++
9ae3a8
 hw/gpio/omap_gpio.c        | 4 ++++
9ae3a8
 hw/i2c/omap_i2c.c          | 2 ++
9ae3a8
 hw/i2c/smbus_eeprom.c      | 2 ++
9ae3a8
 hw/intc/etraxfs_pic.c      | 4 ++++
9ae3a8
 hw/intc/grlib_irqmp.c      | 2 ++
9ae3a8
 hw/intc/omap_intc.c        | 4 ++++
9ae3a8
 hw/net/etraxfs_eth.c       | 2 ++
9ae3a8
 hw/net/lance.c             | 2 ++
9ae3a8
 10 files changed, 26 insertions(+)
9ae3a8
9ae3a8
Signed-off-by: Miroslav Rezanina <mrezanin@redhat.com>
9ae3a8
---
9ae3a8
 hw/audio/marvell_88w8618.c | 2 ++
9ae3a8
 hw/dma/sparc32_dma.c       | 2 ++
9ae3a8
 hw/gpio/omap_gpio.c        | 4 ++++
9ae3a8
 hw/i2c/omap_i2c.c          | 2 ++
9ae3a8
 hw/i2c/smbus_eeprom.c      | 2 ++
9ae3a8
 hw/intc/etraxfs_pic.c      | 4 ++++
9ae3a8
 hw/intc/grlib_irqmp.c      | 2 ++
9ae3a8
 hw/intc/omap_intc.c        | 4 ++++
9ae3a8
 hw/net/etraxfs_eth.c       | 2 ++
9ae3a8
 hw/net/lance.c             | 2 ++
9ae3a8
 10 files changed, 26 insertions(+)
9ae3a8
9ae3a8
diff --git a/hw/audio/marvell_88w8618.c b/hw/audio/marvell_88w8618.c
9ae3a8
index de06dfd..4f7196a 100644
9ae3a8
--- a/hw/audio/marvell_88w8618.c
9ae3a8
+++ b/hw/audio/marvell_88w8618.c
9ae3a8
@@ -285,6 +285,8 @@ static void mv88w8618_audio_class_init(ObjectClass *klass, void *data)
9ae3a8
     dc->reset = mv88w8618_audio_reset;
9ae3a8
     dc->vmsd = &mv88w8618_audio_vmsd;
9ae3a8
     dc->props = mv88w8618_audio_properties;
9ae3a8
+    /* Reason: pointer property "wm8750" */
9ae3a8
+    dc->cannot_instantiate_with_device_add_yet = true;
9ae3a8
 }
9ae3a8
 
9ae3a8
 static const TypeInfo mv88w8618_audio_info = {
9ae3a8
diff --git a/hw/dma/sparc32_dma.c b/hw/dma/sparc32_dma.c
9ae3a8
index fd21533..c866da7 100644
9ae3a8
--- a/hw/dma/sparc32_dma.c
9ae3a8
+++ b/hw/dma/sparc32_dma.c
9ae3a8
@@ -298,6 +298,8 @@ static void sparc32_dma_class_init(ObjectClass *klass, void *data)
9ae3a8
     dc->reset = dma_reset;
9ae3a8
     dc->vmsd = &vmstate_dma;
9ae3a8
     dc->props = sparc32_dma_properties;
9ae3a8
+    /* Reason: pointer property "iommu_opaque" */
9ae3a8
+    dc->cannot_instantiate_with_device_add_yet = true;
9ae3a8
 }
9ae3a8
 
9ae3a8
 static const TypeInfo sparc32_dma_info = {
9ae3a8
diff --git a/hw/gpio/omap_gpio.c b/hw/gpio/omap_gpio.c
9ae3a8
index f5eeaea..3f423dd 100644
9ae3a8
--- a/hw/gpio/omap_gpio.c
9ae3a8
+++ b/hw/gpio/omap_gpio.c
9ae3a8
@@ -745,6 +745,8 @@ static void omap_gpio_class_init(ObjectClass *klass, void *data)
9ae3a8
     k->init = omap_gpio_init;
9ae3a8
     dc->reset = omap_gpif_reset;
9ae3a8
     dc->props = omap_gpio_properties;
9ae3a8
+    /* Reason: pointer property "clk" */
9ae3a8
+    dc->cannot_instantiate_with_device_add_yet = true;
9ae3a8
 }
9ae3a8
 
9ae3a8
 static const TypeInfo omap_gpio_info = {
9ae3a8
@@ -774,6 +776,8 @@ static void omap2_gpio_class_init(ObjectClass *klass, void *data)
9ae3a8
     k->init = omap2_gpio_init;
9ae3a8
     dc->reset = omap2_gpif_reset;
9ae3a8
     dc->props = omap2_gpio_properties;
9ae3a8
+    /* Reason: pointer properties "iclk", "fclk0", ..., "fclk5" */
9ae3a8
+    dc->cannot_instantiate_with_device_add_yet = true;
9ae3a8
 }
9ae3a8
 
9ae3a8
 static const TypeInfo omap2_gpio_info = {
9ae3a8
diff --git a/hw/i2c/omap_i2c.c b/hw/i2c/omap_i2c.c
9ae3a8
index efb2254..464308e 100644
9ae3a8
--- a/hw/i2c/omap_i2c.c
9ae3a8
+++ b/hw/i2c/omap_i2c.c
9ae3a8
@@ -469,6 +469,8 @@ static void omap_i2c_class_init(ObjectClass *klass, void *data)
9ae3a8
     k->init = omap_i2c_init;
9ae3a8
     dc->props = omap_i2c_properties;
9ae3a8
     dc->reset = omap_i2c_reset;
9ae3a8
+    /* Reason: pointer properties "iclk", "fclk" */
9ae3a8
+    dc->cannot_instantiate_with_device_add_yet = true;
9ae3a8
 }
9ae3a8
 
9ae3a8
 static const TypeInfo omap_i2c_info = {
9ae3a8
diff --git a/hw/i2c/smbus_eeprom.c b/hw/i2c/smbus_eeprom.c
9ae3a8
index 0154283..0218f8a 100644
9ae3a8
--- a/hw/i2c/smbus_eeprom.c
9ae3a8
+++ b/hw/i2c/smbus_eeprom.c
9ae3a8
@@ -121,6 +121,8 @@ static void smbus_eeprom_class_initfn(ObjectClass *klass, void *data)
9ae3a8
     sc->write_data = eeprom_write_data;
9ae3a8
     sc->read_data = eeprom_read_data;
9ae3a8
     dc->props = smbus_eeprom_properties;
9ae3a8
+    /* Reason: pointer property "data" */
9ae3a8
+    dc->cannot_instantiate_with_device_add_yet = true;
9ae3a8
 }
9ae3a8
 
9ae3a8
 static const TypeInfo smbus_eeprom_info = {
9ae3a8
diff --git a/hw/intc/etraxfs_pic.c b/hw/intc/etraxfs_pic.c
9ae3a8
index 635103c..57650c4 100644
9ae3a8
--- a/hw/intc/etraxfs_pic.c
9ae3a8
+++ b/hw/intc/etraxfs_pic.c
9ae3a8
@@ -163,6 +163,10 @@ static void etraxfs_pic_class_init(ObjectClass *klass, void *data)
9ae3a8
 
9ae3a8
     k->init = etraxfs_pic_init;
9ae3a8
     dc->props = etraxfs_pic_properties;
9ae3a8
+    /*
9ae3a8
+     * Note: pointer property "interrupt_vector" may remain null, thus
9ae3a8
+     * no need for dc->cannot_instantiate_with_device_add_yet = true;
9ae3a8
+     */
9ae3a8
 }
9ae3a8
 
9ae3a8
 static const TypeInfo etraxfs_pic_info = {
9ae3a8
diff --git a/hw/intc/grlib_irqmp.c b/hw/intc/grlib_irqmp.c
9ae3a8
index 68dfe6a..1cfa960 100644
9ae3a8
--- a/hw/intc/grlib_irqmp.c
9ae3a8
+++ b/hw/intc/grlib_irqmp.c
9ae3a8
@@ -368,6 +368,8 @@ static void grlib_irqmp_class_init(ObjectClass *klass, void *data)
9ae3a8
     k->init = grlib_irqmp_init;
9ae3a8
     dc->reset = grlib_irqmp_reset;
9ae3a8
     dc->props = grlib_irqmp_properties;
9ae3a8
+    /* Reason: pointer properties "set_pil_in", "set_pil_in_opaque" */
9ae3a8
+    dc->cannot_instantiate_with_device_add_yet = true;
9ae3a8
 }
9ae3a8
 
9ae3a8
 static const TypeInfo grlib_irqmp_info = {
9ae3a8
diff --git a/hw/intc/omap_intc.c b/hw/intc/omap_intc.c
9ae3a8
index 875eba4..e846fd6 100644
9ae3a8
--- a/hw/intc/omap_intc.c
9ae3a8
+++ b/hw/intc/omap_intc.c
9ae3a8
@@ -387,6 +387,8 @@ static void omap_intc_class_init(ObjectClass *klass, void *data)
9ae3a8
     k->init = omap_intc_init;
9ae3a8
     dc->reset = omap_inth_reset;
9ae3a8
     dc->props = omap_intc_properties;
9ae3a8
+    /* Reason: pointer property "clk" */
9ae3a8
+    dc->cannot_instantiate_with_device_add_yet = true;
9ae3a8
 }
9ae3a8
 
9ae3a8
 static const TypeInfo omap_intc_info = {
9ae3a8
@@ -631,6 +633,8 @@ static void omap2_intc_class_init(ObjectClass *klass, void *data)
9ae3a8
     k->init = omap2_intc_init;
9ae3a8
     dc->reset = omap_inth_reset;
9ae3a8
     dc->props = omap2_intc_properties;
9ae3a8
+    /* Reason: pointer property "iclk", "fclk" */
9ae3a8
+    dc->cannot_instantiate_with_device_add_yet = true;
9ae3a8
 }
9ae3a8
 
9ae3a8
 static const TypeInfo omap2_intc_info = {
9ae3a8
diff --git a/hw/net/etraxfs_eth.c b/hw/net/etraxfs_eth.c
9ae3a8
index 1039913..374eb5a 100644
9ae3a8
--- a/hw/net/etraxfs_eth.c
9ae3a8
+++ b/hw/net/etraxfs_eth.c
9ae3a8
@@ -639,6 +639,8 @@ static void etraxfs_eth_class_init(ObjectClass *klass, void *data)
9ae3a8
 
9ae3a8
     k->init = fs_eth_init;
9ae3a8
     dc->props = etraxfs_eth_properties;
9ae3a8
+    /* Reason: pointer properties "dma_out", "dma_in" */
9ae3a8
+    dc->cannot_instantiate_with_device_add_yet = true;
9ae3a8
 }
9ae3a8
 
9ae3a8
 static const TypeInfo etraxfs_eth_info = {
9ae3a8
diff --git a/hw/net/lance.c b/hw/net/lance.c
9ae3a8
index 90641e7..df62dcb 100644
9ae3a8
--- a/hw/net/lance.c
9ae3a8
+++ b/hw/net/lance.c
9ae3a8
@@ -154,6 +154,8 @@ static void lance_class_init(ObjectClass *klass, void *data)
9ae3a8
     dc->reset = lance_reset;
9ae3a8
     dc->vmsd = &vmstate_lance;
9ae3a8
     dc->props = lance_properties;
9ae3a8
+    /* Reason: pointer property "dma" */
9ae3a8
+    dc->cannot_instantiate_with_device_add_yet = true;
9ae3a8
 }
9ae3a8
 
9ae3a8
 static const TypeInfo lance_info = {
9ae3a8
-- 
9ae3a8
1.8.3.1
9ae3a8