[PATCH] missing pci_disable_device()

From: Kenji Kaneshige
Date: Mon Sep 06 2004 - 20:26:20 EST


Hi,

As mentioned in Documentaion/pci.txt, pci device driver should call
pci_disable_device() to deallocate any IRQ resources, disable PCI
bus-mastering and etc. when it decides to stop using the device.
But there seems to be many drivers that don't use pci_disable_device()
properly so far.

The following patch changes pci_device_remove() to call
pci_disable_device() instead of the driver if the device has not been
disabled by the driver.

Signed-off-by: Kenji Kaneshige <kaneshige.kenji@xxxxxxxxxxxxxx>

---

linux-2.6.9-rc1-kanesige/drivers/pci/pci-driver.c | 7 +++++++
1 files changed, 7 insertions(+)

diff -puN drivers/pci/pci-driver.c~force_pci_disable_device drivers/pci/pci-driver.c
--- linux-2.6.9-rc1/drivers/pci/pci-driver.c~force_pci_disable_device 2004-09-01 17:42:40.000000000 +0900
+++ linux-2.6.9-rc1-kanesige/drivers/pci/pci-driver.c 2004-09-02 14:54:39.824783993 +0900
@@ -291,6 +291,13 @@ static int pci_device_remove(struct devi
drv->remove(pci_dev);
pci_dev->driver = NULL;
}
+ /*
+ * If the device has not been disabled, we call
+ * pci_disable_device() instead of the driver.
+ */
+ if (pci_dev->is_enabled)
+ pci_disable_device(pci_dev);
+
pci_dev_put(pci_dev);
return 0;
}

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/