From patchwork Wed Jul 22 02:24:59 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Rob Herring (Arm)" X-Patchwork-Id: 11677043 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 9361C14E3 for ; Wed, 22 Jul 2020 02:26:27 +0000 (UTC) Received: from merlin.infradead.org (merlin.infradead.org [205.233.59.134]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 5017A207BB for ; Wed, 22 Jul 2020 02:26:27 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="puUHxalJ" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 5017A207BB Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=kernel.org Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-mediatek-bounces+patchwork-linux-mediatek=patchwork.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=merlin.20170209; h=Sender:Content-Transfer-Encoding: Content-Type:Cc:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To:Message-Id:Date: Subject:To:From:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=HPMPJ458B3gPr4hcWjpTuyh0uZElYmAdIBYYGuUFZgU=; b=puUHxalJBIp9XAYec76ooIBkb iBi9vJBVkkU6TGvhTQM4rf0PN+pS5eD8JBfxgrZ6g8L0DK72ueBSJpTGv+RooZDXjHIqDVMq6bRS7 rJmEFkBnifvRu8aTfIxGna8TTiyiOsnAwMyXmPYXtg6r4PfAC8UfCktp0BsfDR6ps6+JurShQTvby mDCU4f8l19gR+hP3LhBEy3THjEGOP9HTtHeFm1+0MSzFINhybN6MSEju9vfpbKrCasFm2O7tbRaE3 BK/CExHC13BYHVZ9El0fLrOZLfh3LFiyHSbNtTDdaRSIkOD+qGm8I8rx7X2uBwrrf7+PGmkndtoIU 50uSjJumw==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1jy4Sc-00043m-2t; Wed, 22 Jul 2020 02:26:22 +0000 Received: from mail-io1-f68.google.com ([209.85.166.68]) by merlin.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1jy4Ro-0003fi-15; Wed, 22 Jul 2020 02:25:33 +0000 Received: by mail-io1-f68.google.com with SMTP id d18so894921ion.0; Tue, 21 Jul 2020 19:25:31 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=dM76I8T2hvU/uGGdUwBCUr17ZUHx72+ziEfU2vyCYNg=; b=cqwBJrrnf3XEgigMI8VnbHE4O4gRbfJ3etL2V4rQEctUktIPU4Hec9LVNibkucny7/ 7XaBJFlac9woThxt8ox0lI7FGDHTGj3Y6k4pZr2heKQvoj6Z6RtfP6J7dSfOKjkdUtCa /hpTKTPwinEiGDWkeOSouL1i+jiBjwYsh1jVFahHy8FVZNFoNMOrTMNj4XgssPlvEcqs PKg19+aaOZEJorR6tnMcbwLU3JlTiqRttiRBm2bYiwjh4GLcXq6/vVskAmdfNdZzwIn0 +8uoBVHfYqJvJaILeLNJJ87+9WFC1YXS0J+KUlNke/QKp0hJwptcg6QdjG/2pwwce7Lg yAsg== X-Gm-Message-State: AOAM531Kq4eCDDvemh9LIDKzE3HOfmNne22D8OJad0htXOhWaajiHFqr 7pL8SfAPRtYJvMaVnD4C/Q== X-Google-Smtp-Source: ABdhPJwcM6hSvOl1VwpNPgxDhDu2K5qss0HSHlvrXTBU5Uq0xUO+ETk79Jm1CUbZAU/HX2ngncgWkQ== X-Received: by 2002:a92:9a4f:: with SMTP id t76mr30984574ili.174.1595384731436; Tue, 21 Jul 2020 19:25:31 -0700 (PDT) Received: from xps15.herring.priv ([64.188.179.252]) by smtp.googlemail.com with ESMTPSA id y2sm11687981iox.22.2020.07.21.19.25.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 21 Jul 2020 19:25:30 -0700 (PDT) From: Rob Herring To: Bjorn Helgaas , Lorenzo Pieralisi Subject: [PATCH 04/19] PCI: aardvark: Use pci_is_root_bus() to check if bus is root bus Date: Tue, 21 Jul 2020 20:24:59 -0600 Message-Id: <20200722022514.1283916-5-robh@kernel.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20200722022514.1283916-1-robh@kernel.org> References: <20200722022514.1283916-1-robh@kernel.org> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20200721_222532_162500_6E5FE5C3 X-CRM114-Status: GOOD ( 14.12 ) X-Spam-Score: 0.3 (/) X-Spam-Report: SpamAssassin version 3.4.4 on merlin.infradead.org summary: Content analysis details: (0.3 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at https://www.dnswl.org/, no trust [209.85.166.68 listed in list.dnswl.org] -0.0 RCVD_IN_MSPIKE_H2 RBL: Average reputation (+2) [209.85.166.68 listed in wl.mailspike.net] 0.2 FREEMAIL_ENVFROM_END_DIGIT Envelope-from freemail username ends in digit [robherring2[at]gmail.com] 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record 0.0 HEADER_FROM_DIFFERENT_DOMAINS From and EnvelopeFrom 2nd level mail domains are different 0.0 FREEMAIL_FROM Sender email is commonly abused enduser mail provider [robherring2[at]gmail.com] -0.0 SPF_PASS SPF: sender matches SPF record 0.0 FREEMAIL_FORGED_FROMDOMAIN 2nd level domains in From and EnvelopeFrom freemail headers are different X-BeenThere: linux-mediatek@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Heiko Stuebner , Karthikeyan Mitran , linux-pci@vger.kernel.org, Shawn Lin , Thierry Reding , Thomas Petazzoni , Fabio Estevam , Marek Vasut , Linus Walleij , Ryder Lee , Will Deacon , Michal Simek , Jonathan Hunter , linux-rockchip@lists.infradead.org, Murali Karicheri , NXP Linux Team , Hou Zhiqiang , Richard Zhu , Sascha Hauer , linux-mediatek@lists.infradead.org, linux-tegra@vger.kernel.org, linux-arm-kernel@lists.infradead.org, Gustavo Pimentel , Yoshihiro Shimoda , linux-renesas-soc@vger.kernel.org, Tom Joseph , Pengutronix Kernel Team , Jingoo Han , Shawn Guo , Lucas Stach Sender: "Linux-mediatek" Errors-To: linux-mediatek-bounces+patchwork-linux-mediatek=patchwork.kernel.org@lists.infradead.org Use pci_is_root_bus() rather than tracking the root bus number to determine if the bus is the root bus or not. This removes storing duplicated data as well as the need for the host bridge driver to have to care about the bus numbers in most cases. Cc: Thomas Petazzoni Cc: Lorenzo Pieralisi Cc: Bjorn Helgaas Signed-off-by: Rob Herring --- drivers/pci/controller/pci-aardvark.c | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/drivers/pci/controller/pci-aardvark.c b/drivers/pci/controller/pci-aardvark.c index f38663af795c..07d4a75b5c8f 100644 --- a/drivers/pci/controller/pci-aardvark.c +++ b/drivers/pci/controller/pci-aardvark.c @@ -195,7 +195,6 @@ struct advk_pcie { DECLARE_BITMAP(msi_used, MSI_IRQ_NUM); struct mutex msi_used_lock; u16 msi_msg; - int root_bus_nr; int link_gen; struct pci_bridge_emul bridge; struct gpio_desc *reset_gpio; @@ -641,7 +640,7 @@ static void advk_sw_pci_bridge_init(struct advk_pcie *pcie) static bool advk_pcie_valid_device(struct advk_pcie *pcie, struct pci_bus *bus, int devfn) { - if ((bus->number == pcie->root_bus_nr) && PCI_SLOT(devfn) != 0) + if (pci_is_root_bus(bus) && PCI_SLOT(devfn) != 0) return false; return true; @@ -659,7 +658,7 @@ static int advk_pcie_rd_conf(struct pci_bus *bus, u32 devfn, return PCIBIOS_DEVICE_NOT_FOUND; } - if (bus->number == pcie->root_bus_nr) + if (pci_is_root_bus(bus)) return pci_bridge_emul_conf_read(&pcie->bridge, where, size, val); @@ -670,7 +669,7 @@ static int advk_pcie_rd_conf(struct pci_bus *bus, u32 devfn, /* Program the control register */ reg = advk_readl(pcie, PIO_CTRL); reg &= ~PIO_CTRL_TYPE_MASK; - if (bus->primary == pcie->root_bus_nr) + if (pci_is_root_bus(bus->parent)) reg |= PCIE_CONFIG_RD_TYPE0; else reg |= PCIE_CONFIG_RD_TYPE1; @@ -715,7 +714,7 @@ static int advk_pcie_wr_conf(struct pci_bus *bus, u32 devfn, if (!advk_pcie_valid_device(pcie, bus, devfn)) return PCIBIOS_DEVICE_NOT_FOUND; - if (bus->number == pcie->root_bus_nr) + if (pci_is_root_bus(bus)) return pci_bridge_emul_conf_write(&pcie->bridge, where, size, val); @@ -729,7 +728,7 @@ static int advk_pcie_wr_conf(struct pci_bus *bus, u32 devfn, /* Program the control register */ reg = advk_readl(pcie, PIO_CTRL); reg &= ~PIO_CTRL_TYPE_MASK; - if (bus->primary == pcie->root_bus_nr) + if (pci_is_root_bus(bus->parent)) reg |= PCIE_CONFIG_WR_TYPE0; else reg |= PCIE_CONFIG_WR_TYPE1; @@ -1139,7 +1138,7 @@ static int advk_pcie_probe(struct platform_device *pdev) dev_err(dev, "Failed to parse resources\n"); return ret; } - pcie->root_bus_nr = bus->start; + bridge->busnr = bus->start; pcie->reset_gpio = devm_gpiod_get_from_of_node(dev, dev->of_node, "reset-gpios", 0,