]> www.infradead.org Git - users/dwmw2/qemu.git/commitdiff
hw/net/lan9118: use qemu_configure_nic_device()
authorDavid Woodhouse <dwmw@amazon.co.uk>
Mon, 23 Oct 2023 08:37:36 +0000 (09:37 +0100)
committerDavid Woodhouse <dwmw@amazon.co.uk>
Mon, 13 Nov 2023 23:31:53 +0000 (18:31 -0500)
Some callers instantiate the device unconditionally, others will do so only
if there is a NICInfo to go with it. This appears to be fairly random, but
preseve the existing behaviour for now.

Signed-off-by: David Woodhouse <dwmw@amazon.co.uk>
hw/arm/kzm.c
hw/arm/mps2.c
hw/arm/realview.c
hw/arm/vexpress.c
hw/net/lan9118.c
include/hw/net/lan9118.h

index 9be91ebeaafbe2125d793046e9a5b3da36b6a810..2ccd6f8a7689d268fec62d02fd8647abd267579e 100644 (file)
@@ -113,8 +113,8 @@ static void kzm_init(MachineState *machine)
         alias_offset += ram[i].size;
     }
 
-    if (nd_table[0].used) {
-        lan9118_init(&nd_table[0], KZM_LAN9118_ADDR,
+    if (qemu_find_nic_info("lan9118", true, NULL)) {
+        lan9118_init(KZM_LAN9118_ADDR,
                      qdev_get_gpio_in(DEVICE(&s->soc.avic), 52));
     }
 
index 292a180ad27eac0800f265e9a39f17d173058b35..e6ec1e44749c6313e6aadf310ba673963e875e56 100644 (file)
@@ -462,7 +462,7 @@ static void mps2_common_init(MachineState *machine)
     /* In hardware this is a LAN9220; the LAN9118 is software compatible
      * except that it doesn't support the checksum-offload feature.
      */
-    lan9118_init(&nd_table[0], mmc->ethernet_base,
+    lan9118_init(mmc->ethernet_base,
                  qdev_get_gpio_in(armv7m,
                                   mmc->fpga_type == FPGA_AN511 ? 47 : 13));
 
index 6e7529d98f1636937135a313de8c2e9a1c52a48b..1f88da370210c700df3499cf2302971e510c3c3a 100644 (file)
@@ -84,7 +84,6 @@ static void realview_init(MachineState *machine,
     SysBusDevice *busdev;
     qemu_irq pic[64];
     PCIBus *pci_bus = NULL;
-    NICInfo *nd;
     DriveInfo *dinfo;
     I2CBus *i2c;
     int n;
@@ -295,10 +294,9 @@ static void realview_init(MachineState *machine,
         }
     }
 
-    nd = qemu_find_nic_info(is_pb ? "lan9118" : "smc91c111", true, NULL);
-    if (nd) {
+    if (qemu_find_nic_info(is_pb ? "lan9118" : "smc91c111", true, NULL)) {
         if (is_pb) {
-            lan9118_init(nd, 0x4e000000, pic[28]);
+            lan9118_init(0x4e000000, pic[28]);
         } else {
             smc91c111_init(0x4e000000, pic[28]);
         }
index fd981f4c33ef448c80e593e3f304834e670c3c6f..1e02e0965fbe18369e564299497dfb4ad380339a 100644 (file)
@@ -679,8 +679,8 @@ static void vexpress_common_init(MachineState *machine)
     memory_region_add_subregion(sysmem, map[VE_VIDEORAM], &vms->vram);
 
     /* 0x4e000000 LAN9118 Ethernet */
-    if (nd_table[0].used) {
-        lan9118_init(&nd_table[0], map[VE_ETHERNET], pic[15]);
+    if (qemu_find_nic_info("lan9118", true, NULL)) {
+        lan9118_init(map[VE_ETHERNET], pic[15]);
     }
 
     /* VE_USB: not modelled */
index e5c4af182dfa79e8396aab33e4ecfa9414d513ec..42fe5efd8cbd03043f831b9c3ac21fe3bbbde77b 100644 (file)
@@ -1407,14 +1407,13 @@ static void lan9118_register_types(void)
 
 /* Legacy helper function.  Should go away when machine config files are
    implemented.  */
-void lan9118_init(NICInfo *nd, uint32_t base, qemu_irq irq)
+void lan9118_init(uint32_t base, qemu_irq irq)
 {
     DeviceState *dev;
     SysBusDevice *s;
 
-    qemu_check_nic_model(nd, "lan9118");
     dev = qdev_new(TYPE_LAN9118);
-    qdev_set_nic_properties(dev, nd);
+    qemu_configure_nic_device(dev, true, NULL);
     s = SYS_BUS_DEVICE(dev);
     sysbus_realize_and_unref(s, &error_fatal);
     sysbus_mmio_map(s, 0, base);
index 3d0c67f3393649872de818de1a903dc6027ee530..4bf9da7a63efba5b3e02c805a130f48ee1de1d74 100644 (file)
@@ -15,6 +15,6 @@
 
 #define TYPE_LAN9118 "lan9118"
 
-void lan9118_init(NICInfo *, uint32_t, qemu_irq);
+void lan9118_init(uint32_t, qemu_irq);
 
 #endif