driver core: add way to get to bus device klist
authorGreg Kroah-Hartman <gregkh@suse.de>
Fri, 2 Nov 2007 02:41:16 +0000 (19:41 -0700)
committerGreg Kroah-Hartman <gregkh@suse.de>
Fri, 25 Jan 2008 04:40:33 +0000 (20:40 -0800)
This allows an easier way to get to the device klist associated with a
struct bus_type (you have three to choose from...)  This will make it
easier to move these fields to be dynamic in a future patch.

The only user of this is the PCI core which horribly abuses this
interface to rearrange the order of the pci devices.  This should be
done using the existing bus device walking functions, but that's left
for future patches.

Cc: Kay Sievers <kay.sievers@vrfy.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
drivers/base/bus.c
drivers/pci/probe.c
include/linux/device.h

index 8335a1079b0efdebda537c1f5efdf8954d2adb63..9c9027b2c44eef9cbbf591c9113e490ed27b51c9 100644 (file)
@@ -941,6 +941,12 @@ struct kset *bus_get_kset(struct bus_type *bus)
 }
 EXPORT_SYMBOL_GPL(bus_get_kset);
 
+struct klist *bus_get_device_klist(struct bus_type *bus)
+{
+       return &bus->klist_devices;
+}
+EXPORT_SYMBOL_GPL(bus_get_device_klist);
+
 int __init buses_init(void)
 {
        bus_kset = kset_create_and_add("bus", &bus_uevent_ops, NULL);
index c5ca3134513a6e848461c2546604c293d4ba2e51..5fd585293e7954c777094b6331e5a5fae9c094ca 100644 (file)
@@ -1210,16 +1210,19 @@ static void __init pci_sort_breadthfirst_klist(void)
        struct klist_node *n;
        struct device *dev;
        struct pci_dev *pdev;
+       struct klist *device_klist;
 
-       spin_lock(&pci_bus_type.klist_devices.k_lock);
-       list_for_each_safe(pos, tmp, &pci_bus_type.klist_devices.k_list) {
+       device_klist = bus_get_device_klist(&pci_bus_type);
+
+       spin_lock(&device_klist->k_lock);
+       list_for_each_safe(pos, tmp, &device_klist->k_list) {
                n = container_of(pos, struct klist_node, n_node);
                dev = container_of(n, struct device, knode_bus);
                pdev = to_pci_dev(dev);
                pci_insertion_sort_klist(pdev, &sorted_devices);
        }
-       list_splice(&sorted_devices, &pci_bus_type.klist_devices.k_list);
-       spin_unlock(&pci_bus_type.klist_devices.k_lock);
+       list_splice(&sorted_devices, &device_klist->k_list);
+       spin_unlock(&device_klist->k_lock);
 }
 
 static void __init pci_insertion_sort_devices(struct pci_dev *a, struct list_head *list)
index 3cc13c32314ab0191423ecf869f50558a43fb099..62e695bd3c931b574a70853ad29eeebf1651bd04 100644 (file)
@@ -118,6 +118,7 @@ extern int bus_unregister_notifier(struct bus_type *bus,
                                                      unbound */
 
 extern struct kset *bus_get_kset(struct bus_type *bus);
+extern struct klist *bus_get_device_klist(struct bus_type *bus);
 
 struct device_driver {
        const char              * name;