From: David Woodhouse <dwmw2@infradead.org>
To: qemu-devel@nongnu.org
Subject: [PULL 25/47] hw/net/smc91c111: use qemu_configure_nic_device()
Date: Thu, 1 Feb 2024 16:43:50 +0000 [thread overview]
Message-ID: <20240201164412.785520-26-dwmw2@infradead.org> (raw)
In-Reply-To: <20240201164412.785520-1-dwmw2@infradead.org>
From: David Woodhouse <dwmw@amazon.co.uk>
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
preserve the existing behaviour of each caller for now.
Signed-off-by: David Woodhouse <dwmw@amazon.co.uk>
Reviewed-by: Thomas Huth <thuth@redhat.com>
---
hw/arm/gumstix.c | 6 ++----
hw/arm/integratorcp.c | 5 +++--
hw/arm/mainstone.c | 3 +--
hw/arm/realview.c | 25 ++++++++++---------------
hw/arm/versatilepb.c | 15 ++++-----------
hw/net/smc91c111.c | 5 ++---
include/hw/net/smc91c111.h | 2 +-
7 files changed, 23 insertions(+), 38 deletions(-)
diff --git a/hw/arm/gumstix.c b/hw/arm/gumstix.c
index 3f2bcaa24e..d5de5409e1 100644
--- a/hw/arm/gumstix.c
+++ b/hw/arm/gumstix.c
@@ -73,8 +73,7 @@ static void connex_init(MachineState *machine)
FLASH_SECTOR_SIZE, 2, 0, 0, 0, 0, 0);
/* Interrupt line of NIC is connected to GPIO line 36 */
- smc91c111_init(&nd_table[0], 0x04000300,
- qdev_get_gpio_in(cpu->gpio, 36));
+ smc91c111_init(0x04000300, qdev_get_gpio_in(cpu->gpio, 36));
}
static void verdex_init(MachineState *machine)
@@ -97,8 +96,7 @@ static void verdex_init(MachineState *machine)
FLASH_SECTOR_SIZE, 2, 0, 0, 0, 0, 0);
/* Interrupt line of NIC is connected to GPIO line 99 */
- smc91c111_init(&nd_table[0], 0x04000300,
- qdev_get_gpio_in(cpu->gpio, 99));
+ smc91c111_init(0x04000300, qdev_get_gpio_in(cpu->gpio, 99));
}
static void connex_class_init(ObjectClass *oc, void *data)
diff --git a/hw/arm/integratorcp.c b/hw/arm/integratorcp.c
index 793262eca8..f016d20485 100644
--- a/hw/arm/integratorcp.c
+++ b/hw/arm/integratorcp.c
@@ -666,8 +666,9 @@ static void integratorcp_init(MachineState *machine)
sysbus_mmio_map(SYS_BUS_DEVICE(dev), 0, 0x1d000000);
sysbus_connect_irq(SYS_BUS_DEVICE(dev), 0, pic[25]);
- if (nd_table[0].used)
- smc91c111_init(&nd_table[0], 0xc8000000, pic[27]);
+ if (qemu_find_nic_info("smc91c111", true, NULL)) {
+ smc91c111_init(0xc8000000, pic[27]);
+ }
sysbus_create_simple("pl110", 0xc0000000, pic[22]);
diff --git a/hw/arm/mainstone.c b/hw/arm/mainstone.c
index fc14e05060..d2e2e68aa3 100644
--- a/hw/arm/mainstone.c
+++ b/hw/arm/mainstone.c
@@ -152,8 +152,7 @@ static void mainstone_common_init(MachineState *machine,
qdev_get_gpio_in(mst_irq, S1_IRQ),
qdev_get_gpio_in(mst_irq, S1_CD_IRQ));
- smc91c111_init(&nd_table[0], MST_ETH_PHYS,
- qdev_get_gpio_in(mst_irq, ETHERNET_IRQ));
+ smc91c111_init(MST_ETH_PHYS, qdev_get_gpio_in(mst_irq, ETHERNET_IRQ));
mainstone_binfo.board_id = arm_id;
arm_load_kernel(mpu->cpu, machine, &mainstone_binfo);
diff --git a/hw/arm/realview.c b/hw/arm/realview.c
index 566deff9ce..c6bd6e5961 100644
--- a/hw/arm/realview.c
+++ b/hw/arm/realview.c
@@ -90,7 +90,6 @@ static void realview_init(MachineState *machine,
I2CBus *i2c;
int n;
unsigned int smp_cpus = machine->smp.cpus;
- int done_nic = 0;
qemu_irq cpu_irq[4];
int is_mpcore = 0;
int is_pb = 0;
@@ -296,24 +295,20 @@ static void realview_init(MachineState *machine,
n--;
}
}
- for(n = 0; n < nb_nics; n++) {
- nd = &nd_table[n];
-
- if (!done_nic && (!nd->model ||
- strcmp(nd->model, is_pb ? "lan9118" : "smc91c111") == 0)) {
- if (is_pb) {
- lan9118_init(nd, 0x4e000000, pic[28]);
- } else {
- smc91c111_init(nd, 0x4e000000, pic[28]);
- }
- done_nic = 1;
+
+ nd = qemu_find_nic_info(is_pb ? "lan9118" : "smc91c111", true, NULL);
+ if (nd) {
+ if (is_pb) {
+ lan9118_init(nd, 0x4e000000, pic[28]);
} else {
- if (pci_bus) {
- pci_nic_init_nofail(nd, pci_bus, "rtl8139", NULL);
- }
+ smc91c111_init(0x4e000000, pic[28]);
}
}
+ if (pci_bus) {
+ pci_init_nic_devices(pci_bus, "rtl8139");
+ }
+
dev = sysbus_create_simple(TYPE_ARM_SBCON_I2C, 0x10002000, NULL);
i2c = (I2CBus *)qdev_get_child_bus(dev, "i2c");
i2c_slave_create_simple(i2c, "ds1338", 0x68);
diff --git a/hw/arm/versatilepb.c b/hw/arm/versatilepb.c
index 1d813aa23b..d10b75dfdb 100644
--- a/hw/arm/versatilepb.c
+++ b/hw/arm/versatilepb.c
@@ -192,10 +192,8 @@ static void versatile_init(MachineState *machine, int board_id)
SysBusDevice *busdev;
DeviceState *pl041;
PCIBus *pci_bus;
- NICInfo *nd;
I2CBus *i2c;
int n;
- int done_smc = 0;
DriveInfo *dinfo;
if (machine->ram_size > 0x10000000) {
@@ -263,16 +261,11 @@ static void versatile_init(MachineState *machine, int board_id)
sysbus_connect_irq(busdev, 3, sic[30]);
pci_bus = (PCIBus *)qdev_get_child_bus(dev, "pci");
- for(n = 0; n < nb_nics; n++) {
- nd = &nd_table[n];
-
- if (!done_smc && (!nd->model || strcmp(nd->model, "smc91c111") == 0)) {
- smc91c111_init(nd, 0x10010000, sic[25]);
- done_smc = 1;
- } else {
- pci_nic_init_nofail(nd, pci_bus, "rtl8139", NULL);
- }
+ if (qemu_find_nic_info("smc91c111", true, NULL)) {
+ smc91c111_init(0x10010000, sic[25]);
}
+ pci_init_nic_devices(pci_bus, "rtl8139");
+
if (machine_usb(machine)) {
pci_create_simple(pci_bus, -1, "pci-ohci");
}
diff --git a/hw/net/smc91c111.c b/hw/net/smc91c111.c
index 49b7c26102..702d0e8e83 100644
--- a/hw/net/smc91c111.c
+++ b/hw/net/smc91c111.c
@@ -818,14 +818,13 @@ static void smc91c111_register_types(void)
/* Legacy helper function. Should go away when machine config files are
implemented. */
-void smc91c111_init(NICInfo *nd, uint32_t base, qemu_irq irq)
+void smc91c111_init(uint32_t base, qemu_irq irq)
{
DeviceState *dev;
SysBusDevice *s;
- qemu_check_nic_model(nd, "smc91c111");
dev = qdev_new(TYPE_SMC91C111);
- 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);
diff --git a/include/hw/net/smc91c111.h b/include/hw/net/smc91c111.h
index df5b11dcef..dba32a233f 100644
--- a/include/hw/net/smc91c111.h
+++ b/include/hw/net/smc91c111.h
@@ -13,6 +13,6 @@
#include "net/net.h"
-void smc91c111_init(NICInfo *, uint32_t, qemu_irq);
+void smc91c111_init(uint32_t, qemu_irq);
#endif
--
2.43.0
next prev parent reply other threads:[~2024-02-01 16:45 UTC|newest]
Thread overview: 57+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-02-01 16:43 [PULL 00/47] nic-config.for-upstream queue David Woodhouse
2024-02-01 16:43 ` [PULL 01/47] net: add qemu_{configure, create}_nic_device(), qemu_find_nic_info() David Woodhouse
2024-02-01 16:43 ` [PULL 02/47] net: report list of available models according to platform David Woodhouse
2024-02-01 16:43 ` [PULL 03/47] net: add qemu_create_nic_bus_devices() David Woodhouse
2024-02-01 16:43 ` [PULL 04/47] hw/pci: add pci_init_nic_devices(), pci_init_nic_in_slot() David Woodhouse
2024-02-01 16:43 ` [PULL 05/47] hw/i386/pc: use qemu_get_nic_info() and pci_init_nic_devices() David Woodhouse
2024-02-01 16:43 ` [PULL 06/47] hw/xen: use qemu_create_nic_bus_devices() to instantiate Xen NICs David Woodhouse
2024-02-01 16:43 ` [PULL 07/47] hw/alpha/dp264: use pci_init_nic_devices() David Woodhouse
2024-02-01 16:43 ` [PULL 08/47] hw/arm/sbsa-ref: " David Woodhouse
2024-02-01 16:43 ` [PULL 09/47] hw/arm/virt: " David Woodhouse
2024-02-01 16:43 ` [PULL 10/47] hw/hppa: " David Woodhouse
2024-02-01 16:43 ` [PULL 11/47] hw/loongarch: " David Woodhouse
2024-02-01 16:43 ` [PULL 12/47] hw/mips/fuloong2e: " David Woodhouse
2024-02-01 16:43 ` [PULL 13/47] hw/mips/malta: " David Woodhouse
2024-02-01 16:43 ` [PULL 14/47] hw/mips/loongson3_virt: " David Woodhouse
2024-02-01 16:43 ` [PULL 15/47] hw/ppc/prep: " David Woodhouse
2024-02-01 16:43 ` [PULL 16/47] hw/ppc/spapr: use qemu_get_nic_info() and pci_init_nic_devices() David Woodhouse
2024-02-01 16:43 ` [PULL 17/47] hw/ppc: use pci_init_nic_devices() David Woodhouse
2024-02-01 16:43 ` [PULL 18/47] hw/sh4/r2d: " David Woodhouse
2024-02-01 16:43 ` [PULL 19/47] hw/sparc64/sun4u: " David Woodhouse
2024-02-01 16:43 ` [PULL 20/47] hw/xtensa/virt: " David Woodhouse
2024-02-01 16:43 ` [PULL 21/47] hw/arm/allwinner: use qemu_configure_nic_device() David Woodhouse
2024-02-01 16:43 ` [PULL 22/47] hw/arm/aspeed: " David Woodhouse
2024-02-01 16:43 ` [PULL 23/47] hw/arm/exynos4: use qemu_create_nic_device() David Woodhouse
2024-02-01 16:43 ` [PULL 24/47] hw/arm/fsl: use qemu_configure_nic_device() David Woodhouse
2024-02-01 16:43 ` David Woodhouse [this message]
2024-02-01 16:43 ` [PULL 26/47] hw/net/lan9118: " David Woodhouse
2024-02-01 16:43 ` [PULL 27/47] hw/arm/highbank: use qemu_create_nic_device() David Woodhouse
2024-02-01 16:43 ` [PULL 28/47] hw/arm/npcm7xx: use qemu_configure_nic_device, allow emc0/emc1 as aliases David Woodhouse
2024-02-01 16:43 ` [PULL 29/47] hw/arm/stellaris: use qemu_find_nic_info() David Woodhouse
2024-02-01 16:43 ` [PULL 30/47] hw/arm: use qemu_configure_nic_device() David Woodhouse
2024-02-01 16:43 ` [PULL 31/47] hw/net/etraxfs-eth: " David Woodhouse
2024-02-01 16:43 ` [PULL 32/47] hw/m68k/mcf5208: use qemu_create_nic_device() David Woodhouse
2024-02-01 16:43 ` [PULL 33/47] hw/m68k/q800: use qemu_find_nic_info() David Woodhouse
2024-02-01 16:43 ` [PULL 34/47] hw/microblaze: use qemu_configure_nic_device() David Woodhouse
2024-02-01 16:44 ` [PULL 35/47] hw/mips/mipssim: use qemu_create_nic_device() David Woodhouse
2024-02-01 16:44 ` [PULL 36/47] hw/mips/jazz: use qemu_find_nic_info() David Woodhouse
2024-02-01 16:44 ` [PULL 37/47] hw/net/lasi_i82596: Re-enable build David Woodhouse
2024-02-01 16:44 ` [PULL 38/47] hw/net/lasi_i82596: use qemu_create_nic_device() David Woodhouse
2024-02-01 16:44 ` [PULL 39/47] hw/openrisc/openrisc_sim: " David Woodhouse
2024-02-01 16:44 ` [PULL 40/47] hw/riscv: use qemu_configure_nic_device() David Woodhouse
2024-02-01 16:44 ` [PULL 41/47] hw/s390x/s390-virtio-ccw: use qemu_create_nic_device() David Woodhouse
2024-02-01 16:44 ` [PULL 42/47] hw/sparc/sun4m: use qemu_find_nic_info() David Woodhouse
2024-02-01 16:44 ` [PULL 43/47] hw/xtensa/xtfpga: use qemu_create_nic_device() David Woodhouse
2024-02-01 16:44 ` [PULL 44/47] net: remove qemu_check_nic_model() David Woodhouse
2024-02-01 16:44 ` [PULL 45/47] hw/pci: remove pci_nic_init_nofail() David Woodhouse
2024-02-01 16:44 ` [PULL 46/47] net: remove qemu_show_nic_models(), qemu_find_nic_model() David Woodhouse
2024-02-01 16:44 ` [PULL 47/47] net: make nb_nics and nd_table[] static in net/net.c David Woodhouse
2024-02-02 15:32 ` [PULL 00/47] nic-config.for-upstream queue Peter Maydell
2024-02-02 15:36 ` David Woodhouse
2024-02-02 15:40 ` Peter Maydell
2024-02-05 6:56 ` Thomas Huth
2024-02-05 10:11 ` Thomas Huth
2024-02-05 10:55 ` Peter Maydell
2024-02-02 16:01 ` David Woodhouse
2024-02-02 16:15 ` Peter Maydell
2024-02-02 17:01 ` David Woodhouse
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20240201164412.785520-26-dwmw2@infradead.org \
--to=dwmw2@infradead.org \
--cc=qemu-devel@nongnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).