aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGreg Kroah-Hartman <gregkh@suse.de>2007-11-01 22:41:16 -0400
committerGreg Kroah-Hartman <gregkh@suse.de>2008-01-24 23:40:33 -0500
commitb249072ee6897fe4f8d461c7bb4b926223263c28 (patch)
treea6dde5703458677302516145c47f308e52cda189
parent0fed80f7a63abd7168907267af69ee31f6bcf301 (diff)
driver core: add way to get to bus device klist
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>
-rw-r--r--drivers/base/bus.c6
-rw-r--r--drivers/pci/probe.c11
-rw-r--r--include/linux/device.h1
3 files changed, 14 insertions, 4 deletions
diff --git a/drivers/base/bus.c b/drivers/base/bus.c
index 8335a1079b0e..9c9027b2c44e 100644
--- a/drivers/base/bus.c
+++ b/drivers/base/bus.c
@@ -941,6 +941,12 @@ struct kset *bus_get_kset(struct bus_type *bus)
941} 941}
942EXPORT_SYMBOL_GPL(bus_get_kset); 942EXPORT_SYMBOL_GPL(bus_get_kset);
943 943
944struct klist *bus_get_device_klist(struct bus_type *bus)
945{
946 return &bus->klist_devices;
947}
948EXPORT_SYMBOL_GPL(bus_get_device_klist);
949
944int __init buses_init(void) 950int __init buses_init(void)
945{ 951{
946 bus_kset = kset_create_and_add("bus", &bus_uevent_ops, NULL); 952 bus_kset = kset_create_and_add("bus", &bus_uevent_ops, NULL);
diff --git a/drivers/pci/probe.c b/drivers/pci/probe.c
index c5ca3134513a..5fd585293e79 100644
--- a/drivers/pci/probe.c
+++ b/drivers/pci/probe.c
@@ -1210,16 +1210,19 @@ static void __init pci_sort_breadthfirst_klist(void)
1210 struct klist_node *n; 1210 struct klist_node *n;
1211 struct device *dev; 1211 struct device *dev;
1212 struct pci_dev *pdev; 1212 struct pci_dev *pdev;
1213 struct klist *device_klist;
1213 1214
1214 spin_lock(&pci_bus_type.klist_devices.k_lock); 1215 device_klist = bus_get_device_klist(&pci_bus_type);
1215 list_for_each_safe(pos, tmp, &pci_bus_type.klist_devices.k_list) { 1216
1217 spin_lock(&device_klist->k_lock);
1218 list_for_each_safe(pos, tmp, &device_klist->k_list) {
1216 n = container_of(pos, struct klist_node, n_node); 1219 n = container_of(pos, struct klist_node, n_node);
1217 dev = container_of(n, struct device, knode_bus); 1220 dev = container_of(n, struct device, knode_bus);
1218 pdev = to_pci_dev(dev); 1221 pdev = to_pci_dev(dev);
1219 pci_insertion_sort_klist(pdev, &sorted_devices); 1222 pci_insertion_sort_klist(pdev, &sorted_devices);
1220 } 1223 }
1221 list_splice(&sorted_devices, &pci_bus_type.klist_devices.k_list); 1224 list_splice(&sorted_devices, &device_klist->k_list);
1222 spin_unlock(&pci_bus_type.klist_devices.k_lock); 1225 spin_unlock(&device_klist->k_lock);
1223} 1226}
1224 1227
1225static void __init pci_insertion_sort_devices(struct pci_dev *a, struct list_head *list) 1228static void __init pci_insertion_sort_devices(struct pci_dev *a, struct list_head *list)
diff --git a/include/linux/device.h b/include/linux/device.h
index 3cc13c32314a..62e695bd3c93 100644
--- a/include/linux/device.h
+++ b/include/linux/device.h
@@ -118,6 +118,7 @@ extern int bus_unregister_notifier(struct bus_type *bus,
118 unbound */ 118 unbound */
119 119
120extern struct kset *bus_get_kset(struct bus_type *bus); 120extern struct kset *bus_get_kset(struct bus_type *bus);
121extern struct klist *bus_get_device_klist(struct bus_type *bus);
121 122
122struct device_driver { 123struct device_driver {
123 const char * name; 124 const char * name;