From patchwork Mon Dec 6 14:55:48 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Greg KH X-Patchwork-Id: 522218 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 2DB7AC433FE for ; Mon, 6 Dec 2021 15:08:31 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1348795AbhLFPL5 (ORCPT ); Mon, 6 Dec 2021 10:11:57 -0500 Received: from dfw.source.kernel.org ([139.178.84.217]:58790 "EHLO dfw.source.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1346259AbhLFPJY (ORCPT ); Mon, 6 Dec 2021 10:09:24 -0500 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id A09C361319; Mon, 6 Dec 2021 15:05:55 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 87A70C341C2; Mon, 6 Dec 2021 15:05:54 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1638803155; bh=B4aVEs97PJ/ebdv8HLDrNrMEw/5l8CAoAnLcDD81yfA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=CoZvoDg5E5mDq/73nnWex5s3Ln72b5RSB3b5nUTtzJuSeKzqOTEPBL3xcAg3anq8V 2ao/BV475WbhL7wFmRMAm0D48pz4HR7oXVu3T91/UkinQlD5pPGiJbUxRRg4XyAsdW MPBEg0F5qXAkjIftwhlSz7YBsXd8GxAzIxpDgzv8= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Thomas Petazzoni , Lorenzo Pieralisi , =?utf-8?q?Marek_Beh=C3=BAn?= Subject: [PATCH 4.14 040/106] PCI: aardvark: Introduce an advk_pcie_valid_device() helper Date: Mon, 6 Dec 2021 15:55:48 +0100 Message-Id: <20211206145556.766850379@linuxfoundation.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20211206145555.386095297@linuxfoundation.org> References: <20211206145555.386095297@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: stable@vger.kernel.org From: Thomas Petazzoni commit 248d4e59616c632f37f04c233eec6d5008384926 upstream. In other to mimic other PCIe host controller drivers, introduce an advk_pcie_valid_device() helper, used in the configuration read/write functions. Signed-off-by: Thomas Petazzoni [lorenzo.pieralisi@arm.com: updated host->controller dir move] Signed-off-by: Lorenzo Pieralisi Signed-off-by: Marek BehĂșn Signed-off-by: Greg Kroah-Hartman --- drivers/pci/host/pci-aardvark.c | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) --- a/drivers/pci/host/pci-aardvark.c +++ b/drivers/pci/host/pci-aardvark.c @@ -592,6 +592,15 @@ static bool advk_pcie_pio_is_running(str return false; } +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) + return false; + + return true; +} + static int advk_pcie_rd_conf(struct pci_bus *bus, u32 devfn, int where, int size, u32 *val) { @@ -599,7 +608,7 @@ static int advk_pcie_rd_conf(struct pci_ u32 reg; int ret; - if ((bus->number == pcie->root_bus_nr) && PCI_SLOT(devfn) != 0) { + if (!advk_pcie_valid_device(pcie, bus, devfn)) { *val = 0xffffffff; return PCIBIOS_DEVICE_NOT_FOUND; } @@ -660,7 +669,7 @@ static int advk_pcie_wr_conf(struct pci_ int offset; int ret; - if ((bus->number == pcie->root_bus_nr) && PCI_SLOT(devfn) != 0) + if (!advk_pcie_valid_device(pcie, bus, devfn)) return PCIBIOS_DEVICE_NOT_FOUND; if (where % size)