Skip to content

Commit

Permalink
hw: Simplify calls to pci_nic_init_nofail()
Browse files Browse the repository at this point in the history
pci_nic_init_nofail() calls qemu_find_nic_model(), and this function
sets nd->model = g_strdup(default_model) if it has not been initialized
yet. So we don't have to set nd->model to the default_nic in the
calling sites.

Signed-off-by: Thomas Huth <thuth@redhat.com>
Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>
  • Loading branch information
huth authored and Michael Tokarev committed Jul 8, 2023
1 parent c35d937 commit b697a48
Show file tree
Hide file tree
Showing 5 changed files with 5 additions and 35 deletions.
8 changes: 1 addition & 7 deletions hw/arm/sbsa-ref.c
Original file line number Diff line number Diff line change
Expand Up @@ -689,13 +689,7 @@ static void create_pcie(SBSAMachineState *sms)
pci = PCI_HOST_BRIDGE(dev);
if (pci->bus) {
for (i = 0; i < nb_nics; i++) {
NICInfo *nd = &nd_table[i];

if (!nd->model) {
nd->model = g_strdup(mc->default_nic);
}

pci_nic_init_nofail(nd, pci->bus, nd->model, NULL);
pci_nic_init_nofail(&nd_table[i], pci->bus, mc->default_nic, NULL);
}
}

Expand Down
8 changes: 1 addition & 7 deletions hw/arm/virt.c
Original file line number Diff line number Diff line change
Expand Up @@ -1479,13 +1479,7 @@ static void create_pcie(VirtMachineState *vms)
vms->bus = pci->bus;
if (vms->bus) {
for (i = 0; i < nb_nics; i++) {
NICInfo *nd = &nd_table[i];

if (!nd->model) {
nd->model = g_strdup(mc->default_nic);
}

pci_nic_init_nofail(nd, pci->bus, nd->model, NULL);
pci_nic_init_nofail(&nd_table[i], pci->bus, mc->default_nic, NULL);
}
}

Expand Down
8 changes: 1 addition & 7 deletions hw/loongarch/virt.c
Original file line number Diff line number Diff line change
Expand Up @@ -547,13 +547,7 @@ static void loongarch_devices_init(DeviceState *pch_pic, LoongArchMachineState *

/* Network init */
for (i = 0; i < nb_nics; i++) {
NICInfo *nd = &nd_table[i];

if (!nd->model) {
nd->model = g_strdup(mc->default_nic);
}

pci_nic_init_nofail(nd, pci_bus, nd->model, NULL);
pci_nic_init_nofail(&nd_table[i], pci_bus, mc->default_nic, NULL);
}

/*
Expand Down
8 changes: 1 addition & 7 deletions hw/mips/loongson3_virt.c
Original file line number Diff line number Diff line change
Expand Up @@ -454,13 +454,7 @@ static inline void loongson3_virt_devices_init(MachineState *machine,
}

for (i = 0; i < nb_nics; i++) {
NICInfo *nd = &nd_table[i];

if (!nd->model) {
nd->model = g_strdup(mc->default_nic);
}

pci_nic_init_nofail(nd, pci_bus, nd->model, NULL);
pci_nic_init_nofail(&nd_table[i], pci_bus, mc->default_nic, NULL);
}
}

Expand Down
8 changes: 1 addition & 7 deletions hw/xtensa/virt.c
Original file line number Diff line number Diff line change
Expand Up @@ -103,13 +103,7 @@ static void create_pcie(MachineState *ms, CPUXtensaState *env, int irq_base,
pci = PCI_HOST_BRIDGE(dev);
if (pci->bus) {
for (i = 0; i < nb_nics; i++) {
NICInfo *nd = &nd_table[i];

if (!nd->model) {
nd->model = g_strdup(mc->default_nic);
}

pci_nic_init_nofail(nd, pci->bus, nd->model, NULL);
pci_nic_init_nofail(&nd_table[i], pci->bus, mc->default_nic, NULL);
}
}
}
Expand Down

0 comments on commit b697a48

Please sign in to comment.