From nobody Mon Feb 9 20:12:22 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org ARC-Seal: i=1; a=rsa-sha256; t=1557728827; cv=none; d=zoho.com; s=zohoarc; b=VJLvVOZCbGgBd8gumlpS8/GRm+bmf4dcUZ2V9ujNUiMqhErVsV2/ZO0s8trF/QXar6+YY//VO1T51Ke1IJ4XNRtXCu6JxAFZIQQ52c/ICGDqkcEG2izetbyef6Tk6oFEdKTrs3xrRqHr5M9SyAAK9BXYNfS7wK1h0ltsgJTAY+o= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1557728827; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results; bh=HAVRvk9kcE/SIyW+VDkBdwZ/vK3bYaLAKgFjnEKkjQ0=; b=jJSpmt9Ktky3rI/G+5FI74gjitLB3SoFOHPZE/TCLsE6nE0rC1CBL17uH9qfVJ/BexT8PaWsm/+WubMZ2nQIEJJxOhu41FJh020hzQPEstcWtzOZDYYcqfpljkIXQ1bgAvoNHoaDSZJvG36TFGebijCxqS5LCqSqTda2S4lAtuY= ARC-Authentication-Results: i=1; mx.zoho.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1557728827098588.3083732198086; Sun, 12 May 2019 23:27:07 -0700 (PDT) Received: from localhost ([127.0.0.1]:51841 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hQ4QR-0000aQ-4l for importer@patchew.org; Mon, 13 May 2019 02:27:03 -0400 Received: from eggs.gnu.org ([209.51.188.92]:35170) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hQ4JT-0002hP-Dn for qemu-devel@nongnu.org; Mon, 13 May 2019 02:19:52 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hQ4JS-0004NR-22 for qemu-devel@nongnu.org; Mon, 13 May 2019 02:19:51 -0400 Received: from ozlabs.org ([203.11.71.1]:43219) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1hQ4JR-0004Lb-Ms; Mon, 13 May 2019 02:19:49 -0400 Received: by ozlabs.org (Postfix, from userid 1007) id 452Vz30kjtz9sNC; Mon, 13 May 2019 16:19:42 +1000 (AEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gibson.dropbear.id.au; s=201602; t=1557728383; bh=mybf5FDA6IImZhZVbU1H3yLsmp5YpbEYQgGyqUuw+t8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ZMeXejUachaIiRBjZKphqRAm/Ew0gW4tDTV4cutULxCDmMRdzbFJi9fI+gWKLkh5I G/5xXpwUmsndvImUAcZO5Q6xvzK41bYyVsDNpTMCasEsD+EQJLzlbQ2B5yc3t2owOm b2kuAiqXMD+XIfvsarjbWxiMBi1HcCzQsaEqw2G4= From: David Gibson To: mst@redhat.com, qemu-devel@nongnu.org Date: Mon, 13 May 2019 16:19:39 +1000 Message-Id: <20190513061939.3464-6-david@gibson.dropbear.id.au> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190513061939.3464-1-david@gibson.dropbear.id.au> References: <20190513061939.3464-1-david@gibson.dropbear.id.au> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 203.11.71.1 Subject: [Qemu-devel] [PATCH v4 5/5] pci: Fold pci_get_bus_devfn() into its sole caller 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: aik@ozlabs.ru, Mark Cave-Ayland , groug@kaod.org, qemu-ppc@nongnu.org, David Gibson Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" The only remaining caller of pci_get_bus_devfn() is pci_nic_init_nofail(), itself an old compatibility function. Fold the two together to avoid re-using the stale interface. While we're there replace the explicit fprintf()s with error_report(). Signed-off-by: David Gibson Reviewed-by: Greg Kurz --- hw/pci/pci.c | 60 ++++++++++++++++++++++++---------------------------- 1 file changed, 28 insertions(+), 32 deletions(-) diff --git a/hw/pci/pci.c b/hw/pci/pci.c index 7e5f8d001b..d3893bdfe1 100644 --- a/hw/pci/pci.c +++ b/hw/pci/pci.c @@ -723,37 +723,6 @@ static int pci_parse_devaddr(const char *addr, int *do= mp, int *busp, return 0; } =20 -static PCIBus *pci_get_bus_devfn(int *devfnp, PCIBus *root, - const char *devaddr) -{ - int dom, bus; - unsigned slot; - - if (!root) { - fprintf(stderr, "No primary PCI bus\n"); - return NULL; - } - - assert(!root->parent_dev); - - if (!devaddr) { - *devfnp =3D -1; - return pci_find_bus_nr(root, 0); - } - - if (pci_parse_devaddr(devaddr, &dom, &bus, &slot, NULL) < 0) { - return NULL; - } - - if (dom !=3D 0) { - fprintf(stderr, "No support for non-zero PCI domains\n"); - return NULL; - } - - *devfnp =3D PCI_DEVFN(slot, 0); - return pci_find_bus_nr(root, bus); -} - static void pci_init_cmask(PCIDevice *dev) { pci_set_word(dev->cmask + PCI_VENDOR_ID, 0xffff); @@ -1895,6 +1864,8 @@ PCIDevice *pci_nic_init_nofail(NICInfo *nd, PCIBus *r= ootbus, DeviceState *dev; int devfn; int i; + int dom, busnr; + unsigned slot; =20 if (nd->model && !strcmp(nd->model, "virtio")) { g_free(nd->model); @@ -1928,7 +1899,32 @@ PCIDevice *pci_nic_init_nofail(NICInfo *nd, PCIBus *= rootbus, exit(1); } =20 - bus =3D pci_get_bus_devfn(&devfn, rootbus, devaddr); + if (!rootbus) { + error_report("No primary PCI bus"); + exit(1); + } + + assert(!rootbus->parent_dev); + + if (!devaddr) { + devfn =3D -1; + busnr =3D 0; + } else { + if (pci_parse_devaddr(devaddr, &dom, &busnr, &slot, NULL) < 0) { + error_report("Invalid PCI device address %s for device %s", + devaddr, nd->model); + exit(1); + } + + if (dom !=3D 0) { + error_report("No support for non-zero PCI domains"); + exit(1); + } + + devfn =3D PCI_DEVFN(slot, 0); + } + + bus =3D pci_find_bus_nr(rootbus, busnr); if (!bus) { error_report("Invalid PCI device address %s for device %s", devaddr, nd->model); --=20 2.21.0