mirror of https://gitee.com/openkylin/linux.git
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>
This commit is contained in:
parent
73cf7e111e
commit
93ead7c948
|
@ -307,7 +307,7 @@ int bus_for_each_dev(struct bus_type *bus, struct device *start,
|
||||||
|
|
||||||
klist_iter_init_node(&bus->p->klist_devices, &i,
|
klist_iter_init_node(&bus->p->klist_devices, &i,
|
||||||
(start ? &start->p->knode_bus : NULL));
|
(start ? &start->p->knode_bus : NULL));
|
||||||
while ((dev = next_device(&i)) && !error)
|
while (!error && (dev = next_device(&i)))
|
||||||
error = fn(dev, data);
|
error = fn(dev, data);
|
||||||
klist_iter_exit(&i);
|
klist_iter_exit(&i);
|
||||||
return error;
|
return error;
|
||||||
|
|
|
@ -2114,7 +2114,7 @@ int device_for_each_child(struct device *parent, void *data,
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
klist_iter_init(&parent->p->klist_children, &i);
|
klist_iter_init(&parent->p->klist_children, &i);
|
||||||
while ((child = next_device(&i)) && !error)
|
while (!error && (child = next_device(&i)))
|
||||||
error = fn(child, data);
|
error = fn(child, data);
|
||||||
klist_iter_exit(&i);
|
klist_iter_exit(&i);
|
||||||
return error;
|
return error;
|
||||||
|
|
|
@ -50,7 +50,7 @@ int driver_for_each_device(struct device_driver *drv, struct device *start,
|
||||||
|
|
||||||
klist_iter_init_node(&drv->p->klist_devices, &i,
|
klist_iter_init_node(&drv->p->klist_devices, &i,
|
||||||
start ? &start->p->knode_driver : NULL);
|
start ? &start->p->knode_driver : NULL);
|
||||||
while ((dev = next_device(&i)) && !error)
|
while (!error && (dev = next_device(&i)))
|
||||||
error = fn(dev, data);
|
error = fn(dev, data);
|
||||||
klist_iter_exit(&i);
|
klist_iter_exit(&i);
|
||||||
return error;
|
return error;
|
||||||
|
|
Loading…
Reference in New Issue