History

driver core: bus: clean up bus_sort_breadthfirst()

Convert the bus_sort_breadthfirst() function to use bus_to_subsys() and not use the back-pointer to the private structure. This also allows us to get rid of bus_get_device_klist() which was only being used by this one internal function.

Greg Kroah-Hartman committed 3 years ago

Commit b5aaecb1 parent 83b91481 file · +5 −6Browse files

Unified · Split

drivers/base/bus.c+5−6
@@ -1006,11 +1006,6 @@ struct kset *bus_get_kset(struct bus_type *bus) · 1005 unmodified lines
10061006 }
10071007 EXPORT_SYMBOL_GPL(bus_get_kset);
10081008
1009−static struct klist *bus_get_device_klist(struct bus_type *bus)
1010−{
1011− return &bus->p->klist_devices;
1012−}
1013−
10141009 /*
10151010 * Yes, this forcibly breaks the klist abstraction temporarily. It
10161011 * just wants to sort the klist, not change reference counts and
@@ -1042,13 +1037,16 @@ void bus_sort_breadthfirst(struct bus_type *bus, · 25 unmodified lines
10421037 int (*compare)(const struct device *a,
10431038 const struct device *b))
10441039 {
1040+ struct subsys_private *sp = bus_to_subsys(bus);
10451041 LIST_HEAD(sorted_devices);
10461042 struct klist_node *n, *tmp;
10471043 struct device_private *dev_prv;
10481044 struct device *dev;
10491045 struct klist *device_klist;
10501046
1051− device_klist = bus_get_device_klist(bus);
1047+ if (!sp)
1048+ return;
1049+ device_klist = &sp->klist_devices;
10521050
10531051 spin_lock(&device_klist->k_lock);
10541052 list_for_each_entry_safe(n, tmp, &device_klist->k_list, n_node) {
@@ -1058,6 +1056,7 @@ void bus_sort_breadthfirst(struct bus_type *bus, · 3 unmodified lines
10581056 }
10591057 list_splice(&sorted_devices, &device_klist->k_list);
10601058 spin_unlock(&device_klist->k_lock);
1059+ subsys_put(sp);
10611060 }
10621061 EXPORT_SYMBOL_GPL(bus_sort_breadthfirst);
10631062