From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:34494) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Vj4VP-0000mx-42 for qemu-devel@nongnu.org; Wed, 20 Nov 2013 04:55:37 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Vj4VI-00028j-IU for qemu-devel@nongnu.org; Wed, 20 Nov 2013 04:55:30 -0500 Received: from mx1.redhat.com ([209.132.183.28]:46568) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Vj4VI-00028S-9p for qemu-devel@nongnu.org; Wed, 20 Nov 2013 04:55:24 -0500 From: armbru@redhat.com Date: Wed, 20 Nov 2013 10:55:12 +0100 Message-Id: <1384941320-30987-2-git-send-email-armbru@redhat.com> In-Reply-To: <1384941320-30987-1-git-send-email-armbru@redhat.com> References: <1384941320-30987-1-git-send-email-armbru@redhat.com> Subject: [Qemu-devel] [PATCH v2 1/9] ide: Move IDEDevice pointer from IDEBus to IDEState List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: kwolf@redhat.com, afaerber@suse.de From: Markus Armbruster Signed-off-by: Markus Armbruster --- 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