[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PULL 118/126] hw/ide/piix: Refactor pci_piix_init_ports as pci_piix_ini
From: |
Philippe Mathieu-Daudé |
Subject: |
[PULL 118/126] hw/ide/piix: Refactor pci_piix_init_ports as pci_piix_init_bus per bus |
Date: |
Mon, 27 Feb 2023 15:02:05 +0100 |
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Message-Id: <20230215112712.23110-21-philmd@linaro.org>
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
---
hw/ide/piix.c | 37 ++++++++++++++++++-------------------
1 file changed, 18 insertions(+), 19 deletions(-)
diff --git a/hw/ide/piix.c b/hw/ide/piix.c
index f10bdf39ff..41d60921e3 100644
--- a/hw/ide/piix.c
+++ b/hw/ide/piix.c
@@ -121,7 +121,7 @@ static void piix_ide_reset(DeviceState *dev)
pci_set_byte(pci_conf + 0x20, 0x01); /* BMIBA: 20-23h */
}
-static bool pci_piix_init_ports(PCIIDEState *d, Error **errp)
+static bool pci_piix_init_bus(PCIIDEState *d, unsigned i, Error **errp)
{
static const struct {
int iobase;
@@ -131,24 +131,21 @@ static bool pci_piix_init_ports(PCIIDEState *d, Error
**errp)
{0x1f0, 0x3f6, 14},
{0x170, 0x376, 15},
};
- int i, ret;
+ int ret;
- for (i = 0; i < 2; i++) {
- ide_bus_init(&d->bus[i], sizeof(d->bus[i]), DEVICE(d), i, 2);
- ret = ide_init_ioport(&d->bus[i], NULL, port_info[i].iobase,
- port_info[i].iobase2);
- if (ret) {
- error_setg_errno(errp, -ret, "Failed to realize %s port %u",
- object_get_typename(OBJECT(d)), i);
- return false;
- }
- ide_bus_init_output_irq(&d->bus[i],
- isa_get_irq(NULL, port_info[i].isairq));
-
- bmdma_init(&d->bus[i], &d->bmdma[i], d);
- d->bmdma[i].bus = &d->bus[i];
- ide_bus_register_restart_cb(&d->bus[i]);
+ ide_bus_init(&d->bus[i], sizeof(d->bus[i]), DEVICE(d), i, 2);
+ ret = ide_init_ioport(&d->bus[i], NULL, port_info[i].iobase,
+ port_info[i].iobase2);
+ if (ret) {
+ error_setg_errno(errp, -ret, "Failed to realize %s port %u",
+ object_get_typename(OBJECT(d)), i);
+ return false;
}
+ ide_bus_init_output_irq(&d->bus[i], isa_get_irq(NULL,
port_info[i].isairq));
+
+ bmdma_init(&d->bus[i], &d->bmdma[i], d);
+ d->bmdma[i].bus = &d->bus[i];
+ ide_bus_register_restart_cb(&d->bus[i]);
return true;
}
@@ -165,8 +162,10 @@ static void pci_piix_ide_realize(PCIDevice *dev, Error
**errp)
vmstate_register(VMSTATE_IF(dev), 0, &vmstate_ide_pci, d);
- if (!pci_piix_init_ports(d, errp)) {
- return;
+ for (unsigned i = 0; i < 2; i++) {
+ if (!pci_piix_init_bus(d, i, errp)) {
+ return;
+ }
}
}
--
2.38.1
- [PULL 107/126] hw/ide: Rename ide_set_irq() -> ide_bus_set_irq(), (continued)
- [PULL 107/126] hw/ide: Rename ide_set_irq() -> ide_bus_set_irq(), Philippe Mathieu-Daudé, 2023/02/27
- [PULL 106/126] hw/ide: Un-inline ide_set_irq(), Philippe Mathieu-Daudé, 2023/02/27
- [PULL 108/126] hw/ide: Rename ide_create_drive() -> ide_bus_create_drive(), Philippe Mathieu-Daudé, 2023/02/27
- [PULL 111/126] hw/ide: Rename ide_init2() -> ide_bus_init_output_irq(), Philippe Mathieu-Daudé, 2023/02/27
- [PULL 112/126] hw/ide: Rename idebus_active_if() -> ide_bus_active_if(), Philippe Mathieu-Daudé, 2023/02/27
- [PULL 116/126] hw/ide/piix: Remove unused includes, Philippe Mathieu-Daudé, 2023/02/27
- [PULL 104/126] hw/ide: Remove unused 'qapi/qapi-types-run-state.h', Philippe Mathieu-Daudé, 2023/02/27
- [PULL 109/126] hw/ide: Rename ide_register_restart_cb -> ide_bus_register_restart_cb, Philippe Mathieu-Daudé, 2023/02/27
- [PULL 114/126] hw/ide/ioport: Remove unnecessary includes, Philippe Mathieu-Daudé, 2023/02/27
- [PULL 115/126] hw/ide/pci: Unexport bmdma_active_if(), Philippe Mathieu-Daudé, 2023/02/27
- [PULL 118/126] hw/ide/piix: Refactor pci_piix_init_ports as pci_piix_init_bus per bus,
Philippe Mathieu-Daudé <=
- [PULL 120/126] hw/ide/pci: Add PCIIDEState::isa_irq[], Philippe Mathieu-Daudé, 2023/02/27
- [PULL 123/126] dump: Clean included headers, Philippe Mathieu-Daudé, 2023/02/27
- [PULL 125/126] dump: Add create_win_dump() stub for non-x86 targets, Philippe Mathieu-Daudé, 2023/02/27
- [PULL 110/126] hw/ide: Rename ide_exec_cmd() -> ide_bus_exec_cmd(), Philippe Mathieu-Daudé, 2023/02/27
- [PULL 113/126] hw/ide: Declare ide_get_[geometry/bios_chs_trans] in 'hw/ide/internal.h', Philippe Mathieu-Daudé, 2023/02/27
- [PULL 121/126] dump: Replace tswapN() -> cpu_to_dumpN(), Philippe Mathieu-Daudé, 2023/02/27
- [PULL 119/126] hw/ide/via: Replace magic 2 value by ARRAY_SIZE / MAX_IDE_DEVS, Philippe Mathieu-Daudé, 2023/02/27
- [PULL 122/126] dump: Replace TARGET_PAGE_SIZE -> qemu_target_page_size(), Philippe Mathieu-Daudé, 2023/02/27
- [PULL 124/126] dump: Simplify compiling win_dump.o by introducing win_dump_available(), Philippe Mathieu-Daudé, 2023/02/27
- [PULL 117/126] hw/ide/piix: Pass Error* to pci_piix_init_ports() for better error msg, Philippe Mathieu-Daudé, 2023/02/27