From 93ead7c9483c6d7ae0f67ae6d0a5d3966d84bec8 Mon Sep 17 00:00:00 2001 From: Gimcuan Hui Date: Sat, 11 Nov 2017 05:52:54 +0000 Subject: 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 Signed-off-by: Greg Kroah-Hartman --- drivers/base/core.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'drivers/base/core.c') 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, return 0; klist_iter_init(&parent->p->klist_children, &i); - while ((child = next_device(&i)) && !error) + while (!error && (child = next_device(&i))) error = fn(child, data); klist_iter_exit(&i); return error; -- cgit v1.2.3