diff mbox series

[v3,27/46] hw/arm/highbank: use qemu_create_nic_device()

Message ID 20240108204909.564514-28-dwmw2@infradead.org
State New
Headers show
Series Rework matching of network devices to -nic options | expand

Commit Message

David Woodhouse Jan. 8, 2024, 8:26 p.m. UTC
From: David Woodhouse <dwmw@amazon.co.uk>

Signed-off-by: David Woodhouse <dwmw@amazon.co.uk>
---
 hw/arm/highbank.c | 12 +++++-------
 1 file changed, 5 insertions(+), 7 deletions(-)

Comments

Thomas Huth Jan. 26, 2024, 3:48 p.m. UTC | #1
On 08/01/2024 21.26, David Woodhouse wrote:
> From: David Woodhouse <dwmw@amazon.co.uk>
> 
> Signed-off-by: David Woodhouse <dwmw@amazon.co.uk>
> ---
>   hw/arm/highbank.c | 12 +++++-------
>   1 file changed, 5 insertions(+), 7 deletions(-)
> 
> diff --git a/hw/arm/highbank.c b/hw/arm/highbank.c
> index c21e18d08f..6a0e20e58d 100644
> --- a/hw/arm/highbank.c
> +++ b/hw/arm/highbank.c
> @@ -296,19 +296,17 @@ static void calxeda_init(MachineState *machine, enum cxmachines machine_id)
>   
>       sysbus_create_simple(TYPE_SYSBUS_AHCI, 0xffe08000, pic[83]);
>   
> -    if (nd_table[0].used) {
> -        qemu_check_nic_model(&nd_table[0], "xgmac");
> -        dev = qdev_new("xgmac");
> -        qdev_set_nic_properties(dev, &nd_table[0]);
> +    dev = qemu_create_nic_device("xgmac", true, NULL);
> +    if (dev) {
>           sysbus_realize_and_unref(SYS_BUS_DEVICE(dev), &error_fatal);
>           sysbus_mmio_map(SYS_BUS_DEVICE(dev), 0, 0xfff50000);
>           sysbus_connect_irq(SYS_BUS_DEVICE(dev), 0, pic[77]);
>           sysbus_connect_irq(SYS_BUS_DEVICE(dev), 1, pic[78]);
>           sysbus_connect_irq(SYS_BUS_DEVICE(dev), 2, pic[79]);
> +    }
>   
> -        qemu_check_nic_model(&nd_table[1], "xgmac");
> -        dev = qdev_new("xgmac");
> -        qdev_set_nic_properties(dev, &nd_table[1]);
> +    dev = qemu_create_nic_device("xgmac", true, NULL);
> +    if (dev) {
>           sysbus_realize_and_unref(SYS_BUS_DEVICE(dev), &error_fatal);
>           sysbus_mmio_map(SYS_BUS_DEVICE(dev), 0, 0xfff51000);
>           sysbus_connect_irq(SYS_BUS_DEVICE(dev), 0, pic[80]);

Reviewed-by: Thomas Huth <thuth@redhat.com>
diff mbox series

Patch

diff --git a/hw/arm/highbank.c b/hw/arm/highbank.c
index c21e18d08f..6a0e20e58d 100644
--- a/hw/arm/highbank.c
+++ b/hw/arm/highbank.c
@@ -296,19 +296,17 @@  static void calxeda_init(MachineState *machine, enum cxmachines machine_id)
 
     sysbus_create_simple(TYPE_SYSBUS_AHCI, 0xffe08000, pic[83]);
 
-    if (nd_table[0].used) {
-        qemu_check_nic_model(&nd_table[0], "xgmac");
-        dev = qdev_new("xgmac");
-        qdev_set_nic_properties(dev, &nd_table[0]);
+    dev = qemu_create_nic_device("xgmac", true, NULL);
+    if (dev) {
         sysbus_realize_and_unref(SYS_BUS_DEVICE(dev), &error_fatal);
         sysbus_mmio_map(SYS_BUS_DEVICE(dev), 0, 0xfff50000);
         sysbus_connect_irq(SYS_BUS_DEVICE(dev), 0, pic[77]);
         sysbus_connect_irq(SYS_BUS_DEVICE(dev), 1, pic[78]);
         sysbus_connect_irq(SYS_BUS_DEVICE(dev), 2, pic[79]);
+    }
 
-        qemu_check_nic_model(&nd_table[1], "xgmac");
-        dev = qdev_new("xgmac");
-        qdev_set_nic_properties(dev, &nd_table[1]);
+    dev = qemu_create_nic_device("xgmac", true, NULL);
+    if (dev) {
         sysbus_realize_and_unref(SYS_BUS_DEVICE(dev), &error_fatal);
         sysbus_mmio_map(SYS_BUS_DEVICE(dev), 0, 0xfff51000);
         sysbus_connect_irq(SYS_BUS_DEVICE(dev), 0, pic[80]);