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.
Unified · Split
| @@ -1006,11 +1006,6 @@ struct kset *bus_get_kset(struct bus_type *bus) · 1005 unmodified lines | |||
| 1006 | } | 1006 | } |
| 1007 | EXPORT_SYMBOL_GPL(bus_get_kset); | 1007 | EXPORT_SYMBOL_GPL(bus_get_kset); |
| 1008 | 1008 | ||
| 1009 | static struct klist *bus_get_device_klist(struct bus_type *bus) | ||
| 1010 | { | ||
| 1011 | return &bus->p->klist_devices; | ||
| 1012 | } | ||
| 1013 | |||
| 1014 | /* | 1009 | /* |
| 1015 | * Yes, this forcibly breaks the klist abstraction temporarily. It | 1010 | * Yes, this forcibly breaks the klist abstraction temporarily. It |
| 1016 | * just wants to sort the klist, not change reference counts and | 1011 | * 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 | |||
| 1042 | int (*compare)(const struct device *a, | 1037 | int (*compare)(const struct device *a, |
| 1043 | const struct device *b)) | 1038 | const struct device *b)) |
| 1044 | { | 1039 | { |
| 1040 | struct subsys_private *sp = bus_to_subsys(bus); | ||
| 1045 | LIST_HEAD(sorted_devices); | 1041 | LIST_HEAD(sorted_devices); |
| 1046 | struct klist_node *n, *tmp; | 1042 | struct klist_node *n, *tmp; |
| 1047 | struct device_private *dev_prv; | 1043 | struct device_private *dev_prv; |
| 1048 | struct device *dev; | 1044 | struct device *dev; |
| 1049 | struct klist *device_klist; | 1045 | struct klist *device_klist; |
| 1050 | 1046 | ||
| 1051 | device_klist = bus_get_device_klist(bus); | 1047 | if (!sp) |
| 1048 | return; | ||
| 1049 | device_klist = &sp->klist_devices; | ||
| 1052 | 1050 | ||
| 1053 | spin_lock(&device_klist->k_lock); | 1051 | spin_lock(&device_klist->k_lock); |
| 1054 | list_for_each_entry_safe(n, tmp, &device_klist->k_list, n_node) { | 1052 | 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 | |||
| 1058 | } | 1056 | } |
| 1059 | list_splice(&sorted_devices, &device_klist->k_list); | 1057 | list_splice(&sorted_devices, &device_klist->k_list); |
| 1060 | spin_unlock(&device_klist->k_lock); | 1058 | spin_unlock(&device_klist->k_lock); |
| 1059 | subsys_put(sp); | ||
| 1061 | } | 1060 | } |
| 1062 | EXPORT_SYMBOL_GPL(bus_sort_breadthfirst); | 1061 | EXPORT_SYMBOL_GPL(bus_sort_breadthfirst); |
| 1063 | 1062 | ||