diff mbox series

[v3,35/46] hw/mips/mipssim: use qemu_create_nic_device()

Message ID 20240108204909.564514-36-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:27 p.m. UTC
From: David Woodhouse <dwmw@amazon.co.uk>

The MIPS SIM platform instantiates its NIC only if a corresponding
configuration exists for it. Use qemu_create_nic_device() function for
that.

Signed-off-by: David Woodhouse <dwmw@amazon.co.uk>
---
 hw/mips/mipssim.c | 13 +++++++------
 1 file changed, 7 insertions(+), 6 deletions(-)

Comments

Thomas Huth Jan. 26, 2024, 4:20 p.m. UTC | #1
On 08/01/2024 21.27, David Woodhouse wrote:
> From: David Woodhouse <dwmw@amazon.co.uk>
> 
> The MIPS SIM platform instantiates its NIC only if a corresponding
> configuration exists for it. Use qemu_create_nic_device() function for
> that.
> 
> Signed-off-by: David Woodhouse <dwmw@amazon.co.uk>
> ---
>   hw/mips/mipssim.c | 13 +++++++------
>   1 file changed, 7 insertions(+), 6 deletions(-)
> 
> diff --git a/hw/mips/mipssim.c b/hw/mips/mipssim.c
> index 01e323904d..16af31648e 100644
> --- a/hw/mips/mipssim.c
> +++ b/hw/mips/mipssim.c
> @@ -118,13 +118,15 @@ static void main_cpu_reset(void *opaque)
>       }
>   }
>   
> -static void mipsnet_init(int base, qemu_irq irq, NICInfo *nd)
> +static void mipsnet_init(int base, qemu_irq irq)
>   {
>       DeviceState *dev;
>       SysBusDevice *s;
>   
> -    dev = qdev_new("mipsnet");
> -    qdev_set_nic_properties(dev, nd);
> +    dev = qemu_create_nic_device("mipsnet", true, NULL);
> +    if (!dev) {
> +        return;
> +    }
>   
>       s = SYS_BUS_DEVICE(dev);
>       sysbus_realize_and_unref(s, &error_fatal);
> @@ -225,9 +227,8 @@ mips_mipssim_init(MachineState *machine)
>                         sysbus_mmio_get_region(SYS_BUS_DEVICE(dev), 0));
>       }
>   
> -    if (nd_table[0].used)
> -        /* MIPSnet uses the MIPS CPU INT0, which is interrupt 2. */
> -        mipsnet_init(0x4200, env->irq[2], &nd_table[0]);
> +    /* MIPSnet uses the MIPS CPU INT0, which is interrupt 2. */
> +    mipsnet_init(0x4200, env->irq[2]);
>   }
>   
>   static void mips_mipssim_machine_init(MachineClass *mc)

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

Patch

diff --git a/hw/mips/mipssim.c b/hw/mips/mipssim.c
index 01e323904d..16af31648e 100644
--- a/hw/mips/mipssim.c
+++ b/hw/mips/mipssim.c
@@ -118,13 +118,15 @@  static void main_cpu_reset(void *opaque)
     }
 }
 
-static void mipsnet_init(int base, qemu_irq irq, NICInfo *nd)
+static void mipsnet_init(int base, qemu_irq irq)
 {
     DeviceState *dev;
     SysBusDevice *s;
 
-    dev = qdev_new("mipsnet");
-    qdev_set_nic_properties(dev, nd);
+    dev = qemu_create_nic_device("mipsnet", true, NULL);
+    if (!dev) {
+        return;
+    }
 
     s = SYS_BUS_DEVICE(dev);
     sysbus_realize_and_unref(s, &error_fatal);
@@ -225,9 +227,8 @@  mips_mipssim_init(MachineState *machine)
                       sysbus_mmio_get_region(SYS_BUS_DEVICE(dev), 0));
     }
 
-    if (nd_table[0].used)
-        /* MIPSnet uses the MIPS CPU INT0, which is interrupt 2. */
-        mipsnet_init(0x4200, env->irq[2], &nd_table[0]);
+    /* MIPSnet uses the MIPS CPU INT0, which is interrupt 2. */
+    mipsnet_init(0x4200, env->irq[2]);
 }
 
 static void mips_mipssim_machine_init(MachineClass *mc)