Message ID | 20230203211623.50930-3-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_fatal or NULL, 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/pci-host/raven.c | 6 ++---- > 1 file changed, 2 insertions(+), 4 deletions(-) > > diff --git a/hw/pci-host/raven.c b/hw/pci-host/raven.c > index cdfb62ac2e..2c842d2146 100644 > --- a/hw/pci-host/raven.c > +++ b/hw/pci-host/raven.c > @@ -246,8 +246,7 @@ static void raven_pcihost_realizefn(DeviceState *d, Error **errp) > /* According to PReP specification section 6.1.6 "System Interrupt > * Assignments", all PCI interrupts are routed via IRQ 15 */ > s->or_irq = OR_IRQ(object_new(TYPE_OR_IRQ)); > - object_property_set_int(OBJECT(s->or_irq), "num-lines", PCI_NUM_PINS, > - &error_fatal); > + qdev_prop_set_uint16(DEVICE(s->or_irq), "num-lines", PCI_NUM_PINS); > qdev_realize(DEVICE(s->or_irq), NULL, &error_fatal); > sysbus_init_irq(dev, &s->or_irq->out_irq); > > @@ -319,8 +318,7 @@ static void raven_pcihost_initfn(Object *obj) > > object_initialize(&s->pci_dev, sizeof(s->pci_dev), TYPE_RAVEN_PCI_DEVICE); > pci_dev = DEVICE(&s->pci_dev); > - object_property_set_int(OBJECT(&s->pci_dev), "addr", PCI_DEVFN(0, 0), > - NULL); > + qdev_prop_set_int32(pci_dev, "addr", PCI_DEVFN(0, 0)); > qdev_prop_set_bit(pci_dev, "multifunction", false); > } >
diff --git a/hw/pci-host/raven.c b/hw/pci-host/raven.c index cdfb62ac2e..2c842d2146 100644 --- a/hw/pci-host/raven.c +++ b/hw/pci-host/raven.c @@ -246,8 +246,7 @@ static void raven_pcihost_realizefn(DeviceState *d, Error **errp) /* According to PReP specification section 6.1.6 "System Interrupt * Assignments", all PCI interrupts are routed via IRQ 15 */ s->or_irq = OR_IRQ(object_new(TYPE_OR_IRQ)); - object_property_set_int(OBJECT(s->or_irq), "num-lines", PCI_NUM_PINS, - &error_fatal); + qdev_prop_set_uint16(DEVICE(s->or_irq), "num-lines", PCI_NUM_PINS); qdev_realize(DEVICE(s->or_irq), NULL, &error_fatal); sysbus_init_irq(dev, &s->or_irq->out_irq); @@ -319,8 +318,7 @@ static void raven_pcihost_initfn(Object *obj) object_initialize(&s->pci_dev, sizeof(s->pci_dev), TYPE_RAVEN_PCI_DEVICE); pci_dev = DEVICE(&s->pci_dev); - object_property_set_int(OBJECT(&s->pci_dev), "addr", PCI_DEVFN(0, 0), - NULL); + qdev_prop_set_int32(pci_dev, "addr", PCI_DEVFN(0, 0)); qdev_prop_set_bit(pci_dev, "multifunction", false); }
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_fatal or NULL, 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/pci-host/raven.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-)