From patchwork Tue Feb 7 19:32:37 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Keith Busch X-Patchwork-Id: 725291 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 3vHvRB3BMmz9s3s for ; Wed, 8 Feb 2017 06:24:22 +1100 (AEDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754715AbdBGTYV (ORCPT ); Tue, 7 Feb 2017 14:24:21 -0500 Received: from mga01.intel.com ([192.55.52.88]:59345 "EHLO mga01.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754286AbdBGTYV (ORCPT ); Tue, 7 Feb 2017 14:24:21 -0500 Received: from orsmga005.jf.intel.com ([10.7.209.41]) by fmsmga101.fm.intel.com with ESMTP; 07 Feb 2017 11:23:35 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.33,346,1477983600"; d="scan'208";a="61944787" Received: from unknown (HELO localhost.lm.intel.com) ([10.232.112.96]) by orsmga005.jf.intel.com with ESMTP; 07 Feb 2017 11:23:34 -0800 From: Keith Busch To: linux-pci@vger.kernel.org, Bjorn Helgaas Cc: Greg Kroah-Hartman , Lukas Wunner , Wei Zhang , Austin Bolen , Christoph Hellwig , Keith Busch Subject: [PATCHv6 5/5] pci: Quick return for pci_device_is_present Date: Tue, 7 Feb 2017 14:32:37 -0500 Message-Id: <1486495957-26177-6-git-send-email-keith.busch@intel.com> X-Mailer: git-send-email 2.5.5 In-Reply-To: <1486495957-26177-1-git-send-email-keith.busch@intel.com> References: <1486495957-26177-1-git-send-email-keith.busch@intel.com> Sender: linux-pci-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pci@vger.kernel.org If the pci device is disconnected, return false immediately for checking presence. We can't use the early return in pci device config accessors since this function uses the bus accessors. Signed-off-by: Keith Busch Reviewed-by: Christoph Hellwig --- drivers/pci/pci.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/drivers/pci/pci.c b/drivers/pci/pci.c index a881c0d..b8d37e7 100644 --- a/drivers/pci/pci.c +++ b/drivers/pci/pci.c @@ -4932,6 +4932,8 @@ bool pci_device_is_present(struct pci_dev *pdev) { u32 v; + if (pci_dev_is_disconnected(pdev)) + return false; return pci_bus_read_dev_vendor_id(pdev->bus, pdev->devfn, &v, 0); } EXPORT_SYMBOL_GPL(pci_device_is_present);