From: Markus Armbruster <arm...@redhat.com>
Signed-off-by: Markus Armbruster <arm...@redhat.com> --- hw/ide/core.c | 2 +- hw/ide/internal.h | 3 +-- hw/ide/qdev.c | 12 +++--------- 3 files changed, 5 insertions(+), 12 deletions(-) diff --git a/hw/ide/core.c b/hw/ide/core.c index e1f4c33..2d382b2 100644 --- a/hw/ide/core.c +++ b/hw/ide/core.c @@ -79,7 +79,7 @@ static void ide_identify(IDEState *s) { uint16_t *p; unsigned int oldsize; - IDEDevice *dev = s->unit ? s->bus->slave : s->bus->master; + IDEDevice *dev = s->dev; if (s->identify_set) { memcpy(s->io_buffer, s->identify_data, sizeof(s->identify_data)); diff --git a/hw/ide/internal.h b/hw/ide/internal.h index 0567a52..908d91d 100644 --- a/hw/ide/internal.h +++ b/hw/ide/internal.h @@ -341,6 +341,7 @@ enum ide_dma_cmd { /* NOTE: IDEState represents in fact one drive */ struct IDEState { IDEBus *bus; + IDEDevice *dev; uint8_t unit; /* ide config */ IDEDriveKind drive_kind; @@ -447,8 +448,6 @@ struct IDEDMA { struct IDEBus { BusState qbus; - IDEDevice *master; - IDEDevice *slave; IDEState ifs[2]; int bus_id; int max_units; diff --git a/hw/ide/qdev.c b/hw/ide/qdev.c index 18c4b7e..6ea1698 100644 --- a/hw/ide/qdev.c +++ b/hw/ide/qdev.c @@ -76,7 +76,7 @@ static int ide_qdev_init(DeviceState *qdev) goto err; } if (dev->unit == -1) { - dev->unit = bus->master ? 1 : 0; + dev->unit = bus->ifs[0].dev ? 1 : 0; } if (dev->unit >= bus->max_units) { @@ -87,18 +87,12 @@ static int ide_qdev_init(DeviceState *qdev) switch (dev->unit) { case 0: - if (bus->master) { - error_report("IDE unit %d is in use", dev->unit); - goto err; - } - bus->master = dev; - break; case 1: - if (bus->slave) { + if (bus->ifs[dev->unit].dev) { error_report("IDE unit %d is in use", dev->unit); goto err; } - bus->slave = dev; + bus->ifs[dev->unit].dev = dev; break; default: error_report("Invalid IDE unit %d", dev->unit); -- 1.8.1.4