PCI: add is_added flag to struct pci_dev

This lets us check if the device is really added to the driver core or
not, which is what we need when walking some of the bus lists.  The flag
is there in anticipation of getting rid of the other PCI device list,
which is what we used to check in this situation.

Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
This commit is contained in:
Greg Kroah-Hartman 2008-02-14 14:56:56 -08:00
parent 70308923d3
commit 8a1bc9013a
5 changed files with 10 additions and 17 deletions

View File

@ -88,11 +88,8 @@ pcibios_fixup_new_pci_devices(struct pci_bus *bus)
struct pci_dev *dev; struct pci_dev *dev;
list_for_each_entry(dev, &bus->devices, bus_list) { list_for_each_entry(dev, &bus->devices, bus_list) {
/* /* Skip already-added devices */
* Skip already-present devices (which are on the if (!dev->is_added) {
* global device list.)
*/
if (list_empty(&dev->global_list)) {
int i; int i;
/* Fill device archdata and setup iommu table */ /* Fill device archdata and setup iommu table */

View File

@ -84,6 +84,7 @@ int pci_bus_add_device(struct pci_dev *dev)
if (retval) if (retval)
return retval; return retval;
dev->is_added = 1;
down_write(&pci_bus_sem); down_write(&pci_bus_sem);
list_add_tail(&dev->global_list, &pci_devices); list_add_tail(&dev->global_list, &pci_devices);
up_write(&pci_bus_sem); up_write(&pci_bus_sem);
@ -112,11 +113,8 @@ void pci_bus_add_devices(struct pci_bus *bus)
int retval; int retval;
list_for_each_entry(dev, &bus->devices, bus_list) { list_for_each_entry(dev, &bus->devices, bus_list) {
/* /* Skip already-added devices */
* Skip already-present devices (which are on the if (dev->is_added)
* global device list.)
*/
if (!list_empty(&dev->global_list))
continue; continue;
retval = pci_bus_add_device(dev); retval = pci_bus_add_device(dev);
if (retval) if (retval)
@ -124,8 +122,7 @@ void pci_bus_add_devices(struct pci_bus *bus)
} }
list_for_each_entry(dev, &bus->devices, bus_list) { list_for_each_entry(dev, &bus->devices, bus_list) {
BUG_ON(!dev->is_added);
BUG_ON(list_empty(&dev->global_list));
/* /*
* If there is an unattached subordinate bus, attach * If there is an unattached subordinate bus, attach

View File

@ -984,7 +984,7 @@ EXPORT_SYMBOL(pci_scan_single_device);
* *
* Scan a PCI slot on the specified PCI bus for devices, adding * Scan a PCI slot on the specified PCI bus for devices, adding
* discovered devices to the @bus->devices list. New devices * discovered devices to the @bus->devices list. New devices
* will have an empty dev->global_list head. * will not have is_added set.
*/ */
int pci_scan_slot(struct pci_bus *bus, int devfn) int pci_scan_slot(struct pci_bus *bus, int devfn)
{ {

View File

@ -18,13 +18,11 @@ static void pci_free_resources(struct pci_dev *dev)
static void pci_stop_dev(struct pci_dev *dev) static void pci_stop_dev(struct pci_dev *dev)
{ {
if (!dev->global_list.next) if (dev->is_added) {
return;
if (!list_empty(&dev->global_list)) {
pci_proc_detach_device(dev); pci_proc_detach_device(dev);
pci_remove_sysfs_dev_files(dev); pci_remove_sysfs_dev_files(dev);
device_unregister(&dev->dev); device_unregister(&dev->dev);
dev->is_added = 0;
down_write(&pci_bus_sem); down_write(&pci_bus_sem);
list_del(&dev->global_list); list_del(&dev->global_list);
dev->global_list.next = dev->global_list.prev = NULL; dev->global_list.next = dev->global_list.prev = NULL;

View File

@ -181,6 +181,7 @@ struct pci_dev {
unsigned int transparent:1; /* Transparent PCI bridge */ unsigned int transparent:1; /* Transparent PCI bridge */
unsigned int multifunction:1;/* Part of multi-function device */ unsigned int multifunction:1;/* Part of multi-function device */
/* keep track of device state */ /* keep track of device state */
unsigned int is_added:1;
unsigned int is_busmaster:1; /* device is busmaster */ unsigned int is_busmaster:1; /* device is busmaster */
unsigned int no_msi:1; /* device may not use msi */ unsigned int no_msi:1; /* device may not use msi */
unsigned int no_d1d2:1; /* only allow d0 or d3 */ unsigned int no_d1d2:1; /* only allow d0 or d3 */