diff mbox series

[6/6] hw/m68k/virt: Do not open-code sysbus_create_simple()

Message ID 20231020150627.56893-7-philmd@linaro.org
State Superseded
Headers show
Series hw/m68k: Strengthen QOM/SysBus API uses | expand

Commit Message

Philippe Mathieu-Daudé Oct. 20, 2023, 3:06 p.m. UTC
Mechanical change using the following coccinelle script:

  @@
  identifier dev;
  expression qom_type;
  expression addr;
  expression irq;
  @@
  -    dev = qdev_new(qom_type);
  -    sysbus_realize_and_unref(SYS_BUS_DEVICE(dev), &error_fatal);
  -    sysbus_mmio_map(SYS_BUS_DEVICE(dev), 0, addr);
  -    sysbus_connect_irq(SYS_BUS_DEVICE(dev), 0, irq);
  +    dev = sysbus_create_simple(qom_type, addr, irq);

Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
---
 hw/m68k/virt.c | 7 ++-----
 1 file changed, 2 insertions(+), 5 deletions(-)

Comments

Thomas Huth Oct. 22, 2023, 9:43 a.m. UTC | #1
Am Fri, 20 Oct 2023 17:06:26 +0200
schrieb Philippe Mathieu-Daudé <philmd@linaro.org>:

> Mechanical change using the following coccinelle script:
> 
>   @@
>   identifier dev;
>   expression qom_type;
>   expression addr;
>   expression irq;
>   @@
>   -    dev = qdev_new(qom_type);
>   -    sysbus_realize_and_unref(SYS_BUS_DEVICE(dev), &error_fatal);
>   -    sysbus_mmio_map(SYS_BUS_DEVICE(dev), 0, addr);
>   -    sysbus_connect_irq(SYS_BUS_DEVICE(dev), 0, irq);
>   +    dev = sysbus_create_simple(qom_type, addr, irq);
> 
> Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
> ---

Reviewed-by: Thomas Huth <huth@tuxfamily.org>
diff mbox series

Patch

diff --git a/hw/m68k/virt.c b/hw/m68k/virt.c
index da35e74bd9..31038b8bb0 100644
--- a/hw/m68k/virt.c
+++ b/hw/m68k/virt.c
@@ -201,11 +201,8 @@  static void virt_init(MachineState *machine)
     sysbus_connect_irq(sysbus, 0, PIC_GPIO(VIRT_GF_TTY_IRQ_BASE));
 
     /* virt controller */
-    dev = qdev_new(TYPE_VIRT_CTRL);
-    sysbus = SYS_BUS_DEVICE(dev);
-    sysbus_realize_and_unref(sysbus, &error_fatal);
-    sysbus_mmio_map(sysbus, 0, VIRT_CTRL_MMIO_BASE);
-    sysbus_connect_irq(sysbus, 0, PIC_GPIO(VIRT_CTRL_IRQ_BASE));
+    dev = sysbus_create_simple(TYPE_VIRT_CTRL, VIRT_CTRL_MMIO_BASE,
+                               PIC_GPIO(VIRT_CTRL_IRQ_BASE));
 
     /* virtio-mmio */
     io_base = VIRT_VIRTIO_MMIO_BASE;