Message ID | 20230203211623.50930-5-philmd@linaro.org |
---|---|
State | New |
Headers | show |
Series | hw/ppc: Set QDev properties using QDev API (part 2/3) | expand |
On 2/3/23 18:16, Philippe Mathieu-Daudé wrote: > No need to use the low-level QOM API when an object > inherits from QDev. Directly use the QDev API to set > its properties. > > All calls use either errp=&error_abort or &error_fatal, > so converting to the QDev API is almost a no-op (QDev > API always uses &error_abort). > > Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org> > --- Reviewed-by: Daniel Henrique Barboza <danielhb413@gmail.com> > hw/intc/spapr_xive.c | 11 ++++------- > hw/intc/xics.c | 4 ++-- > hw/intc/xive.c | 4 ++-- > hw/ppc/spapr_irq.c | 8 +++----- > 4 files changed, 11 insertions(+), 16 deletions(-) > > diff --git a/hw/intc/spapr_xive.c b/hw/intc/spapr_xive.c > index dc641cc604..213c4cac44 100644 > --- a/hw/intc/spapr_xive.c > +++ b/hw/intc/spapr_xive.c > @@ -310,9 +310,8 @@ static void spapr_xive_realize(DeviceState *dev, Error **errp) > /* > * Initialize the internal sources, for IPIs and virtual devices. > */ > - object_property_set_int(OBJECT(xsrc), "nr-irqs", xive->nr_irqs, > - &error_fatal); > - object_property_set_link(OBJECT(xsrc), "xive", OBJECT(xive), &error_abort); > + qdev_prop_set_uint32(DEVICE(xsrc), "nr-irqs", xive->nr_irqs); > + qdev_prop_set_link(DEVICE(xsrc), "xive", OBJECT(xive)); > if (!qdev_realize(DEVICE(xsrc), NULL, errp)) { > return; > } > @@ -321,10 +320,8 @@ static void spapr_xive_realize(DeviceState *dev, Error **errp) > /* > * Initialize the END ESB source > */ > - object_property_set_int(OBJECT(end_xsrc), "nr-ends", xive->nr_irqs, > - &error_fatal); > - object_property_set_link(OBJECT(end_xsrc), "xive", OBJECT(xive), > - &error_abort); > + qdev_prop_set_uint32(DEVICE(end_xsrc), "nr-ends", xive->nr_irqs); > + qdev_prop_set_link(DEVICE(end_xsrc), "xive", OBJECT(xive)); > if (!qdev_realize(DEVICE(end_xsrc), NULL, errp)) { > return; > } > diff --git a/hw/intc/xics.c b/hw/intc/xics.c > index c7f8abd71e..2fd1a15153 100644 > --- a/hw/intc/xics.c > +++ b/hw/intc/xics.c > @@ -382,8 +382,8 @@ Object *icp_create(Object *cpu, const char *type, XICSFabric *xi, Error **errp) > obj = object_new(type); > object_property_add_child(cpu, type, obj); > object_unref(obj); > - object_property_set_link(obj, ICP_PROP_XICS, OBJECT(xi), &error_abort); > - object_property_set_link(obj, ICP_PROP_CPU, cpu, &error_abort); > + qdev_prop_set_link(DEVICE(obj), ICP_PROP_XICS, OBJECT(xi)); > + qdev_prop_set_link(DEVICE(obj), ICP_PROP_CPU, cpu); > if (!qdev_realize(DEVICE(obj), NULL, errp)) { > object_unparent(obj); > obj = NULL; > diff --git a/hw/intc/xive.c b/hw/intc/xive.c > index a986b96843..0e34035bc6 100644 > --- a/hw/intc/xive.c > +++ b/hw/intc/xive.c > @@ -799,8 +799,8 @@ Object *xive_tctx_create(Object *cpu, XivePresenter *xptr, Error **errp) > obj = object_new(TYPE_XIVE_TCTX); > object_property_add_child(cpu, TYPE_XIVE_TCTX, obj); > object_unref(obj); > - object_property_set_link(obj, "cpu", cpu, &error_abort); > - object_property_set_link(obj, "presenter", OBJECT(xptr), &error_abort); > + qdev_prop_set_link(DEVICE(obj), "cpu", cpu); > + qdev_prop_set_link(DEVICE(obj), "presenter", OBJECT(xptr)); > if (!qdev_realize(DEVICE(obj), NULL, errp)) { > object_unparent(obj); > return NULL; > diff --git a/hw/ppc/spapr_irq.c b/hw/ppc/spapr_irq.c > index a0d1e1298e..283769c074 100644 > --- a/hw/ppc/spapr_irq.c > +++ b/hw/ppc/spapr_irq.c > @@ -313,9 +313,8 @@ void spapr_irq_init(SpaprMachineState *spapr, Error **errp) > obj = object_new(TYPE_ICS_SPAPR); > > object_property_add_child(OBJECT(spapr), "ics", obj); > - object_property_set_link(obj, ICS_PROP_XICS, OBJECT(spapr), > - &error_abort); > - object_property_set_int(obj, "nr-irqs", smc->nr_xirqs, &error_abort); > + qdev_prop_set_link(DEVICE(obj), ICS_PROP_XICS, OBJECT(spapr)); > + qdev_prop_set_uint32(DEVICE(obj), "nr-irqs", smc->nr_xirqs); > if (!qdev_realize(DEVICE(obj), NULL, errp)) { > return; > } > @@ -335,8 +334,7 @@ void spapr_irq_init(SpaprMachineState *spapr, Error **errp) > * priority > */ > qdev_prop_set_uint32(dev, "nr-ends", nr_servers << 3); > - object_property_set_link(OBJECT(dev), "xive-fabric", OBJECT(spapr), > - &error_abort); > + qdev_prop_set_link(dev, "xive-fabric", OBJECT(spapr)); > sysbus_realize_and_unref(SYS_BUS_DEVICE(dev), &error_fatal); > > spapr->xive = SPAPR_XIVE(dev);
On 2/3/23 22:16, Philippe Mathieu-Daudé wrote: > No need to use the low-level QOM API when an object > inherits from QDev. Directly use the QDev API to set > its properties. > > All calls use either errp=&error_abort or &error_fatal, > so converting to the QDev API is almost a no-op (QDev > API always uses &error_abort). > > Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org> Reviewed-by: Cédric Le Goater <clg@kaod.org> Thanks, C. > --- > hw/intc/spapr_xive.c | 11 ++++------- > hw/intc/xics.c | 4 ++-- > hw/intc/xive.c | 4 ++-- > hw/ppc/spapr_irq.c | 8 +++----- > 4 files changed, 11 insertions(+), 16 deletions(-) > > diff --git a/hw/intc/spapr_xive.c b/hw/intc/spapr_xive.c > index dc641cc604..213c4cac44 100644 > --- a/hw/intc/spapr_xive.c > +++ b/hw/intc/spapr_xive.c > @@ -310,9 +310,8 @@ static void spapr_xive_realize(DeviceState *dev, Error **errp) > /* > * Initialize the internal sources, for IPIs and virtual devices. > */ > - object_property_set_int(OBJECT(xsrc), "nr-irqs", xive->nr_irqs, > - &error_fatal); > - object_property_set_link(OBJECT(xsrc), "xive", OBJECT(xive), &error_abort); > + qdev_prop_set_uint32(DEVICE(xsrc), "nr-irqs", xive->nr_irqs); > + qdev_prop_set_link(DEVICE(xsrc), "xive", OBJECT(xive)); > if (!qdev_realize(DEVICE(xsrc), NULL, errp)) { > return; > } > @@ -321,10 +320,8 @@ static void spapr_xive_realize(DeviceState *dev, Error **errp) > /* > * Initialize the END ESB source > */ > - object_property_set_int(OBJECT(end_xsrc), "nr-ends", xive->nr_irqs, > - &error_fatal); > - object_property_set_link(OBJECT(end_xsrc), "xive", OBJECT(xive), > - &error_abort); > + qdev_prop_set_uint32(DEVICE(end_xsrc), "nr-ends", xive->nr_irqs); > + qdev_prop_set_link(DEVICE(end_xsrc), "xive", OBJECT(xive)); > if (!qdev_realize(DEVICE(end_xsrc), NULL, errp)) { > return; > } > diff --git a/hw/intc/xics.c b/hw/intc/xics.c > index c7f8abd71e..2fd1a15153 100644 > --- a/hw/intc/xics.c > +++ b/hw/intc/xics.c > @@ -382,8 +382,8 @@ Object *icp_create(Object *cpu, const char *type, XICSFabric *xi, Error **errp) > obj = object_new(type); > object_property_add_child(cpu, type, obj); > object_unref(obj); > - object_property_set_link(obj, ICP_PROP_XICS, OBJECT(xi), &error_abort); > - object_property_set_link(obj, ICP_PROP_CPU, cpu, &error_abort); > + qdev_prop_set_link(DEVICE(obj), ICP_PROP_XICS, OBJECT(xi)); > + qdev_prop_set_link(DEVICE(obj), ICP_PROP_CPU, cpu); > if (!qdev_realize(DEVICE(obj), NULL, errp)) { > object_unparent(obj); > obj = NULL; > diff --git a/hw/intc/xive.c b/hw/intc/xive.c > index a986b96843..0e34035bc6 100644 > --- a/hw/intc/xive.c > +++ b/hw/intc/xive.c > @@ -799,8 +799,8 @@ Object *xive_tctx_create(Object *cpu, XivePresenter *xptr, Error **errp) > obj = object_new(TYPE_XIVE_TCTX); > object_property_add_child(cpu, TYPE_XIVE_TCTX, obj); > object_unref(obj); > - object_property_set_link(obj, "cpu", cpu, &error_abort); > - object_property_set_link(obj, "presenter", OBJECT(xptr), &error_abort); > + qdev_prop_set_link(DEVICE(obj), "cpu", cpu); > + qdev_prop_set_link(DEVICE(obj), "presenter", OBJECT(xptr)); > if (!qdev_realize(DEVICE(obj), NULL, errp)) { > object_unparent(obj); > return NULL; > diff --git a/hw/ppc/spapr_irq.c b/hw/ppc/spapr_irq.c > index a0d1e1298e..283769c074 100644 > --- a/hw/ppc/spapr_irq.c > +++ b/hw/ppc/spapr_irq.c > @@ -313,9 +313,8 @@ void spapr_irq_init(SpaprMachineState *spapr, Error **errp) > obj = object_new(TYPE_ICS_SPAPR); > > object_property_add_child(OBJECT(spapr), "ics", obj); > - object_property_set_link(obj, ICS_PROP_XICS, OBJECT(spapr), > - &error_abort); > - object_property_set_int(obj, "nr-irqs", smc->nr_xirqs, &error_abort); > + qdev_prop_set_link(DEVICE(obj), ICS_PROP_XICS, OBJECT(spapr)); > + qdev_prop_set_uint32(DEVICE(obj), "nr-irqs", smc->nr_xirqs); > if (!qdev_realize(DEVICE(obj), NULL, errp)) { > return; > } > @@ -335,8 +334,7 @@ void spapr_irq_init(SpaprMachineState *spapr, Error **errp) > * priority > */ > qdev_prop_set_uint32(dev, "nr-ends", nr_servers << 3); > - object_property_set_link(OBJECT(dev), "xive-fabric", OBJECT(spapr), > - &error_abort); > + qdev_prop_set_link(dev, "xive-fabric", OBJECT(spapr)); > sysbus_realize_and_unref(SYS_BUS_DEVICE(dev), &error_fatal); > > spapr->xive = SPAPR_XIVE(dev);
diff --git a/hw/intc/spapr_xive.c b/hw/intc/spapr_xive.c index dc641cc604..213c4cac44 100644 --- a/hw/intc/spapr_xive.c +++ b/hw/intc/spapr_xive.c @@ -310,9 +310,8 @@ static void spapr_xive_realize(DeviceState *dev, Error **errp) /* * Initialize the internal sources, for IPIs and virtual devices. */ - object_property_set_int(OBJECT(xsrc), "nr-irqs", xive->nr_irqs, - &error_fatal); - object_property_set_link(OBJECT(xsrc), "xive", OBJECT(xive), &error_abort); + qdev_prop_set_uint32(DEVICE(xsrc), "nr-irqs", xive->nr_irqs); + qdev_prop_set_link(DEVICE(xsrc), "xive", OBJECT(xive)); if (!qdev_realize(DEVICE(xsrc), NULL, errp)) { return; } @@ -321,10 +320,8 @@ static void spapr_xive_realize(DeviceState *dev, Error **errp) /* * Initialize the END ESB source */ - object_property_set_int(OBJECT(end_xsrc), "nr-ends", xive->nr_irqs, - &error_fatal); - object_property_set_link(OBJECT(end_xsrc), "xive", OBJECT(xive), - &error_abort); + qdev_prop_set_uint32(DEVICE(end_xsrc), "nr-ends", xive->nr_irqs); + qdev_prop_set_link(DEVICE(end_xsrc), "xive", OBJECT(xive)); if (!qdev_realize(DEVICE(end_xsrc), NULL, errp)) { return; } diff --git a/hw/intc/xics.c b/hw/intc/xics.c index c7f8abd71e..2fd1a15153 100644 --- a/hw/intc/xics.c +++ b/hw/intc/xics.c @@ -382,8 +382,8 @@ Object *icp_create(Object *cpu, const char *type, XICSFabric *xi, Error **errp) obj = object_new(type); object_property_add_child(cpu, type, obj); object_unref(obj); - object_property_set_link(obj, ICP_PROP_XICS, OBJECT(xi), &error_abort); - object_property_set_link(obj, ICP_PROP_CPU, cpu, &error_abort); + qdev_prop_set_link(DEVICE(obj), ICP_PROP_XICS, OBJECT(xi)); + qdev_prop_set_link(DEVICE(obj), ICP_PROP_CPU, cpu); if (!qdev_realize(DEVICE(obj), NULL, errp)) { object_unparent(obj); obj = NULL; diff --git a/hw/intc/xive.c b/hw/intc/xive.c index a986b96843..0e34035bc6 100644 --- a/hw/intc/xive.c +++ b/hw/intc/xive.c @@ -799,8 +799,8 @@ Object *xive_tctx_create(Object *cpu, XivePresenter *xptr, Error **errp) obj = object_new(TYPE_XIVE_TCTX); object_property_add_child(cpu, TYPE_XIVE_TCTX, obj); object_unref(obj); - object_property_set_link(obj, "cpu", cpu, &error_abort); - object_property_set_link(obj, "presenter", OBJECT(xptr), &error_abort); + qdev_prop_set_link(DEVICE(obj), "cpu", cpu); + qdev_prop_set_link(DEVICE(obj), "presenter", OBJECT(xptr)); if (!qdev_realize(DEVICE(obj), NULL, errp)) { object_unparent(obj); return NULL; diff --git a/hw/ppc/spapr_irq.c b/hw/ppc/spapr_irq.c index a0d1e1298e..283769c074 100644 --- a/hw/ppc/spapr_irq.c +++ b/hw/ppc/spapr_irq.c @@ -313,9 +313,8 @@ void spapr_irq_init(SpaprMachineState *spapr, Error **errp) obj = object_new(TYPE_ICS_SPAPR); object_property_add_child(OBJECT(spapr), "ics", obj); - object_property_set_link(obj, ICS_PROP_XICS, OBJECT(spapr), - &error_abort); - object_property_set_int(obj, "nr-irqs", smc->nr_xirqs, &error_abort); + qdev_prop_set_link(DEVICE(obj), ICS_PROP_XICS, OBJECT(spapr)); + qdev_prop_set_uint32(DEVICE(obj), "nr-irqs", smc->nr_xirqs); if (!qdev_realize(DEVICE(obj), NULL, errp)) { return; } @@ -335,8 +334,7 @@ void spapr_irq_init(SpaprMachineState *spapr, Error **errp) * priority */ qdev_prop_set_uint32(dev, "nr-ends", nr_servers << 3); - object_property_set_link(OBJECT(dev), "xive-fabric", OBJECT(spapr), - &error_abort); + qdev_prop_set_link(dev, "xive-fabric", OBJECT(spapr)); sysbus_realize_and_unref(SYS_BUS_DEVICE(dev), &error_fatal); spapr->xive = SPAPR_XIVE(dev);
No need to use the low-level QOM API when an object inherits from QDev. Directly use the QDev API to set its properties. All calls use either errp=&error_abort or &error_fatal, so converting to the QDev API is almost a no-op (QDev API always uses &error_abort). Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org> --- hw/intc/spapr_xive.c | 11 ++++------- hw/intc/xics.c | 4 ++-- hw/intc/xive.c | 4 ++-- hw/ppc/spapr_irq.c | 8 +++----- 4 files changed, 11 insertions(+), 16 deletions(-)