From patchwork Fri Jun 4 16:32:58 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kevin Wolf X-Patchwork-Id: 54642 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [199.232.76.165]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 01C38B7D2E for ; Sat, 5 Jun 2010 03:02:02 +1000 (EST) Received: from localhost ([127.0.0.1]:57257 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1OKaHO-0004EQ-JQ for incoming@patchwork.ozlabs.org; Fri, 04 Jun 2010 13:01:58 -0400 Received: from [140.186.70.92] (port=45167 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1OKZtk-00082k-IM for qemu-devel@nongnu.org; Fri, 04 Jun 2010 12:37:36 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.69) (envelope-from ) id 1OKZtf-0002mi-7S for qemu-devel@nongnu.org; Fri, 04 Jun 2010 12:37:32 -0400 Received: from mx1.redhat.com ([209.132.183.28]:57582) by eggs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1OKZte-0002mI-Si for qemu-devel@nongnu.org; Fri, 04 Jun 2010 12:37:27 -0400 Received: from int-mx04.intmail.prod.int.phx2.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.17]) by mx1.redhat.com (8.13.8/8.13.8) with ESMTP id o54GbIub026701 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Fri, 4 Jun 2010 12:37:24 -0400 Received: from localhost.localdomain (vpn2-9-144.ams2.redhat.com [10.36.9.144]) by int-mx04.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id o54GXWSr032074; Fri, 4 Jun 2010 12:35:42 -0400 From: Kevin Wolf To: anthony@codemonkey.ws Date: Fri, 4 Jun 2010 18:32:58 +0200 Message-Id: <1275669195-28312-11-git-send-email-kwolf@redhat.com> In-Reply-To: <1275669195-28312-1-git-send-email-kwolf@redhat.com> References: <1275669195-28312-1-git-send-email-kwolf@redhat.com> X-Scanned-By: MIMEDefang 2.67 on 10.5.11.17 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. Cc: kwolf@redhat.com, qemu-devel@nongnu.org Subject: [Qemu-devel] [PATCH 10/27] ide: Remove redundant IDEState member conf X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org From: Markus Armbruster Commit 428c149b added IDEState member conf to let commit 0009baf1 find the BlockConf from there. It exists only for qdev drives, created via ide_drive_initfn(), not for drives created via ide_init2(). But for a qdev drive, we can just as well reach its IDEDevice, which contains the BlockConf. Do that, and revert the parts of commit 428c149b that add IDEState member conf. Signed-off-by: Markus Armbruster Signed-off-by: Kevin Wolf --- hw/ide/core.c | 16 +++++++--------- hw/ide/internal.h | 4 +--- hw/ide/qdev.c | 3 +-- 3 files changed, 9 insertions(+), 14 deletions(-) diff --git a/hw/ide/core.c b/hw/ide/core.c index 066fecb..c3334b1 100644 --- a/hw/ide/core.c +++ b/hw/ide/core.c @@ -98,6 +98,7 @@ static void ide_identify(IDEState *s) { uint16_t *p; unsigned int oldsize; + IDEDevice *dev; if (s->identify_set) { memcpy(s->io_buffer, s->identify_data, sizeof(s->identify_data)); @@ -165,8 +166,9 @@ static void ide_identify(IDEState *s) put_le16(p + 101, s->nb_sectors >> 16); put_le16(p + 102, s->nb_sectors >> 32); put_le16(p + 103, s->nb_sectors >> 48); - if (s->conf && s->conf->physical_block_size) - put_le16(p + 106, 0x6000 | get_physical_block_exp(s->conf)); + dev = s->unit ? s->bus->slave : s->bus->master; + if (dev && dev->conf.physical_block_size) + put_le16(p + 106, 0x6000 | get_physical_block_exp(&dev->conf)); memcpy(s->identify_data, p, sizeof(s->identify_data)); s->identify_set = 1; @@ -2594,8 +2596,7 @@ void ide_bus_reset(IDEBus *bus) ide_clear_hob(bus); } -void ide_init_drive(IDEState *s, DriveInfo *dinfo, BlockConf *conf, - const char *version) +void ide_init_drive(IDEState *s, DriveInfo *dinfo, const char *version) { int cylinders, heads, secs; uint64_t nb_sectors; @@ -2620,9 +2621,6 @@ void ide_init_drive(IDEState *s, DriveInfo *dinfo, BlockConf *conf, } strncpy(s->drive_serial_str, drive_get_serial(s->bs), sizeof(s->drive_serial_str)); - if (conf) { - s->conf = conf; - } } if (strlen(s->drive_serial_str) == 0) snprintf(s->drive_serial_str, sizeof(s->drive_serial_str), @@ -2653,9 +2651,9 @@ void ide_init2(IDEBus *bus, DriveInfo *hd0, DriveInfo *hd1, s->sector_write_timer = qemu_new_timer(vm_clock, ide_sector_write_timer_cb, s); if (i == 0) - ide_init_drive(s, hd0, NULL, NULL); + ide_init_drive(s, hd0, NULL); if (i == 1) - ide_init_drive(s, hd1, NULL, NULL); + ide_init_drive(s, hd1, NULL); } bus->irq = irq; } diff --git a/hw/ide/internal.h b/hw/ide/internal.h index b4554ce..cf71019 100644 --- a/hw/ide/internal.h +++ b/hw/ide/internal.h @@ -398,7 +398,6 @@ struct IDEState { /* set for lba48 access */ uint8_t lba48; BlockDriverState *bs; - BlockConf *conf; char version[9]; /* ATAPI specific */ uint8_t sense_key; @@ -555,8 +554,7 @@ uint32_t ide_data_readw(void *opaque, uint32_t addr); void ide_data_writel(void *opaque, uint32_t addr, uint32_t val); uint32_t ide_data_readl(void *opaque, uint32_t addr); -void ide_init_drive(IDEState *s, DriveInfo *dinfo, BlockConf *conf, - const char *version); +void ide_init_drive(IDEState *s, DriveInfo *dinfo, const char *version); void ide_init2(IDEBus *bus, DriveInfo *hd0, DriveInfo *hd1, qemu_irq irq); void ide_init_ioport(IDEBus *bus, int iobase, int iobase2); diff --git a/hw/ide/qdev.c b/hw/ide/qdev.c index b18693d..9ebb906 100644 --- a/hw/ide/qdev.c +++ b/hw/ide/qdev.c @@ -99,8 +99,7 @@ typedef struct IDEDrive { static int ide_drive_initfn(IDEDevice *dev) { IDEBus *bus = DO_UPCAST(IDEBus, qbus, dev->qdev.parent_bus); - ide_init_drive(bus->ifs + dev->unit, dev->conf.dinfo, &dev->conf, - dev->version); + ide_init_drive(bus->ifs + dev->unit, dev->conf.dinfo, dev->version); return 0; }