summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGeliang Tang <geliangtang@163.com>2016-01-05 16:03:37 +0100
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2016-02-10 02:25:27 +0100
commit4c62785e670e978294222a42200346f0538e19e7 (patch)
tree9c4ec160f04d45af3ec20064027860f138728ae4
parentdebugfs: Add stub function for debugfs_create_automount(). (diff)
downloadlinux-4c62785e670e978294222a42200346f0538e19e7.tar.xz
linux-4c62785e670e978294222a42200346f0538e19e7.zip
driver core: bus: use list_for_each_entry*
Use list_for_each_entry*() instead of list_for_each*() to simplify the code. Signed-off-by: Geliang Tang <geliangtang@163.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
-rw-r--r--drivers/base/bus.c10
1 files changed, 3 insertions, 7 deletions
diff --git a/drivers/base/bus.c b/drivers/base/bus.c
index 500592486e88..4bee6b0f9ea4 100644
--- a/drivers/base/bus.c
+++ b/drivers/base/bus.c
@@ -1019,13 +1019,11 @@ static void device_insertion_sort_klist(struct device *a, struct list_head *list
int (*compare)(const struct device *a,
const struct device *b))
{
- struct list_head *pos;
struct klist_node *n;
struct device_private *dev_prv;
struct device *b;
- list_for_each(pos, list) {
- n = container_of(pos, struct klist_node, n_node);
+ list_for_each_entry(n, list, n_node) {
dev_prv = to_device_private_bus(n);
b = dev_prv->device;
if (compare(a, b) <= 0) {
@@ -1042,8 +1040,7 @@ void bus_sort_breadthfirst(struct bus_type *bus,
const struct device *b))
{
LIST_HEAD(sorted_devices);
- struct list_head *pos, *tmp;
- struct klist_node *n;
+ struct klist_node *n, *tmp;
struct device_private *dev_prv;
struct device *dev;
struct klist *device_klist;
@@ -1051,8 +1048,7 @@ void bus_sort_breadthfirst(struct bus_type *bus,
device_klist = bus_get_device_klist(bus);
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);
+ list_for_each_entry_safe(n, tmp, &device_klist->k_list, n_node) {
dev_prv = to_device_private_bus(n);
dev = dev_prv->device;
device_insertion_sort_klist(dev, &sorted_devices, compare);