mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Saravana Kannan <skannan@codeaurora.org>
To: Liam Girdwood <lrg@slimlogic.co.uk>
Cc: linux-arm-msm@vger.kernel.org,
	Liam Girdwood <lrg@slimlogic.co.uk>,
	Mark Brown <broonie@opensource.wolfsonmicro.com>,
	linux-kernel@vger.kernel.org
Subject: [PATCH] regulator: Call into regulator driver only when voltage min/max really changes.
Date: Sun, 12 Dec 2010 02:55:40 -0800	[thread overview]
Message-ID: <1292151342-12970-1-git-send-email-skannan@codeaurora.org> (raw)

Even in cases where the consumer driver calls the regulator core with
different voltage min/max values, the application of the various
voltage constraints could result in the min/max voltage values passed
to the regulator driver to be unchanged since the previous invocation.

Optimize these cases by not calling into the regulator driver and not
sending incorrect/unnecessary voltage change notifications.

Signed-off-by: Saravana Kannan <skannan@codeaurora.org>
---
 drivers/regulator/core.c |   10 ++++++++--
 1 files changed, 8 insertions(+), 2 deletions(-)

diff --git a/drivers/regulator/core.c b/drivers/regulator/core.c
index ba521f0..c2e67bb 100644
--- a/drivers/regulator/core.c
+++ b/drivers/regulator/core.c
@@ -1640,12 +1640,18 @@ 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->min_uV = min_uV;
-	regulator->max_uV = max_uV;
+
+	if (regulator->min_uV == min_uV && regulator->max_uV == max_uV)
+		goto unlock;
 	ret = rdev->desc->ops->set_voltage(rdev, min_uV, max_uV);
+	if (!ret) {
+		regulator->min_uV = min_uV;
+		regulator->max_uV = max_uV;
+	}
 
 out:
 	_notifier_call_chain(rdev, REGULATOR_EVENT_VOLTAGE_CHANGE, NULL);
+unlock:
 	mutex_unlock(&rdev->mutex);
 	return ret;
 }
-- 
1.7.1.1
--
Sent by an employee of the Qualcomm Innovation Center, Inc.
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum.

             reply	other threads:[~2010-12-12 10:55 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-12-12 10:55 Saravana Kannan [this message]
2010-12-12 12:18 ` Mark Brown
2010-12-12 12:41   ` skannan
2010-12-12 13:13     ` Mark Brown
2010-12-12 13:53 ` Mark Brown
2010-12-12 21:41   ` Saravana Kannan
2010-12-13 14:41 ` Liam Girdwood

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=1292151342-12970-1-git-send-email-skannan@codeaurora.org \
    --to=skannan@codeaurora.org \
    --cc=broonie@opensource.wolfsonmicro.com \
    --cc=linux-arm-msm@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=lrg@slimlogic.co.uk \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

Powered by JetHome