From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:46073) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1W8qY6-0006eZ-HZ for qemu-devel@nongnu.org; Thu, 30 Jan 2014 07:16:56 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1W8qXy-0002Dh-Bt for qemu-devel@nongnu.org; Thu, 30 Jan 2014 07:16:50 -0500 Received: from mx1.redhat.com ([209.132.183.28]:52839) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1W8qXy-0002DP-3L for qemu-devel@nongnu.org; Thu, 30 Jan 2014 07:16:42 -0500 From: Markus Armbruster Date: Thu, 30 Jan 2014 13:16:30 +0100 Message-Id: <1391084198-21021-2-git-send-email-armbru@redhat.com> In-Reply-To: <1391084198-21021-1-git-send-email-armbru@redhat.com> References: <1391084198-21021-1-git-send-email-armbru@redhat.com> Subject: [Qemu-devel] [PATCH v3 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, stefanha@redhat.com, agraf@suse.de 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 036cd4a..9087025 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