]> Pileus Git - ~andy/linux/commit
PCI: Skip attaching driver in device_add()
authorYinghai Lu <yinghai@kernel.org>
Mon, 21 Jan 2013 21:20:51 +0000 (13:20 -0800)
committerBjorn Helgaas <bhelgaas@google.com>
Fri, 25 Jan 2013 22:10:12 +0000 (15:10 -0700)
commit58d9a38f6facb28e935ec2747f6d9e9bf4684118
tree252899cd333ccc3c23c2435acd3f377512092aa0
parentd59f53bc9bd80ee62072dea590fc623c67cb84a8
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>
drivers/pci/bus.c
drivers/pci/pci-driver.c
include/linux/pci.h