From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753152AbdBCXQs (ORCPT ); Fri, 3 Feb 2017 18:16:48 -0500 Received: from mail-pf0-f195.google.com ([209.85.192.195]:33414 "EHLO mail-pf0-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752888AbdBCXQp (ORCPT ); Fri, 3 Feb 2017 18:16:45 -0500 From: Dmitry Torokhov To: Mark Brown Cc: Liam Girdwood , linux-kernel@vger.kernel.org, Bjorn Andersson Subject: [PATCH 2/4] regulator: core: simplify regulator_bulk_force_disable() Date: Fri, 3 Feb 2017 15:16:17 -0800 Message-Id: <20170203231619.8013-2-dmitry.torokhov@gmail.com> X-Mailer: git-send-email 2.11.0.483.g087da7b7c-goog In-Reply-To: <20170203231619.8013-1-dmitry.torokhov@gmail.com> References: <20170203231619.8013-1-dmitry.torokhov@gmail.com> Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org There is no need to have two loops there, we can store error for subsequent reporting. Signed-off-by: Dmitry Torokhov --- drivers/regulator/core.c | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/drivers/regulator/core.c b/drivers/regulator/core.c index 8a469d7c00c2..9eb2e04f1219 100644 --- a/drivers/regulator/core.c +++ b/drivers/regulator/core.c @@ -3690,21 +3690,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); -- 2.11.0.483.g087da7b7c-goog