hw: Minor simplifications using proper QOM getter macros
cover hw: Minor simplifications using proper QOM getter macros
Enforce QOM style. Besides, using the proper QOM macros slightly simplifies the code.
Philippe Mathieu-Daudé (4):
hw/core/cpu: Simplify realize() using MACHINE_GET_CLASS() macro hw/i386/microvm: Simplify using object_dynamic_cast() hw/pci/pci: Simplify pci_bar_address() using MACHINE_GET_CLASS() macro hw/usb/hcd-ehci-pci: Simplify using DEVICE_GET_CLASS() macro
hw/core/cpu-common.c | 3 +-- hw/i386/microvm.c | 3 +-- hw/pci/pci.c | 4 +--- hw/usb/hcd-ehci-pci.c | 2 +- 4 files changed, 4 insertions(+), 8 deletions(-)
Signature · 1 line
2.38.1
PATCH 1/4 hw/core/cpu: Simplify realize() using MACHINE_GET_CLASS() macro
--- hw/core/cpu-common.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
hw/core/cpu-common.c +1 -2
@@ -196,8 +196,7 @@ static void cpu_common_realizefn(DeviceState *dev, Error **errp)* no need to check the ignore_memory_transaction_failures board flag. */ if (object_dynamic_cast (machine,TYPE_MACHINE )) { -ObjectClass *oc =object_get_class (machine); -MachineClass *mc =MACHINE_CLASS (oc); +MachineClass *mc =MACHINE_GET_CLASS (machine);if (mc) { cpu->ignore_memory_transaction_failures =
Signature · 1 line
2.38.1
Re: [PATCH 1/4] hw/core/cpu: Simplify realize() using MACHINE_GET_CLASS() macro
Quoted 4 lines · Philippe Mathieu-Daudé
Signed-off-by Philippe Mathieu-Daudé<[email protected]>--- hw/core/cpu-common.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
r~
PATCH 2/4 hw/i386/microvm: Simplify using object_dynamic_cast()
In reply to Philippe Mathieu-DaudéUse object_dynamic_cast() to determine if 'dev' is a TYPE_VIRTIO_MMIO.
--- hw/i386/microvm.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
hw/i386/microvm.c +1 -2
@@ -389,9 +389,8 @@ static void microvm_fix_kernel_cmdline(MachineState *machine) bus =sysbus_get_default (); QTAILQ_FOREACH(kid, &bus->children, sibling) {DeviceState *dev = kid->child; -ObjectClass *class =object_get_class (OBJECT (dev)); -if (class ==object_class_by_name (TYPE_VIRTIO_MMIO )) { +if (object_dynamic_cast (OBJECT (dev),TYPE_VIRTIO_MMIO )) {VirtIOMMIOProxy *mmio =VIRTIO_MMIO (OBJECT (dev));VirtioBusState *mmio_virtio_bus = &mmio->bus;BusState *mmio_bus = &mmio_virtio_bus->parent_obj;
Signature · 1 line
2.38.1
Re: [PATCH 2/4] hw/i386/microvm: Simplify using object_dynamic_cast()
Quoted 6 lines · Philippe Mathieu-Daudé
Use
object_dynamic_cast()to determine if 'dev' is aTYPE_VIRTIO_MMIO.Signed-off-by Philippe Mathieu-Daudé<[email protected]>--- hw/i386/microvm.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
r~
Re: [PATCH 2/4] hw/i386/microvm: Simplify using object_dynamic_cast()
In reply to Philippe Mathieu-DaudéQuoted 6 lines · Philippe Mathieu-Daudé
Use
object_dynamic_cast()to determine if 'dev' is aTYPE_VIRTIO_MMIO.Signed-off-by Philippe Mathieu-Daudé <[email protected]>--- hw/i386/microvm.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
PATCH 3/4 hw/pci/pci: Simplify pci_bar_address() using MACHINE_GET_CLASS() macro
In reply to Philippe Mathieu-DaudéRemove unnecessary intermediate variables.
--- hw/pci/pci.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-)
hw/pci/pci.c +1 -3
@@ -1444,9 +1444,7 @@ pcibus_t pci_bar_address(PCIDevice *d, {pcibus_t new_addr, last_addr;uint16_t cmd =pci_get_word (d->config +PCI_COMMAND ); -Object *machine =qdev_get_machine (); -ObjectClass *oc =object_get_class (machine); -MachineClass *mc =MACHINE_CLASS (oc); +MachineClass *mc =MACHINE_GET_CLASS (qdev_get_machine ());bool allow_0_address = mc->pci_allow_0_address;if (type &PCI_BASE_ADDRESS_SPACE_IO ) {
Signature · 1 line
2.38.1
Re: [PATCH 3/4] hw/pci/pci: Simplify pci_bar_address() using MACHINE_GET_CLASS() macro
Quoted 6 lines · Philippe Mathieu-Daudé
Remove unnecessary intermediate variables.
Signed-off-by Philippe Mathieu-Daudé<[email protected]>--- hw/pci/pci.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-)
r~
PATCH 4/4 hw/usb/hcd-ehci-pci: Simplify using DEVICE_GET_CLASS() macro
In reply to Philippe Mathieu-Daudé--- hw/usb/hcd-ehci-pci.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
hw/usb/hcd-ehci-pci.c +1 -1
@@ -74,7 +74,7 @@ static void usb_ehci_pci_realize(PCIDevice *dev, Error **errp)static void usb_ehci_pci_init (Object *obj) { -DeviceClass *dc =OBJECT_GET_CLASS (DeviceClass, obj,TYPE_DEVICE ); +DeviceClass *dc =DEVICE_GET_CLASS (obj);EHCIPCIState *i =PCI_EHCI (obj);EHCIState *s = &i->ehci;
Signature · 1 line
2.38.1
Re: [PATCH 4/4] hw/usb/hcd-ehci-pci: Simplify using DEVICE_GET_CLASS() macro
Quoted 4 lines · Philippe Mathieu-Daudé
Signed-off-by Philippe Mathieu-Daudé<[email protected]>--- hw/usb/hcd-ehci-pci.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
r~
Michael Tokarev
AppliedQuoted 2 lines · Philippe Mathieu-Daudé
Enforce QOM style. Besides, using the proper QOM macros slightly simplifies the code.
Applied to my trivial-patches branch (Maybe it's time to resurrect it).
Thanks,
/mjt
Michael S. Tsirkin
Reviewed-byQuoted 9 lines · Michael Tokarev
Quoted 2 lines · Philippe Mathieu-Daudé
Enforce QOM style. Besides, using the proper QOM macros slightly simplifies the code.
Applied to my trivial-patches branch (Maybe it's time to resurrect it).
Thanks,
/mjt
pci things:
Quoted 7 lines · Michael S. Tsirkin
Quoted 1 line · Michael Tokarev
Applied to my trivial-patches branch (Maybe it's time to resurrect it).
pci things:
Reviewed-by Michael S. Tsirkin <[email protected]>
It's been merged to master on Jun-11 already. But thank you for the review anyway! :)
/mjt