All of lore.kernel.org
 help / color / mirror / Atom feed
From: J Keerthy <j-keerthy@ti.com>
To: <linux-kernel@vger.kernel.org>, <lgirdwood@gmail.com>,
	<broonie@opensource.wolfsonmicro.com>
Cc: <j-keerthy@ti.com>
Subject: [PATCH] Regulator: Reorder the min max assignment in the sequence of regulator_set_voltage function
Date: Fri, 1 Feb 2013 10:34:58 +0530	[thread overview]
Message-ID: <1359695098-3630-1-git-send-email-j-keerthy@ti.com> (raw)

The min and max values for regulators are getting assigned before actually
the voltage is set. So making sure that min and max values are assigned
only if the voltage is successfully set else keeping the last successfully
set voltage's min and max values.

This is boot tested on OMAP4430 and OMAP4460 boards.

Signed-off-by: J Keerthy <j-keerthy@ti.com>
Cc: Mark Brown <broonie@opensource.wolfsonmicro.com> 
---
 drivers/regulator/core.c |    9 +++++++++
 1 files changed, 9 insertions(+), 0 deletions(-)

diff --git a/drivers/regulator/core.c b/drivers/regulator/core.c
index 2785843..12140fb 100644
--- a/drivers/regulator/core.c
+++ b/drivers/regulator/core.c
@@ -81,6 +81,8 @@ struct regulator {
 	int uA_load;
 	int min_uV;
 	int max_uV;
+	int curr_min_uV;
+	int curr_max_uV;
 	char *supply_name;
 	struct device_attribute dev_attr;
 	struct regulator_dev *rdev;
@@ -2315,6 +2317,8 @@ int regulator_set_voltage(struct regulator *regulator, int min_uV, int max_uV)
 	ret = regulator_check_voltage(rdev, &min_uV, &max_uV);
 	if (ret < 0)
 		goto out;
+	regulator->curr_min_uV = regulator->min_uV;
+	regulator->curr_max_uV = regulator->max_uV;
 	regulator->min_uV = min_uV;
 	regulator->max_uV = max_uV;
 
@@ -2325,6 +2329,11 @@ int regulator_set_voltage(struct regulator *regulator, int min_uV, int max_uV)
 	ret = _regulator_do_set_voltage(rdev, min_uV, max_uV);
 
 out:
+	if (ret) {
+		regulator->min_uV = regulator->curr_min_uV;
+		regulator->max_uV = regulator->curr_max_uV;
+	}
+
 	mutex_unlock(&rdev->mutex);
 	return ret;
 }
-- 
1.7.5.4


             reply	other threads:[~2013-02-01  5:06 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-02-01  5:04 J Keerthy [this message]
2013-02-04 11:53 ` [PATCH] Regulator: Reorder the min max assignment in the sequence of regulator_set_voltage function J, KEERTHY
2013-02-04 15:05   ` Mark Brown
2013-02-08 11:28 ` Mark Brown
2013-02-11  5:26   ` J, KEERTHY

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1359695098-3630-1-git-send-email-j-keerthy@ti.com \
    --to=j-keerthy@ti.com \
    --cc=broonie@opensource.wolfsonmicro.com \
    --cc=lgirdwood@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.