Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

PCI: Add device even if driver attach failed

device_attach() returning failure indicates a driver error while trying to
probe the device. In such a scenario, the PCI device should still be added
in the system and be visible to the user.

When device_attach() fails, merely warn about it and keep the PCI device in
the system.

This partially reverts ab1a187bba5c ("PCI: Check device_attach() return
value always").

Link: https://lore.kernel.org/r/20200706233240.3245512-1-rajatja@google.com
Signed-off-by: Rajat Jain <rajatja@google.com>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
Reviewed-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: stable@vger.kernel.org # v4.6+

authored by

Rajat Jain and committed by
Bjorn Helgaas
2194bc7c 2a7e32d0

+1 -5
+1 -5
drivers/pci/bus.c
··· 322 322 323 323 dev->match_driver = true; 324 324 retval = device_attach(&dev->dev); 325 - if (retval < 0 && retval != -EPROBE_DEFER) { 325 + if (retval < 0 && retval != -EPROBE_DEFER) 326 326 pci_warn(dev, "device attach failed (%d)\n", retval); 327 - pci_proc_detach_device(dev); 328 - pci_remove_sysfs_dev_files(dev); 329 - return; 330 - } 331 327 332 328 pci_dev_assign_added(dev, true); 333 329 }