diff mbox series

[4/9] hw/arm/bcm2386: Fix parent type of bcm2386

Message ID 20180313153458.26822-5-peter.maydell@linaro.org
State Superseded
Headers show
Series raspi3: various fixes for Linux booting | expand

Commit Message

Peter Maydell March 13, 2018, 3:34 p.m. UTC
The TypeInfo and state struct for bcm2386 disagree about what the
parent class is -- the TypeInfo says it's TYPE_SYS_BUS_DEVICE,
but the BCM2386State struct only defines the parent_obj field
as DeviceState. This would have caused problems if anything
actually tried to treat the object as a TYPE_SYS_BUS_DEVICE.
Fix the TypeInfo to use TYPE_DEVICE as the parent, since we don't
need any of the additional functionality TYPE_SYS_BUS_DEVICE
provides.

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>

---
I noticed this when I tried to make the type into one which
has its own class struct, because we hit the assert that the
child's class struct had better be bigger than the parent's.
---
 hw/arm/bcm2836.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

-- 
2.16.2

Comments

Andrew Baumann March 13, 2018, 4:40 p.m. UTC | #1
> From: Qemu-devel <qemu-devel-

> bounces+andrew.baumann=microsoft.com@nongnu.org> On Behalf Of Peter

> Maydell

> Sent: Tuesday, 13 March 2018 08:35

> 

> The TypeInfo and state struct for bcm2386 disagree about what the

> parent class is -- the TypeInfo says it's TYPE_SYS_BUS_DEVICE,

> but the BCM2386State struct only defines the parent_obj field

> as DeviceState. This would have caused problems if anything

> actually tried to treat the object as a TYPE_SYS_BUS_DEVICE.

> Fix the TypeInfo to use TYPE_DEVICE as the parent, since we don't

> need any of the additional functionality TYPE_SYS_BUS_DEVICE

> provides.

> 

> Signed-off-by: Peter Maydell <peter.maydell@linaro.org>

> ---

> I noticed this when I tried to make the type into one which

> has its own class struct, because we hit the assert that the

> child's class struct had better be bigger than the parent's.

> ---

>  hw/arm/bcm2836.c | 2 +-

>  1 file changed, 1 insertion(+), 1 deletion(-)

> 

> diff --git a/hw/arm/bcm2836.c b/hw/arm/bcm2836.c

> index 40e8b25a46..9266f27c14 100644

> --- a/hw/arm/bcm2836.c

> +++ b/hw/arm/bcm2836.c

> @@ -165,7 +165,7 @@ static void bcm2836_class_init(ObjectClass *oc, void

> *data)

> 

>  static const TypeInfo bcm2836_type_info = {

>      .name = TYPE_BCM2836,

> -    .parent = TYPE_SYS_BUS_DEVICE,

> +    .parent = TYPE_DEVICE,

>      .instance_size = sizeof(BCM2836State),

>      .instance_init = bcm2836_init,

>      .class_init = bcm2836_class_init,


Reviewed-by: Andrew Baumann <Andrew.Baumann@microsoft.com>


Thanks for catching this -- it looks like bcm2835.c (which never got merged) has the same bug, and I copied it along.
Philippe Mathieu-Daudé March 13, 2018, 11:04 p.m. UTC | #2
On 03/13/2018 04:34 PM, Peter Maydell wrote:
> The TypeInfo and state struct for bcm2386 disagree about what the

> parent class is -- the TypeInfo says it's TYPE_SYS_BUS_DEVICE,

> but the BCM2386State struct only defines the parent_obj field

> as DeviceState. This would have caused problems if anything

> actually tried to treat the object as a TYPE_SYS_BUS_DEVICE.

> Fix the TypeInfo to use TYPE_DEVICE as the parent, since we don't

> need any of the additional functionality TYPE_SYS_BUS_DEVICE

> provides.


I once wondered if we can dump the whole devices hierarchy (xml format)
and check consistency, or generate hyperlink doc and graph for the wiki...

> 

> Signed-off-by: Peter Maydell <peter.maydell@linaro.org>


Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>


> ---

> I noticed this when I tried to make the type into one which

> has its own class struct, because we hit the assert that the

> child's class struct had better be bigger than the parent's.


Yeah once you understand this obscure assert(), it is VERY useful.

> ---

>  hw/arm/bcm2836.c | 2 +-

>  1 file changed, 1 insertion(+), 1 deletion(-)

> 

> diff --git a/hw/arm/bcm2836.c b/hw/arm/bcm2836.c

> index 40e8b25a46..9266f27c14 100644

> --- a/hw/arm/bcm2836.c

> +++ b/hw/arm/bcm2836.c

> @@ -165,7 +165,7 @@ static void bcm2836_class_init(ObjectClass *oc, void *data)

>  

>  static const TypeInfo bcm2836_type_info = {

>      .name = TYPE_BCM2836,

> -    .parent = TYPE_SYS_BUS_DEVICE,

> +    .parent = TYPE_DEVICE,

>      .instance_size = sizeof(BCM2836State),

>      .instance_init = bcm2836_init,

>      .class_init = bcm2836_class_init,

>
diff mbox series

Patch

diff --git a/hw/arm/bcm2836.c b/hw/arm/bcm2836.c
index 40e8b25a46..9266f27c14 100644
--- a/hw/arm/bcm2836.c
+++ b/hw/arm/bcm2836.c
@@ -165,7 +165,7 @@  static void bcm2836_class_init(ObjectClass *oc, void *data)
 
 static const TypeInfo bcm2836_type_info = {
     .name = TYPE_BCM2836,
-    .parent = TYPE_SYS_BUS_DEVICE,
+    .parent = TYPE_DEVICE,
     .instance_size = sizeof(BCM2836State),
     .instance_init = bcm2836_init,
     .class_init = bcm2836_class_init,