From nobody Tue Feb 10 19:47:53 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1500394473205510.0096291034537; Tue, 18 Jul 2017 09:14:33 -0700 (PDT) Received: from localhost ([::1]:57579 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dXV8o-0005eP-NC for importer@patchew.org; Tue, 18 Jul 2017 12:14:30 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:45297) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dXV72-0004Jx-Cd for qemu-devel@nongnu.org; Tue, 18 Jul 2017 12:12:41 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dXV6z-0001sl-DH for qemu-devel@nongnu.org; Tue, 18 Jul 2017 12:12:40 -0400 Received: from mx1.redhat.com ([209.132.183.28]:50402) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dXV6z-0001sG-4Q for qemu-devel@nongnu.org; Tue, 18 Jul 2017 12:12:37 -0400 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 23F67C04B952; Tue, 18 Jul 2017 16:12:36 +0000 (UTC) Received: from probe.bos.redhat.com (dhcp-17-231.bos.redhat.com [10.18.17.231]) by smtp.corp.redhat.com (Postfix) with ESMTP id 804437A24A; Tue, 18 Jul 2017 16:12:35 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 23F67C04B952 Authentication-Results: ext-mx07.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx07.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=jsnow@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com 23F67C04B952 From: John Snow To: qemu-devel@nongnu.org Date: Tue, 18 Jul 2017 12:12:27 -0400 Message-Id: <20170718161230.21917-2-jsnow@redhat.com> In-Reply-To: <20170718161230.21917-1-jsnow@redhat.com> References: <20170718161230.21917-1-jsnow@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.31]); Tue, 18 Jul 2017 16:12:36 +0000 (UTC) Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PULL 1/4] ahci: add ahci_get_num_ports X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: peter.maydell@linaro.org, jsnow@redhat.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" Instead of reaching into the PCI state, allow the AHCIDevice to respond with how many ports it has. Signed-off-by: John Snow Reviewed-by: Philippe Mathieu-Daud=C3=A9 Tested-by: Philippe Mathieu-Daud=C3=A9 Message-id: 20170623220926.11479-2-jsnow@redhat.com Signed-off-by: John Snow --- hw/i386/pc_q35.c | 4 ++-- hw/ide/ahci.c | 8 ++++++++ hw/mips/boston.c | 4 ++-- include/hw/ide/ahci.h | 1 + 4 files changed, 13 insertions(+), 4 deletions(-) diff --git a/hw/i386/pc_q35.c b/hw/i386/pc_q35.c index 1653a47..169a214 100644 --- a/hw/i386/pc_q35.c +++ b/hw/i386/pc_q35.c @@ -242,8 +242,8 @@ static void pc_q35_init(MachineState *machine) true, "ich9-ahci"); idebus[0] =3D qdev_get_child_bus(&ahci->qdev, "ide.0"); idebus[1] =3D qdev_get_child_bus(&ahci->qdev, "ide.1"); - g_assert(MAX_SATA_PORTS =3D=3D ICH_AHCI(ahci)->ahci.ports); - ide_drive_get(hd, ICH_AHCI(ahci)->ahci.ports); + g_assert(MAX_SATA_PORTS =3D=3D ahci_get_num_ports(ahci)); + ide_drive_get(hd, ahci_get_num_ports(ahci)); ahci_ide_create_devs(ahci, hd); } else { idebus[0] =3D idebus[1] =3D NULL; diff --git a/hw/ide/ahci.c b/hw/ide/ahci.c index 874d3fe..e3cdbc8 100644 --- a/hw/ide/ahci.c +++ b/hw/ide/ahci.c @@ -1833,6 +1833,14 @@ static void sysbus_ahci_register_types(void) =20 type_init(sysbus_ahci_register_types) =20 +int32_t ahci_get_num_ports(PCIDevice *dev) +{ + AHCIPCIState *d =3D ICH_AHCI(dev); + AHCIState *ahci =3D &d->ahci; + + return ahci->ports; +} + void ahci_ide_create_devs(PCIDevice *dev, DriveInfo **hd) { AHCIPCIState *d =3D ICH_AHCI(dev); diff --git a/hw/mips/boston.c b/hw/mips/boston.c index 7985c60..776ee28 100644 --- a/hw/mips/boston.c +++ b/hw/mips/boston.c @@ -538,8 +538,8 @@ static void boston_mach_init(MachineState *machine) ahci =3D pci_create_simple_multifunction(&PCI_BRIDGE(&pcie2->root)->se= c_bus, PCI_DEVFN(0, 0), true, TYPE_ICH9_AHCI); - g_assert(ARRAY_SIZE(hd) =3D=3D ICH_AHCI(ahci)->ahci.ports); - ide_drive_get(hd, ICH_AHCI(ahci)->ahci.ports); + g_assert(ARRAY_SIZE(hd) =3D=3D ahci_get_num_ports(ahci)); + ide_drive_get(hd, ahci_get_num_ports(ahci)); ahci_ide_create_devs(ahci, hd); =20 if (machine->firmware) { diff --git a/include/hw/ide/ahci.h b/include/hw/ide/ahci.h index 0ca7c65..f866bbf 100644 --- a/include/hw/ide/ahci.h +++ b/include/hw/ide/ahci.h @@ -372,6 +372,7 @@ void ahci_uninit(AHCIState *s); =20 void ahci_reset(AHCIState *s); =20 +int32_t ahci_get_num_ports(PCIDevice *dev); void ahci_ide_create_devs(PCIDevice *dev, DriveInfo **hd); =20 #define TYPE_SYSBUS_AHCI "sysbus-ahci" --=20 2.9.4