diff options
author | Yinghai Lu <yinghai@kernel.org> | 2013-01-21 16:20:51 -0500 |
---|---|---|
committer | Bjorn Helgaas <bhelgaas@google.com> | 2013-01-25 17:10:12 -0500 |
commit | 58d9a38f6facb28e935ec2747f6d9e9bf4684118 (patch) | |
tree | 252899cd333ccc3c23c2435acd3f377512092aa0 /drivers/pci/bus.c | |
parent | d59f53bc9bd80ee62072dea590fc623c67cb84a8 (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/bus.c')
-rw-r--r-- | drivers/pci/bus.c | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/drivers/pci/bus.c b/drivers/pci/bus.c index 847f3ca47bb8..c8709c6fdb7c 100644 --- a/drivers/pci/bus.c +++ b/drivers/pci/bus.c | |||
@@ -177,10 +177,15 @@ int pci_bus_add_device(struct pci_dev *dev) | |||
177 | if (retval) | 177 | if (retval) |
178 | return retval; | 178 | return retval; |
179 | 179 | ||
180 | dev->match_driver = false; | ||
180 | retval = device_add(&dev->dev); | 181 | retval = device_add(&dev->dev); |
181 | if (retval) | 182 | if (retval) |
182 | return retval; | 183 | return retval; |
183 | 184 | ||
185 | dev->match_driver = true; | ||
186 | retval = device_attach(&dev->dev); | ||
187 | WARN_ON(retval < 0); | ||
188 | |||
184 | dev->is_added = 1; | 189 | dev->is_added = 1; |
185 | pci_proc_attach_device(dev); | 190 | pci_proc_attach_device(dev); |
186 | pci_create_sysfs_dev_files(dev); | 191 | pci_create_sysfs_dev_files(dev); |