diff mbox series

[2/4] hw/i386/microvm: Simplify using object_dynamic_cast()

Message ID 20230523061207.48818-3-philmd@linaro.org
State Superseded
Headers show
Series hw: Minor simplifications using proper QOM getter macros | expand

Commit Message

Philippe Mathieu-Daudé May 23, 2023, 6:12 a.m. UTC
Use object_dynamic_cast() to determine if 'dev' is a TYPE_VIRTIO_MMIO.

Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
---
 hw/i386/microvm.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

Comments

Richard Henderson May 23, 2023, 6:22 p.m. UTC | #1
On 5/22/23 23:12, Philippe Mathieu-Daudé wrote:
> Use object_dynamic_cast() to determine if 'dev' is a TYPE_VIRTIO_MMIO.
> 
> Signed-off-by: Philippe Mathieu-Daudé<philmd@linaro.org>
> ---
>   hw/i386/microvm.c | 3 +--
>   1 file changed, 1 insertion(+), 2 deletions(-)

Reviewed-by: Richard Henderson <richard.henderson@linaro.org>

r~
Sergio Lopez May 26, 2023, 8:35 a.m. UTC | #2
On Tue, May 23, 2023 at 08:12:05AM +0200, Philippe Mathieu-Daudé wrote:
> Use object_dynamic_cast() to determine if 'dev' is a TYPE_VIRTIO_MMIO.
> 
> Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
> ---
>  hw/i386/microvm.c | 3 +--
>  1 file changed, 1 insertion(+), 2 deletions(-)

Reviewed-by: Sergio Lopez <slp@redhat.com>
diff mbox series

Patch

diff --git a/hw/i386/microvm.c b/hw/i386/microvm.c
index 3d606a20b4..7227a2156c 100644
--- a/hw/i386/microvm.c
+++ b/hw/i386/microvm.c
@@ -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;