Skip to content

Commit b249072

Browse files
committed
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>
1 parent 0fed80f commit b249072

3 files changed

Lines changed: 14 additions & 4 deletions

File tree

‎drivers/base/bus.c‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -941,6 +941,12 @@ struct kset *bus_get_kset(struct bus_type *bus)
941941
}
942942
EXPORT_SYMBOL_GPL(bus_get_kset);
943943

944+
struct klist *bus_get_device_klist(struct bus_type *bus)
945+
{
946+
return &bus->klist_devices;
947+
}
948+
EXPORT_SYMBOL_GPL(bus_get_device_klist);
949+
944950
int __init buses_init(void)
945951
{
946952
bus_kset = kset_create_and_add("bus", &bus_uevent_ops, NULL);

‎drivers/pci/probe.c‎

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1210,16 +1210,19 @@ static void __init pci_sort_breadthfirst_klist(void)
12101210
struct klist_node *n;
12111211
struct device *dev;
12121212
struct pci_dev *pdev;
1213+
struct klist *device_klist;
12131214

1214-
spin_lock(&pci_bus_type.klist_devices.k_lock);
1215-
list_for_each_safe(pos, tmp, &pci_bus_type.klist_devices.k_list) {
1215+
device_klist = bus_get_device_klist(&pci_bus_type);
1216+
1217+
spin_lock(&device_klist->k_lock);
1218+
list_for_each_safe(pos, tmp, &device_klist->k_list) {
12161219
n = container_of(pos, struct klist_node, n_node);
12171220
dev = container_of(n, struct device, knode_bus);
12181221
pdev = to_pci_dev(dev);
12191222
pci_insertion_sort_klist(pdev, &sorted_devices);
12201223
}
1221-
list_splice(&sorted_devices, &pci_bus_type.klist_devices.k_list);
1222-
spin_unlock(&pci_bus_type.klist_devices.k_lock);
1224+
list_splice(&sorted_devices, &device_klist->k_list);
1225+
spin_unlock(&device_klist->k_lock);
12231226
}
12241227

12251228
static void __init pci_insertion_sort_devices(struct pci_dev *a, struct list_head *list)

‎include/linux/device.h‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,7 @@ extern int bus_unregister_notifier(struct bus_type *bus,
118118
unbound */
119119

120120
extern struct kset *bus_get_kset(struct bus_type *bus);
121+
extern struct klist *bus_get_device_klist(struct bus_type *bus);
121122

122123
struct device_driver {
123124
const char * name;

0 commit comments

Comments
 (0)