Skip to contentSkip to conversation

nios2: iic: Convert CPU prop to qom link

PATCH Superseded Marek Vasut 3 participants 6 messages Feb 27, 2017 – Mar 17, 2017

v2 of 3 Superseded Latest is v3 →

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 nios2: iic: Convert CPU prop to qom link

Add a const qom link between the CPU and the IIC instead of passing the CPU link through a qom property.

Cc Alexander Graf <[email protected]>
Cc Chris Wulff <[email protected]>
Cc Igor Mammedov <[email protected]>
Cc Jeff Da Silva <[email protected]>
Cc Ley Foon Tan <[email protected]>
Cc Markus Armbruster <[email protected]>
Cc Richard Henderson <[email protected]>
Cc Sandra Loosemore <[email protected]>
Cc Yves Vandervennet <[email protected]>

---
V2: Retain dc->cannot_instantiate_with_device_add_yet = true
in altera_iic_class_init() since the device is still not device_add() creatable.

---
 hw/intc/nios2_iic.c       | 12 ++++--------
 hw/nios2/10m50_devboard.c |  3 ++-
 2 files changed, 6 insertions(+), 9 deletions(-)
hw/intc/nios2_iic.c +4 -8
index 818ab1b315..fe15621202 100644
@@ -62,17 +62,15 @@ static void altera_iic_init(Object *obj)
     sysbus_init_irq(SYS_BUS_DEVICE(obj), &pv->parent_irq);
 }
 
-static Property altera_iic_properties[] = {
-    DEFINE_PROP_PTR("cpu", AlteraIIC, cpu),
-    DEFINE_PROP_END_OF_LIST(),
-};
-
 static void altera_iic_realize(DeviceState *dev, Error **errp)
 {
     struct AlteraIIC *pv = ALTERA_IIC(dev);
+    Error *err = NULL;
 
+    pv->cpu = object_property_get_link(OBJECT(dev), "cpu", &err);
     if (!pv->cpu) {
-        error_setg(errp, "altera,iic: CPU not connected");
+        error_setg(errp, "altera,iic: CPU link not found: %s",
+                   error_get_pretty(err));
         return;
     }
 }
@@ -81,8 +79,6 @@ static void altera_iic_class_init(ObjectClass *klass, void *data)
 {
     DeviceClass *dc = DEVICE_CLASS(klass);
 
-    dc->props = altera_iic_properties;
-    /* Reason: pointer property "cpu" */
     dc->cannot_instantiate_with_device_add_yet = true;
     dc->realize = altera_iic_realize;
 }
hw/nios2/10m50_devboard.c +2 -1
index 0d8b9aa58f..c18e0b2a17 100644
@@ -83,7 +83,8 @@ static void nios2_10m50_ghrd_init(MachineState *machine)
 
     /* Register: Internal Interrupt Controller (IIC) */
     dev = qdev_create(NULL, "altera,iic");
-    qdev_prop_set_ptr(dev, "cpu", cpu);
+    object_property_add_const_link(OBJECT(dev), "cpu", OBJECT(cpu),
+                                   &error_abort);
     qdev_init_nofail(dev);
     sysbus_connect_irq(SYS_BUS_DEVICE(dev), 0, cpu_irq[0]);
     for (i = 0; i < 32; i++) {
Signature · 1 line
2.11.0
#1 lore raw
Quoted 13 lines · Marek Vasut

Add a const qom link between the CPU and the IIC instead of passing the CPU link through a qom property.

Cc Alexander Graf <[email protected]>
Cc Chris Wulff <[email protected]>
Cc Igor Mammedov <[email protected]>
Cc Jeff Da Silva <[email protected]>
Cc Ley Foon Tan <[email protected]>
Cc Markus Armbruster <[email protected]>
Cc Richard Henderson <[email protected]>
Cc Sandra Loosemore <[email protected]>
Cc Yves Vandervennet <[email protected]>

Why is this patch not applied yet ?

Quoted 59 lines

---
V2: Retain dc->cannot_instantiate_with_device_add_yet = true
in altera_iic_class_init() since the device is still not device_add() creatable.

---
 hw/intc/nios2_iic.c       | 12 ++++--------
 hw/nios2/10m50_devboard.c |  3 ++-
 2 files changed, 6 insertions(+), 9 deletions(-)
hw/intc/nios2_iic.c +4 -8
index 818ab1b315..fe15621202 100644
@@ -62,17 +62,15 @@ static void altera_iic_init(Object *obj)
     sysbus_init_irq(SYS_BUS_DEVICE(obj), &pv->parent_irq);
 }
 
-static Property altera_iic_properties[] = {
-    DEFINE_PROP_PTR("cpu", AlteraIIC, cpu),
-    DEFINE_PROP_END_OF_LIST(),
-};
-
 static void altera_iic_realize(DeviceState *dev, Error **errp)
 {
     struct AlteraIIC *pv = ALTERA_IIC(dev);
+    Error *err = NULL;
 
+    pv->cpu = object_property_get_link(OBJECT(dev), "cpu", &err);
     if (!pv->cpu) {
-        error_setg(errp, "altera,iic: CPU not connected");
+        error_setg(errp, "altera,iic: CPU link not found: %s",
+                   error_get_pretty(err));
         return;
     }
 }
@@ -81,8 +79,6 @@ static void altera_iic_class_init(ObjectClass *klass, void *data)
 {
     DeviceClass *dc = DEVICE_CLASS(klass);
 
-    dc->props = altera_iic_properties;
-    /* Reason: pointer property "cpu" */
     dc->cannot_instantiate_with_device_add_yet = true;
     dc->realize = altera_iic_realize;
 }
hw/nios2/10m50_devboard.c +2 -1
index 0d8b9aa58f..c18e0b2a17 100644
@@ -83,7 +83,8 @@ static void nios2_10m50_ghrd_init(MachineState *machine)
 
     /* Register: Internal Interrupt Controller (IIC) */
     dev = qdev_create(NULL, "altera,iic");
-    qdev_prop_set_ptr(dev, "cpu", cpu);
+    object_property_add_const_link(OBJECT(dev), "cpu", OBJECT(cpu),
+                                   &error_abort);
     qdev_init_nofail(dev);
     sysbus_connect_irq(SYS_BUS_DEVICE(dev), 0, cpu_irq[0]);
     for (i = 0; i < 32; i++) {
Signature · 2 lines
Best regards,
Marek Vasut
#2 lore raw
In reply to Marek Vasut
Quoted 49 lines · Marek Vasut

Add a const qom link between the CPU and the IIC instead of passing the CPU link through a qom property.

Cc Alexander Graf <[email protected]>
Cc Chris Wulff <[email protected]>
Cc Igor Mammedov <[email protected]>
Cc Jeff Da Silva <[email protected]>
Cc Ley Foon Tan <[email protected]>
Cc Markus Armbruster <[email protected]>
Cc Richard Henderson <[email protected]>
Cc Sandra Loosemore <[email protected]>
Cc Yves Vandervennet <[email protected]>

---
V2: Retain dc->cannot_instantiate_with_device_add_yet = true
in altera_iic_class_init() since the device is still not device_add() creatable.

---
 hw/intc/nios2_iic.c       | 12 ++++--------
 hw/nios2/10m50_devboard.c |  3 ++-
 2 files changed, 6 insertions(+), 9 deletions(-)
hw/intc/nios2_iic.c +4 -6
index 818ab1b315..fe15621202 100644
@@ -62,17 +62,15 @@ static void altera_iic_init(Object *obj)
     sysbus_init_irq(SYS_BUS_DEVICE(obj), &pv->parent_irq);
 }
 
-static Property altera_iic_properties[] = {
-    DEFINE_PROP_PTR("cpu", AlteraIIC, cpu),
-    DEFINE_PROP_END_OF_LIST(),
-};
-
 static void altera_iic_realize(DeviceState *dev, Error **errp)
 {
     struct AlteraIIC *pv = ALTERA_IIC(dev);
+    Error *err = NULL;
 
+    pv->cpu = object_property_get_link(OBJECT(dev), "cpu", &err);
     if (!pv->cpu) {
-        error_setg(errp, "altera,iic: CPU not connected");
+        error_setg(errp, "altera,iic: CPU link not found: %s",
+                   error_get_pretty(err));
         return;
     }
 }

hw/intc/nios2_iic.c static void altera_iic_class_init(ObjectClass *klass, void *data) · line 85

Quoted 5 lines
hw/intc/nios2_iic.c +0 -2
@@ -81,8 +79,6 @@ static void altera_iic_class_init(ObjectClass *klass, void *data)
 {
     DeviceClass *dc = DEVICE_CLASS(klass);
 
-    dc->props = altera_iic_properties;
-    /* Reason: pointer property "cpu" */

This comment goes with the line below it:

hw/intc/nios2_iic.c static void altera_iic_class_init(ObjectClass *klass, void *data) · line 82

Quoted 1 line
hw/intc/nios2_iic.c +0 -0
     dc->cannot_instantiate_with_device_add_yet = true;

as it's explaining why we cannot instantiate with device add.

Either the cannot_instantiate assignment should go, or the comment needs to be updated to explain why we cannot-instantiate (since it's no longer because of a pointer property).

Quoted 17 lines
hw/intc/nios2_iic.c +0 -0
     dc->realize = altera_iic_realize;
 }
hw/nios2/10m50_devboard.c +2 -2
index 0d8b9aa58f..c18e0b2a17 100644
@@ -83,7 +83,8 @@ static void nios2_10m50_ghrd_init(MachineState *machine)
 
     /* Register: Internal Interrupt Controller (IIC) */
     dev = qdev_create(NULL, "altera,iic");
-    qdev_prop_set_ptr(dev, "cpu", cpu);
+    object_property_add_const_link(OBJECT(dev), "cpu", OBJECT(cpu),
+                                   &error_abort);
     qdev_init_nofail(dev);
     sysbus_connect_irq(SYS_BUS_DEVICE(dev), 0, cpu_irq[0]);
     for (i = 0; i < 32; i++) {
--
Quoted 1 line

2.11.0

thanks
-- PMM

#3 lore raw
Quoted 58 lines · Peter Maydell
Quoted 49 lines · Marek Vasut

Add a const qom link between the CPU and the IIC instead of passing the CPU link through a qom property.

Cc Alexander Graf <[email protected]>
Cc Chris Wulff <[email protected]>
Cc Igor Mammedov <[email protected]>
Cc Jeff Da Silva <[email protected]>
Cc Ley Foon Tan <[email protected]>
Cc Markus Armbruster <[email protected]>
Cc Richard Henderson <[email protected]>
Cc Sandra Loosemore <[email protected]>
Cc Yves Vandervennet <[email protected]>

---
V2: Retain dc->cannot_instantiate_with_device_add_yet = true
in altera_iic_class_init() since the device is still not device_add() creatable.

---
 hw/intc/nios2_iic.c       | 12 ++++--------
 hw/nios2/10m50_devboard.c |  3 ++-
 2 files changed, 6 insertions(+), 9 deletions(-)
hw/intc/nios2_iic.c +4 -6
index 818ab1b315..fe15621202 100644
@@ -62,17 +62,15 @@ static void altera_iic_init(Object *obj)
     sysbus_init_irq(SYS_BUS_DEVICE(obj), &pv->parent_irq);
 }
 
-static Property altera_iic_properties[] = {
-    DEFINE_PROP_PTR("cpu", AlteraIIC, cpu),
-    DEFINE_PROP_END_OF_LIST(),
-};
-
 static void altera_iic_realize(DeviceState *dev, Error **errp)
 {
     struct AlteraIIC *pv = ALTERA_IIC(dev);
+    Error *err = NULL;
 
+    pv->cpu = object_property_get_link(OBJECT(dev), "cpu", &err);
     if (!pv->cpu) {
-        error_setg(errp, "altera,iic: CPU not connected");
+        error_setg(errp, "altera,iic: CPU link not found: %s",
+                   error_get_pretty(err));
         return;
     }
 }

hw/intc/nios2_iic.c static void altera_iic_class_init(ObjectClass *klass, void *data) · line 85

Quoted 5 lines
hw/intc/nios2_iic.c +0 -2
@@ -81,8 +79,6 @@ static void altera_iic_class_init(ObjectClass *klass, void *data)
 {
     DeviceClass *dc = DEVICE_CLASS(klass);
 
-    dc->props = altera_iic_properties;
-    /* Reason: pointer property "cpu" */

This comment goes with the line below it:

Quoted 8 lines

hw/intc/nios2_iic.c static void altera_iic_class_init(ObjectClass *klass, void *data) · line 82

Quoted 1 line
hw/intc/nios2_iic.c +0 -0
     dc->cannot_instantiate_with_device_add_yet = true;

as it's explaining why we cannot instantiate with device add.

Either the cannot_instantiate assignment should go, or the comment needs to be updated to explain why we cannot-instantiate (since it's no longer because of a pointer property).

Fixed, will send V3 shortly, thanks.

Quoted 22 lines
Quoted 17 lines
hw/intc/nios2_iic.c +0 -0
     dc->realize = altera_iic_realize;
 }
hw/nios2/10m50_devboard.c +2 -2
index 0d8b9aa58f..c18e0b2a17 100644
@@ -83,7 +83,8 @@ static void nios2_10m50_ghrd_init(MachineState *machine)
 
     /* Register: Internal Interrupt Controller (IIC) */
     dev = qdev_create(NULL, "altera,iic");
-    qdev_prop_set_ptr(dev, "cpu", cpu);
+    object_property_add_const_link(OBJECT(dev), "cpu", OBJECT(cpu),
+                                   &error_abort);
     qdev_init_nofail(dev);
     sysbus_connect_irq(SYS_BUS_DEVICE(dev), 0, cpu_irq[0]);
     for (i = 0; i < 32; i++) {
--
Quoted 1 line

2.11.0

thanks
-- PMM

Signature · 2 lines
Best regards,
Marek Vasut
Reviewed-by on v2 1/1
#4 lore raw
In reply to Marek Vasut
Quoted 49 lines · Marek Vasut

Add a const qom link between the CPU and the IIC instead of passing the CPU link through a qom property.

Cc Alexander Graf <[email protected]>
Cc Chris Wulff <[email protected]>
Cc Igor Mammedov <[email protected]>
Cc Jeff Da Silva <[email protected]>
Cc Ley Foon Tan <[email protected]>
Cc Markus Armbruster <[email protected]>
Cc Richard Henderson <[email protected]>
Cc Sandra Loosemore <[email protected]>
Cc Yves Vandervennet <[email protected]>

---
V2: Retain dc->cannot_instantiate_with_device_add_yet = true
in altera_iic_class_init() since the device is still not device_add() creatable.

---
 hw/intc/nios2_iic.c       | 12 ++++--------
 hw/nios2/10m50_devboard.c |  3 ++-
 2 files changed, 6 insertions(+), 9 deletions(-)
hw/intc/nios2_iic.c +4 -6
index 818ab1b315..fe15621202 100644
@@ -62,17 +62,15 @@ static void altera_iic_init(Object *obj)
     sysbus_init_irq(SYS_BUS_DEVICE(obj), &pv->parent_irq);
 }
 
-static Property altera_iic_properties[] = {
-    DEFINE_PROP_PTR("cpu", AlteraIIC, cpu),
-    DEFINE_PROP_END_OF_LIST(),
-};
-
 static void altera_iic_realize(DeviceState *dev, Error **errp)
 {
     struct AlteraIIC *pv = ALTERA_IIC(dev);
+    Error *err = NULL;
 
+    pv->cpu = object_property_get_link(OBJECT(dev), "cpu", &err);
     if (!pv->cpu) {
-        error_setg(errp, "altera,iic: CPU not connected");
+        error_setg(errp, "altera,iic: CPU link not found: %s",
+                   error_get_pretty(err));
         return;
     }
 }

hw/intc/nios2_iic.c static void altera_iic_class_init(ObjectClass *klass, void *data) · line 85

Quoted 5 lines
hw/intc/nios2_iic.c +0 -2
@@ -81,8 +79,6 @@ static void altera_iic_class_init(ObjectClass *klass, void *data)
 {
     DeviceClass *dc = DEVICE_CLASS(klass);
 
-    dc->props = altera_iic_properties;
-    /* Reason: pointer property "cpu" */

You need to update, not delete this comment. I think

       /* Reason: needs to be wired up, e.g. by nios2_10m50_ghrd_init() */

would do.

Quoted 8 lines
hw/intc/nios2_iic.c +0 -0
     dc->cannot_instantiate_with_device_add_yet = true;
     dc->realize = altera_iic_realize;
 }
hw/nios2/10m50_devboard.c +0 -0
index 0d8b9aa58f..c18e0b2a17 100644

hw/nios2/10m50_devboard.c static void nios2_10m50_ghrd_init(MachineState *machine) · line 90

Quoted 9 lines
hw/nios2/10m50_devboard.c +2 -1
@@ -83,7 +83,8 @@ static void nios2_10m50_ghrd_init(MachineState *machine)
 
     /* Register: Internal Interrupt Controller (IIC) */
     dev = qdev_create(NULL, "altera,iic");
-    qdev_prop_set_ptr(dev, "cpu", cpu);
+    object_property_add_const_link(OBJECT(dev), "cpu", OBJECT(cpu),
+                                   &error_abort);
     qdev_init_nofail(dev);
     sysbus_connect_irq(SYS_BUS_DEVICE(dev), 0, cpu_irq[0]);
     for (i = 0; i < 32; i++) {

With a suitable comment next to dc->cannot_instantiate_with_device_add_yet = true:

#5 lore raw
Quoted 83 lines · Markus Armbruster
Quoted 49 lines · Marek Vasut

Add a const qom link between the CPU and the IIC instead of passing the CPU link through a qom property.

Cc Alexander Graf <[email protected]>
Cc Chris Wulff <[email protected]>
Cc Igor Mammedov <[email protected]>
Cc Jeff Da Silva <[email protected]>
Cc Ley Foon Tan <[email protected]>
Cc Markus Armbruster <[email protected]>
Cc Richard Henderson <[email protected]>
Cc Sandra Loosemore <[email protected]>
Cc Yves Vandervennet <[email protected]>

---
V2: Retain dc->cannot_instantiate_with_device_add_yet = true
in altera_iic_class_init() since the device is still not device_add() creatable.

---
 hw/intc/nios2_iic.c       | 12 ++++--------
 hw/nios2/10m50_devboard.c |  3 ++-
 2 files changed, 6 insertions(+), 9 deletions(-)
hw/intc/nios2_iic.c +4 -6
index 818ab1b315..fe15621202 100644
@@ -62,17 +62,15 @@ static void altera_iic_init(Object *obj)
     sysbus_init_irq(SYS_BUS_DEVICE(obj), &pv->parent_irq);
 }
 
-static Property altera_iic_properties[] = {
-    DEFINE_PROP_PTR("cpu", AlteraIIC, cpu),
-    DEFINE_PROP_END_OF_LIST(),
-};
-
 static void altera_iic_realize(DeviceState *dev, Error **errp)
 {
     struct AlteraIIC *pv = ALTERA_IIC(dev);
+    Error *err = NULL;
 
+    pv->cpu = object_property_get_link(OBJECT(dev), "cpu", &err);
     if (!pv->cpu) {
-        error_setg(errp, "altera,iic: CPU not connected");
+        error_setg(errp, "altera,iic: CPU link not found: %s",
+                   error_get_pretty(err));
         return;
     }
 }

hw/intc/nios2_iic.c static void altera_iic_class_init(ObjectClass *klass, void *data) · line 85

Quoted 5 lines
hw/intc/nios2_iic.c +0 -2
@@ -81,8 +79,6 @@ static void altera_iic_class_init(ObjectClass *klass, void *data)
 {
     DeviceClass *dc = DEVICE_CLASS(klass);
 
-    dc->props = altera_iic_properties;
-    /* Reason: pointer property "cpu" */

You need to update, not delete this comment. I think

       /* Reason: needs to be wired up, e.g. by nios2_10m50_ghrd_init() */

would do.

Quoted 8 lines
hw/intc/nios2_iic.c +0 -0
     dc->cannot_instantiate_with_device_add_yet = true;
     dc->realize = altera_iic_realize;
 }
hw/nios2/10m50_devboard.c +0 -0
index 0d8b9aa58f..c18e0b2a17 100644

hw/nios2/10m50_devboard.c static void nios2_10m50_ghrd_init(MachineState *machine) · line 90

Quoted 9 lines
hw/nios2/10m50_devboard.c +2 -1
@@ -83,7 +83,8 @@ static void nios2_10m50_ghrd_init(MachineState *machine)
 
     /* Register: Internal Interrupt Controller (IIC) */
     dev = qdev_create(NULL, "altera,iic");
-    qdev_prop_set_ptr(dev, "cpu", cpu);
+    object_property_add_const_link(OBJECT(dev), "cpu", OBJECT(cpu),
+                                   &error_abort);
     qdev_init_nofail(dev);
     sysbus_connect_irq(SYS_BUS_DEVICE(dev), 0, cpu_irq[0]);
     for (i = 0; i < 32; i++) {

With a suitable comment next to dc->cannot_instantiate_with_device_add_yet = true:

Quoted 2 lines

OK, done and added the R-B , thanks

Signature · 2 lines
Best regards,
Marek Vasut