diff options
author | Gimcuan Hui <gimcuan@gmail.com> | 2017-11-11 00:52:54 -0500 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2017-12-18 10:47:27 -0500 |
commit | 93ead7c9483c6d7ae0f67ae6d0a5d3966d84bec8 (patch) | |
tree | aa5df925bfd023273f4d5de96dfbb20cd405239f | |
parent | 73cf7e111ed69d8e1b59a3ae41b14bc77215e9ee (diff) |
drivers: base: omit redundant interations
When error happens, these interators return the error, no interation should
be continued, so make the change for getting out of while immediately.
Signed-off-by: Gimcuan Hui <gimcuan@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
-rw-r--r-- | drivers/base/bus.c | 2 | ||||
-rw-r--r-- | drivers/base/core.c | 2 | ||||
-rw-r--r-- | drivers/base/driver.c | 2 |
3 files changed, 3 insertions, 3 deletions
diff --git a/drivers/base/bus.c b/drivers/base/bus.c index 6c63e1abbdcc..ef6183306b40 100644 --- a/drivers/base/bus.c +++ b/drivers/base/bus.c | |||
@@ -307,7 +307,7 @@ int bus_for_each_dev(struct bus_type *bus, struct device *start, | |||
307 | 307 | ||
308 | klist_iter_init_node(&bus->p->klist_devices, &i, | 308 | klist_iter_init_node(&bus->p->klist_devices, &i, |
309 | (start ? &start->p->knode_bus : NULL)); | 309 | (start ? &start->p->knode_bus : NULL)); |
310 | while ((dev = next_device(&i)) && !error) | 310 | while (!error && (dev = next_device(&i))) |
311 | error = fn(dev, data); | 311 | error = fn(dev, data); |
312 | klist_iter_exit(&i); | 312 | klist_iter_exit(&i); |
313 | return error; | 313 | return error; |
diff --git a/drivers/base/core.c b/drivers/base/core.c index bf45587bcb46..61515ef91184 100644 --- a/drivers/base/core.c +++ b/drivers/base/core.c | |||
@@ -2114,7 +2114,7 @@ int device_for_each_child(struct device *parent, void *data, | |||
2114 | return 0; | 2114 | return 0; |
2115 | 2115 | ||
2116 | klist_iter_init(&parent->p->klist_children, &i); | 2116 | klist_iter_init(&parent->p->klist_children, &i); |
2117 | while ((child = next_device(&i)) && !error) | 2117 | while (!error && (child = next_device(&i))) |
2118 | error = fn(child, data); | 2118 | error = fn(child, data); |
2119 | klist_iter_exit(&i); | 2119 | klist_iter_exit(&i); |
2120 | return error; | 2120 | return error; |
diff --git a/drivers/base/driver.c b/drivers/base/driver.c index 4e20d68edb0d..ba912558a510 100644 --- a/drivers/base/driver.c +++ b/drivers/base/driver.c | |||
@@ -50,7 +50,7 @@ int driver_for_each_device(struct device_driver *drv, struct device *start, | |||
50 | 50 | ||
51 | klist_iter_init_node(&drv->p->klist_devices, &i, | 51 | klist_iter_init_node(&drv->p->klist_devices, &i, |
52 | start ? &start->p->knode_driver : NULL); | 52 | start ? &start->p->knode_driver : NULL); |
53 | while ((dev = next_device(&i)) && !error) | 53 | while (!error && (dev = next_device(&i))) |
54 | error = fn(dev, data); | 54 | error = fn(dev, data); |
55 | klist_iter_exit(&i); | 55 | klist_iter_exit(&i); |
56 | return error; | 56 | return error; |