aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/pci/pci-driver.c
diff options
context:
space:
mode:
authorYinghai Lu <yinghai@kernel.org>2013-01-21 16:20:51 -0500
committerBjorn Helgaas <bhelgaas@google.com>2013-01-25 17:10:12 -0500
commit58d9a38f6facb28e935ec2747f6d9e9bf4684118 (patch)
tree252899cd333ccc3c23c2435acd3f377512092aa0 /drivers/pci/pci-driver.c
parentd59f53bc9bd80ee62072dea590fc623c67cb84a8 (diff)
PCI: Skip attaching driver in device_add()
We want to add PCI devices to the device tree as early as possible but delay attaching drivers. device_add() adds a device to the device hierarchy and (via device_attach()) attaches a matching driver and calls its .probe() method. We want to separate adding the device to the hierarchy from attaching the driver. This patch does that by adding "match_driver" in struct pci_dev. When false, we return failure from pci_bus_match(), which makes device_attach() believe there's no matching driver. Later, we set "match_driver = true" and call device_attach() again, which now attaches the driver and calls its .probe() method. [bhelgaas: changelog, explicitly init dev->match_driver, fold device_attach() call into pci_bus_add_device()] Signed-off-by: Yinghai Lu <yinghai@kernel.org> Signed-off-by: Bjorn Helgaas <bhelgaas@google.com> Acked-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Diffstat (limited to 'drivers/pci/pci-driver.c')
-rw-r--r--drivers/pci/pci-driver.c6
1 files changed, 5 insertions, 1 deletions
diff --git a/drivers/pci/pci-driver.c b/drivers/pci/pci-driver.c
index f79cbcd3944b..acdcc3c6ecdd 100644
--- a/drivers/pci/pci-driver.c
+++ b/drivers/pci/pci-driver.c
@@ -1186,9 +1186,13 @@ pci_dev_driver(const struct pci_dev *dev)
1186static int pci_bus_match(struct device *dev, struct device_driver *drv) 1186static int pci_bus_match(struct device *dev, struct device_driver *drv)
1187{ 1187{
1188 struct pci_dev *pci_dev = to_pci_dev(dev); 1188 struct pci_dev *pci_dev = to_pci_dev(dev);
1189 struct pci_driver *pci_drv = to_pci_driver(drv); 1189 struct pci_driver *pci_drv;
1190 const struct pci_device_id *found_id; 1190 const struct pci_device_id *found_id;
1191 1191
1192 if (!pci_dev->match_driver)
1193 return 0;
1194
1195 pci_drv = to_pci_driver(drv);
1192 found_id = pci_match_device(pci_drv, pci_dev); 1196 found_id = pci_match_device(pci_drv, pci_dev);
1193 if (found_id) 1197 if (found_id)
1194 return 1; 1198 return 1;