From nobody Tue Dec 16 12:16:58 2025 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 CC1F6C28B2B for ; Fri, 19 Aug 2022 16:49:01 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1354080AbiHSQtA (ORCPT ); Fri, 19 Aug 2022 12:49:00 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38510 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1353743AbiHSQq2 (ORCPT ); Fri, 19 Aug 2022 12:46:28 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8458C12AD22; Fri, 19 Aug 2022 09:12:28 -0700 (PDT) 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 ams.source.kernel.org (Postfix) with ESMTPS id 8BB8BB825D3; Fri, 19 Aug 2022 16:11:32 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id ECF00C433C1; Fri, 19 Aug 2022 16:11:30 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1660925491; bh=maXJZmtfGHTbigKGqgNHPqRQAaITODt4/YtQSu33wlo=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=dejY5PZ81ioTDjn/ncS6QfNQBU1VIr8mJWABYGO2e6eqdAYjLeLlVQSHGlAMW3Hoq /O+JOhPyp1H4tnjJuYrEml3K2d1g85KNSAPzkhglXwEJBGz1bK/uYu7J/dvFgYmNc7 O898/eWDpIITKfXMhdJa+8lM7ad7YwHnVsmMDlgk= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Sean V Kelley , Bjorn Helgaas , Jonathan Cameron , Sasha Levin Subject: [PATCH 5.10 477/545] PCI/ERR: Simplify by computing pci_pcie_type() once Date: Fri, 19 Aug 2022 17:44:07 +0200 Message-Id: <20220819153850.764825952@linuxfoundation.org> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20220819153829.135562864@linuxfoundation.org> References: <20220819153829.135562864@linuxfoundation.org> User-Agent: quilt/0.67 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" From: Sean V Kelley [ Upstream commit 480ef7cb9fcebda7b28cbed4f6cdcf0a02f4a6ca ] Instead of calling pci_pcie_type(dev) twice, call it once and save the result. No functional change intended. Link: https://lore.kernel.org/r/20201121001036.8560-7-sean.v.kelley@intel.c= om Tested-by: Jonathan Cameron # non-native/no R= CEC Signed-off-by: Sean V Kelley Signed-off-by: Bjorn Helgaas Acked-by: Jonathan Cameron Signed-off-by: Sasha Levin --- drivers/pci/pcie/aer.c | 5 +++-- drivers/pci/pcie/err.c | 5 +++-- drivers/pci/pcie/portdrv_pci.c | 9 +++++---- 3 files changed, 11 insertions(+), 8 deletions(-) diff --git a/drivers/pci/pcie/aer.c b/drivers/pci/pcie/aer.c index 61f78b20b0cf..72dbc193a25f 100644 --- a/drivers/pci/pcie/aer.c +++ b/drivers/pci/pcie/aer.c @@ -1039,6 +1039,7 @@ EXPORT_SYMBOL_GPL(aer_recover_queue); */ int aer_get_device_error_info(struct pci_dev *dev, struct aer_err_info *in= fo) { + int type =3D pci_pcie_type(dev); int aer =3D dev->aer_cap; int temp; =20 @@ -1057,8 +1058,8 @@ int aer_get_device_error_info(struct pci_dev *dev, st= ruct aer_err_info *info) &info->mask); if (!(info->status & ~info->mask)) return 0; - } else if (pci_pcie_type(dev) =3D=3D PCI_EXP_TYPE_ROOT_PORT || - pci_pcie_type(dev) =3D=3D PCI_EXP_TYPE_DOWNSTREAM || + } else if (type =3D=3D PCI_EXP_TYPE_ROOT_PORT || + type =3D=3D PCI_EXP_TYPE_DOWNSTREAM || info->severity =3D=3D AER_NONFATAL) { =20 /* Link is still healthy for IO reads */ diff --git a/drivers/pci/pcie/err.c b/drivers/pci/pcie/err.c index 05f61da5ed9d..7a5af873d8bc 100644 --- a/drivers/pci/pcie/err.c +++ b/drivers/pci/pcie/err.c @@ -150,6 +150,7 @@ pci_ers_result_t pcie_do_recovery(struct pci_dev *dev, pci_channel_state_t state, pci_ers_result_t (*reset_subordinates)(struct pci_dev *pdev)) { + int type =3D pci_pcie_type(dev); pci_ers_result_t status =3D PCI_ERS_RESULT_CAN_RECOVER; struct pci_bus *bus; =20 @@ -157,8 +158,8 @@ pci_ers_result_t pcie_do_recovery(struct pci_dev *dev, * Error recovery runs on all subordinates of the first downstream port. * If the downstream port detected the error, it is cleared at the end. */ - if (!(pci_pcie_type(dev) =3D=3D PCI_EXP_TYPE_ROOT_PORT || - pci_pcie_type(dev) =3D=3D PCI_EXP_TYPE_DOWNSTREAM)) + if (!(type =3D=3D PCI_EXP_TYPE_ROOT_PORT || + type =3D=3D PCI_EXP_TYPE_DOWNSTREAM)) dev =3D pci_upstream_bridge(dev); bus =3D dev->subordinate; =20 diff --git a/drivers/pci/pcie/portdrv_pci.c b/drivers/pci/pcie/portdrv_pci.c index 26259630fd10..aac1a6828b4f 100644 --- a/drivers/pci/pcie/portdrv_pci.c +++ b/drivers/pci/pcie/portdrv_pci.c @@ -101,13 +101,14 @@ static const struct dev_pm_ops pcie_portdrv_pm_ops = =3D { static int pcie_portdrv_probe(struct pci_dev *dev, const struct pci_device_id *id) { + int type =3D pci_pcie_type(dev); int status; =20 if (!pci_is_pcie(dev) || - ((pci_pcie_type(dev) !=3D PCI_EXP_TYPE_ROOT_PORT) && - (pci_pcie_type(dev) !=3D PCI_EXP_TYPE_UPSTREAM) && - (pci_pcie_type(dev) !=3D PCI_EXP_TYPE_DOWNSTREAM) && - (pci_pcie_type(dev) !=3D PCI_EXP_TYPE_RC_EC))) + ((type !=3D PCI_EXP_TYPE_ROOT_PORT) && + (type !=3D PCI_EXP_TYPE_UPSTREAM) && + (type !=3D PCI_EXP_TYPE_DOWNSTREAM) && + (type !=3D PCI_EXP_TYPE_RC_EC))) return -ENODEV; =20 status =3D pcie_port_device_register(dev); --=20 2.35.1