diff mbox

[PATCHv5,5/5] pci: Quick return for pci_device_is_present

Message ID 1486144555-5526-6-git-send-email-keith.busch@intel.com (mailing list archive)
State New, archived
Delegated to: Bjorn Helgaas
Headers show

Commit Message

Keith Busch Feb. 3, 2017, 5:55 p.m. UTC
If the pci device is disconnected, return false immediately for checking
presence. We can't rely on the pci device config accessors since
this function uses the bus accessors, so this patch has the explicit
disconnected check first.

Signed-off-by: Keith Busch <keith.busch@intel.com>
---
 drivers/pci/pci.c | 2 ++
 1 file changed, 2 insertions(+)

Comments

Christoph Hellwig Feb. 6, 2017, 5:36 p.m. UTC | #1
On Fri, Feb 03, 2017 at 12:55:55PM -0500, Keith Busch wrote:
> If the pci device is disconnected, return false immediately for checking
> presence. We can't rely on the pci device config accessors since
> this function uses the bus accessors, so this patch has the explicit
> disconnected check first.
> 
> Signed-off-by: Keith Busch <keith.busch@intel.com>

Looks fine,

Reviewed-by: Christoph Hellwig <hch@lst.de>
diff mbox

Patch

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);