From bd587aa0e1b9a5985076bdda7230ce60924b0e07 Mon Sep 17 00:00:00 2001 From: Kenji Kaneshige Date: Tue, 5 Oct 2004 22:50:32 -0700 Subject: [PATCH] [PATCH] PCI: warn of missing pci_disable_device() As mentioned in Documentaion/pci.txt, pci device driver should call pci_disable_device() when it decides to stop using the device. But there are some drivers that don't use pci_disable_device() so far. This patch adds warning messages that are displayed if the device is removed without properly calling pci_disable_device(). 'WARN_ON(1)' is commented out for now because I guess many people (including some distros) enables 'CONFIG_DEBUG_KERNEL'. People might be surprised if many stack dumps are displayed on their console. Signed-off-by: Kenji Kaneshige Signed-off-by: Greg Kroah-Hartman --- drivers/pci/pci-driver.c | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/drivers/pci/pci-driver.c b/drivers/pci/pci-driver.c index 64195d6d6828f..0cf9f2d5129ec 100644 --- a/drivers/pci/pci-driver.c +++ b/drivers/pci/pci-driver.c @@ -291,6 +291,19 @@ static int pci_device_remove(struct device * dev) drv->remove(pci_dev); pci_dev->driver = NULL; } + +#ifdef CONFIG_DEBUG_KERNEL + /* + * If the driver decides to stop using the device, it should + * call pci_disable_device(). + */ + if (pci_dev->is_enabled) { + dev_warn(&pci_dev->dev, "Device was removed without properly " + "calling pci_disable_device(). This may need fixing.\n"); + /* WARN_ON(1); */ + } +#endif /* CONFIG_DEBUG_KERNEL */ + pci_dev_put(pci_dev); return 0; } -- 2.53.0