[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH v2 22/24] hw/ide/piix: Pass Error* to pci_piix_init_ports() for b
From: |
Philippe Mathieu-Daudé |
Subject: |
[PATCH v2 22/24] hw/ide/piix: Pass Error* to pci_piix_init_ports() for better error msg |
Date: |
Mon, 20 Feb 2023 10:13:56 +0100 |
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Message-Id: <20230215112712.23110-20-philmd@linaro.org>
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
---
hw/ide/piix.c | 15 +++++++--------
1 file changed, 7 insertions(+), 8 deletions(-)
diff --git a/hw/ide/piix.c b/hw/ide/piix.c
index 5b1455e232..b74f1c77c4 100644
--- a/hw/ide/piix.c
+++ b/hw/ide/piix.c
@@ -122,7 +122,7 @@ static void piix_ide_reset(DeviceState *dev)
pci_set_byte(pci_conf + 0x20, 0x01); /* BMIBA: 20-23h */
}
-static int pci_piix_init_ports(PCIIDEState *d)
+static bool pci_piix_init_ports(PCIIDEState *d, Error **errp)
{
static const struct {
int iobase;
@@ -139,7 +139,9 @@ static int pci_piix_init_ports(PCIIDEState *d)
ret = ide_bus_init_ioport_isa(&d->bus[i], NULL, port_info[i].iobase,
port_info[i].iobase2);
if (ret) {
- return 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));
@@ -149,14 +151,13 @@ static int pci_piix_init_ports(PCIIDEState *d)
ide_bus_register_restart_cb(&d->bus[i]);
}
- return 0;
+ return true;
}
static void pci_piix_ide_realize(PCIDevice *dev, Error **errp)
{
PCIIDEState *d = PCI_IDE(dev);
uint8_t *pci_conf = dev->config;
- int rc;
pci_conf[PCI_CLASS_PROG] = 0x80; // legacy ATA mode
@@ -165,10 +166,8 @@ static void pci_piix_ide_realize(PCIDevice *dev, Error
**errp)
vmstate_register(VMSTATE_IF(dev), 0, &vmstate_ide_pci, d);
- rc = pci_piix_init_ports(d);
- if (rc) {
- error_setg_errno(errp, -rc, "Failed to realize %s",
- object_get_typename(OBJECT(dev)));
+ if (!pci_piix_init_ports(d, errp)) {
+ return;
}
}
--
2.38.1
- [PATCH v2 13/24] hw/ide: Rename ide_register_restart_cb -> ide_bus_register_restart_cb, (continued)
- [PATCH v2 13/24] hw/ide: Rename ide_register_restart_cb -> ide_bus_register_restart_cb, Philippe Mathieu-Daudé, 2023/02/20
- [PATCH v2 14/24] hw/ide: Rename ide_exec_cmd() -> ide_bus_exec_cmd(), Philippe Mathieu-Daudé, 2023/02/20
- [PATCH v2 15/24] hw/ide: Rename ide_init2() -> ide_bus_init_output_irq(), Philippe Mathieu-Daudé, 2023/02/20
- [PATCH v2 16/24] hw/ide: Rename idebus_active_if() -> ide_bus_active_if(), Philippe Mathieu-Daudé, 2023/02/20
- [PATCH v2 20/24] hw/ide/pci: Unexport bmdma_active_if(), Philippe Mathieu-Daudé, 2023/02/20
- [PATCH v2 17/24] hw/ide: Declare ide_get_[geometry/bios_chs_trans] in 'hw/ide/internal.h', Philippe Mathieu-Daudé, 2023/02/20
- [PATCH v2 18/24] hw/ide: Rename ISA specific ide_init_ioport -> ide_bus_init_ioport_isa, Philippe Mathieu-Daudé, 2023/02/20
- [PATCH v2 21/24] hw/ide/piix: Remove unused includes, Philippe Mathieu-Daudé, 2023/02/20
- [PATCH v2 22/24] hw/ide/piix: Pass Error* to pci_piix_init_ports() for better error msg,
Philippe Mathieu-Daudé <=
- [PATCH v2 19/24] hw/ide/ioport: Remove unnecessary includes, Philippe Mathieu-Daudé, 2023/02/20
- [PATCH v2 24/24] hw/ide/ahci: trace ncq write command as write instead of read, Philippe Mathieu-Daudé, 2023/02/20
- [PATCH v2 23/24] hw/ide/piix: Refactor pci_piix_init_ports as pci_piix_init_bus per bus, Philippe Mathieu-Daudé, 2023/02/20
- Re: [PATCH v2 00/24] hw/ide: QOM/QDev housekeeping, Philippe Mathieu-Daudé, 2023/02/24