regulator: core: simplify regulator_bulk_force_disable()
authorDmitry Torokhov <dmitry.torokhov@gmail.com>
Fri, 3 Feb 2017 23:16:17 +0000 (15:16 -0800)
committerMark Brown <broonie@kernel.org>
Sat, 4 Feb 2017 10:37:24 +0000 (11:37 +0100)
There is no need to have two loops there, we can store error for subsequent
reporting.

Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
Signed-off-by: Mark Brown <broonie@kernel.org>
drivers/regulator/core.c

index 206c274..fe05923 100644 (file)
@@ -3687,21 +3687,17 @@ int regulator_bulk_force_disable(int num_consumers,
                           struct regulator_bulk_data *consumers)
 {
        int i;
-       int ret;
+       int ret = 0;
 
-       for (i = 0; i < num_consumers; i++)
+       for (i = 0; i < num_consumers; i++) {
                consumers[i].ret =
                            regulator_force_disable(consumers[i].consumer);
 
-       for (i = 0; i < num_consumers; i++) {
-               if (consumers[i].ret != 0) {
+               /* Store first error for reporting */
+               if (consumers[i].ret && !ret)
                        ret = consumers[i].ret;
-                       goto out;
-               }
        }
 
-       return 0;
-out:
        return ret;
 }
 EXPORT_SYMBOL_GPL(regulator_bulk_force_disable);