linux-pci.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Yinghai Lu <yinghai@kernel.org>
To: Bjorn Helgaas <bhelgaas@google.com>
Cc: Linus Torvalds <torvalds@linux-foundation.org>,
	linux-pci@vger.kernel.org, linux-kernel@vger.kernel.org,
	Yinghai Lu <yinghai@kernel.org>
Subject: [PATCH 04/10] PCI: extend pci device match_driver state
Date: Fri,  4 Aug 2017 23:37:55 -0700	[thread overview]
Message-ID: <20170805063801.15880-5-yinghai@kernel.org> (raw)
In-Reply-To: <20170805063801.15880-1-yinghai@kernel.org>

Change it from false/true to -1/0/1.

If it is set from -1, then it will never get change to 1 later.

For PCI_TEST, the simulated device does not have realy function
support except bus number and BAR setting.

Signed-off-by: Yinghai Lu <yinghai@kernel.org>
---
 drivers/iommu/amd_iommu_init.c | 2 +-
 drivers/pci/bus.c              | 3 ++-
 drivers/pci/pci-driver.c       | 2 +-
 drivers/pci/probe.c            | 2 +-
 include/linux/pci.h            | 2 +-
 5 files changed, 6 insertions(+), 5 deletions(-)

diff --git a/drivers/iommu/amd_iommu_init.c b/drivers/iommu/amd_iommu_init.c
index 3723037..6d706ca 100644
--- a/drivers/iommu/amd_iommu_init.c
+++ b/drivers/iommu/amd_iommu_init.c
@@ -1558,7 +1558,7 @@ static int iommu_init_pci(struct amd_iommu *iommu)
 		return -ENODEV;
 
 	/* Prevent binding other PCI device drivers to IOMMU devices */
-	iommu->dev->match_driver = false;
+	iommu->dev->match_driver = 0;
 
 	pci_read_config_dword(iommu->dev, cap_ptr + MMIO_CAP_HDR_OFFSET,
 			      &iommu->cap);
diff --git a/drivers/pci/bus.c b/drivers/pci/bus.c
index bc56cf1..e2c0bda 100644
--- a/drivers/pci/bus.c
+++ b/drivers/pci/bus.c
@@ -322,7 +322,8 @@ void pci_bus_add_device(struct pci_dev *dev)
 	pci_proc_attach_device(dev);
 	pci_bridge_d3_update(dev);
 
-	dev->match_driver = true;
+	if (dev->match_driver == 0)
+		dev->match_driver = 1;
 	retval = device_attach(&dev->dev);
 	if (retval < 0 && retval != -EPROBE_DEFER) {
 		dev_warn(&dev->dev, "device attach failed (%d)\n", retval);
diff --git a/drivers/pci/pci-driver.c b/drivers/pci/pci-driver.c
index d51e873..c67b872 100644
--- a/drivers/pci/pci-driver.c
+++ b/drivers/pci/pci-driver.c
@@ -1373,7 +1373,7 @@ static int pci_bus_match(struct device *dev, struct device_driver *drv)
 	struct pci_driver *pci_drv;
 	const struct pci_device_id *found_id;
 
-	if (!pci_dev->match_driver)
+	if (pci_dev->match_driver != 1)
 		return 0;
 
 	pci_drv = to_pci_driver(drv);
diff --git a/drivers/pci/probe.c b/drivers/pci/probe.c
index 1811016..34ffbdf 100644
--- a/drivers/pci/probe.c
+++ b/drivers/pci/probe.c
@@ -2021,7 +2021,7 @@ void pci_device_add(struct pci_dev *dev, struct pci_bus *bus)
 	pci_set_msi_domain(dev);
 
 	/* Notifier could use PCI capabilities */
-	dev->match_driver = false;
+	dev->match_driver = 0;
 	ret = device_add(&dev->dev);
 	WARN_ON(ret < 0);
 }
diff --git a/include/linux/pci.h b/include/linux/pci.h
index c58a635..6e81d64 100644
--- a/include/linux/pci.h
+++ b/include/linux/pci.h
@@ -344,7 +344,7 @@ struct pci_dev {
 	unsigned int	irq;
 	struct resource resource[DEVICE_COUNT_RESOURCE]; /* I/O and memory regions + expansion ROMs */
 
-	bool match_driver;		/* Skip attaching driver */
+	int match_driver;		/* Skip attaching driver */
 	/* These fields are used by common fixups */
 	unsigned int	transparent:1;	/* Subtractive decode PCI bridge */
 	unsigned int	multifunction:1;/* Part of multi-function device */
-- 
2.9.4

  parent reply	other threads:[~2017-08-05  6:38 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-08-05  6:37 [PATCH 00/10] PCI: pci resource allocation test module Yinghai Lu
2017-08-05  6:37 ` [PATCH 01/10] PCI: avoid arch_remove_reservations() for PCI_TEST Yinghai Lu
2017-08-05  6:37 ` [PATCH 02/10] PCI: introduce ioport_res/iomem_res " Yinghai Lu
2017-08-05  6:37 ` [PATCH 03/10] PCI: export symbol for PCI_TEST module Yinghai Lu
2017-08-05  6:37 ` Yinghai Lu [this message]
2017-08-05  6:37 ` [PATCH 05/10] PCI: Add PCI_TEST module for resource allocation Yinghai Lu
2017-08-05  6:37 ` [PATCH 06/10] PCI: PCI_TEST simple data Yinghai Lu
2017-08-05  6:37 ` [PATCH 07/10] PCI: PCI_TEST data from x5-8 Yinghai Lu
2017-08-05  6:37 ` [PATCH 08/10] PCI: PCI_TEST data from x5-8 with zeroed bus number Yinghai Lu

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20170805063801.15880-5-yinghai@kernel.org \
    --to=yinghai@kernel.org \
    --cc=bhelgaas@google.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-pci@vger.kernel.org \
    --cc=torvalds@linux-foundation.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).