lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-id: <1327491338-18817-1-git-send-email-s.nawrocki@samsung.com>
Date:	Wed, 25 Jan 2012 12:35:38 +0100
From:	Sylwester Nawrocki <s.nawrocki@...sung.com>
To:	broonie@...nsource.wolfsonmicro.com, lrg@...com
Cc:	linux-kernel@...r.kernel.org, m.szyprowski@...sung.com,
	Sylwester Nawrocki <s.nawrocki@...sung.com>,
	Jaroslav Kysela <perex@...ex.cz>, Takashi Iwai <tiwai@...e.de>,
	Samuel Ortiz <sameo@...ux.intel.com>,
	Steve Glendinning <steve.glendinning@...c.com>,
	Richard Purdie <rpurdie@...ys.net>,
	Timur Tabi <timur@...escale.com>,
	Kyungmin Park <kyungmin.park@...sung.com>
Subject: [PATCH/RFC] regulator: Reverse the disable sequence in
 regulator_bulk_disable()

Often there is a need for disabling a set of regulators in order opposite
to the enable order. Currently the function regulator_bulk_disable() walks
list of regulators in same order as regulator_bulk_enable(). This may cause
trouble, especially for devices with mixed analogue and digital circuits.
So reverse the disabling sequence of regulator_bulk_disable().
While at it, also correct the comment.

Cc: Jaroslav Kysela <perex@...ex.cz>
Cc: Takashi Iwai <tiwai@...e.de>
Cc: Samuel Ortiz <sameo@...ux.intel.com>
Cc: Steve Glendinning <steve.glendinning@...c.com>
Cc: Richard Purdie <rpurdie@...ys.net>
Cc: Timur Tabi <timur@...escale.com>
Signed-off-by: Sylwester Nawrocki <s.nawrocki@...sung.com>
Signed-off-by: Kyungmin Park <kyungmin.park@...sung.com>
---
The alternatives to directly modifying regulator_bulk_disable() could be:

 - re-implement it in modules that need the order reversed; it is not
   really helpful in practice since such code would have to be repeated
   in multiple modules;

 - create new function, e.g. regulator_bulk_disable_reversed() with the
   order reversed - not sure if it is not an overkill though;
---
 drivers/regulator/core.c |    8 ++++----
 1 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/drivers/regulator/core.c b/drivers/regulator/core.c
index e9a83f8..67db4a6 100644
--- a/drivers/regulator/core.c
+++ b/drivers/regulator/core.c
@@ -2463,8 +2463,8 @@ EXPORT_SYMBOL_GPL(regulator_bulk_enable);
  * @return         0 on success, an errno on failure
  *
  * This convenience API allows consumers to disable multiple regulator
- * clients in a single API call.  If any consumers cannot be enabled
- * then any others that were disabled will be disabled again prior to
+ * clients in a single API call.  If any consumers cannot be disabled
+ * then any others that were disabled will be enabled again prior to
  * return.
  */
 int regulator_bulk_disable(int num_consumers,
@@ -2473,7 +2473,7 @@ int regulator_bulk_disable(int num_consumers,
 	int i;
 	int ret;
 
-	for (i = 0; i < num_consumers; i++) {
+	for (i = num_consumers - 1; i >= 0; --i) {
 		ret = regulator_disable(consumers[i].consumer);
 		if (ret != 0)
 			goto err;
@@ -2483,7 +2483,7 @@ int regulator_bulk_disable(int num_consumers,
 
 err:
 	pr_err("Failed to disable %s: %d\n", consumers[i].supply, ret);
-	for (--i; i >= 0; --i)
+	for (++i; i < num_consumers; ++i)
 		regulator_enable(consumers[i].consumer);
 
 	return ret;
-- 
1.7.8.3

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ