All of lore.kernel.org
 help / color / mirror / Atom feed
From: Maciej Purski <m.purski@samsung.com>
To: Tony Lindgren <tony@atomide.com>
Cc: Mark Brown <broonie@kernel.org>,
	linux-kernel@vger.kernel.org,
	linux-arm-kernel@lists.infradead.org, linux-omap@vger.kernel.org,
	Carlos Hernandez <ceh@ti.com>,
	Marek Szyprowski <m.szyprowski@samsung.com>,
	Maciej Purski <m.purski@samsung.com>
Subject: [PATCH] regulator: core: Pass max_uV value to regulator_set_voltage_rdev
Date: Mon, 18 Jun 2018 16:08:33 +0200	[thread overview]
Message-ID: <1529330913-11152-1-git-send-email-m.purski@samsung.com> (raw)
In-Reply-To: <20180615112916.GK112168@atomide.com>

If the regulator is not coupled, balance_voltage() should preserve
its desired max uV, instead of setting the exact value like in
coupled regulators case.

Remove debugs, which are not necessary for now.

Signed-off-by: Maciej Purski <m.purski@samsung.com>
---
 drivers/regulator/core.c | 26 ++++++++++++++++----------
 1 file changed, 16 insertions(+), 10 deletions(-)

diff --git a/drivers/regulator/core.c b/drivers/regulator/core.c
index 266f4eb..9894f4e 100644
--- a/drivers/regulator/core.c
+++ b/drivers/regulator/core.c
@@ -2245,7 +2245,6 @@ static int _regulator_enable(struct regulator_dev *rdev)
 {
 	int ret;
 
-	rdev_err(rdev, "%s: %d\n", __func__, __LINE__);
 	lockdep_assert_held_once(&rdev->mutex);
 
 	/* check voltage and requested load before enabling */
@@ -2294,7 +2293,6 @@ int regulator_enable(struct regulator *regulator)
 	struct regulator_dev *rdev = regulator->rdev;
 	int ret = 0;
 
-	rdev_err(rdev, "%s: %d\n", __func__, __LINE__);
 	if (rdev->coupling_desc.n_resolved != rdev->coupling_desc.n_coupled) {
 		rdev_err(rdev, "not all coupled regulators registered\n");
 		return -EPERM;
@@ -2319,7 +2317,6 @@ int regulator_enable(struct regulator *regulator)
 	if (ret != 0 && rdev->supply)
 		regulator_disable(rdev->supply);
 
-	rdev_err(rdev, "%s: %d\n", __func__, __LINE__);
 	return ret;
 }
 EXPORT_SYMBOL_GPL(regulator_enable);
@@ -2418,7 +2415,6 @@ int regulator_disable(struct regulator *regulator)
 	struct regulator_dev *rdev = regulator->rdev;
 	int ret = 0;
 
-	rdev_err(rdev, "%s: %d\n", __func__, __LINE__);
 	if (regulator->always_on)
 		return 0;
 
@@ -2431,7 +2427,6 @@ int regulator_disable(struct regulator *regulator)
 	if (ret == 0 && rdev->supply)
 		regulator_disable(rdev->supply);
 
-	rdev_err(rdev, "%s: %d\n", __func__, __LINE__);
 	return ret;
 }
 EXPORT_SYMBOL_GPL(regulator_disable);
@@ -3112,6 +3107,8 @@ static int regulator_set_voltage_rdev(struct regulator_dev *rdev, int min_uV,
 	int supply_change_uV = 0;
 	int ret;
 
+	rdev_err(rdev, "%s: %d\n", __func__, __LINE__);
+
 	if (rdev->supply &&
 	    regulator_ops_is_valid(rdev->supply->rdev,
 				   REGULATOR_CHANGE_VOLTAGE) &&
@@ -3175,7 +3172,8 @@ static int regulator_set_voltage_rdev(struct regulator_dev *rdev, int min_uV,
 	return ret;
 }
 
-static int regulator_get_optimal_voltage(struct regulator_dev *rdev)
+static int
+regulator_get_optimal_voltage(struct regulator_dev *rdev, int *max_uV)
 {
 	struct coupling_desc *c_desc = &rdev->coupling_desc;
 	struct regulator_dev **c_rdevs = c_desc->coupled_rdevs;
@@ -3200,6 +3198,7 @@ static int regulator_get_optimal_voltage(struct regulator_dev *rdev)
 	 */
 	if (n_coupled == 1) {
 		ret = desired_min_uV;
+		*max_uV = desired_max_uV;
 		goto out;
 	}
 
@@ -3274,6 +3273,7 @@ static int regulator_get_optimal_voltage(struct regulator_dev *rdev)
 		goto out;
 	}
 	ret = possible_uV;
+	*max_uV = ret;
 
 out:
 	return ret;
@@ -3303,6 +3303,8 @@ static int regulator_balance_voltage(struct regulator_dev *rdev,
 	 * if there isn't any possible change.
 	 */
 	while (1) {
+		int max_uV;
+
 		best_delta = 0;
 		best_uV = 0;
 		best_rdev = NULL;
@@ -3318,9 +3320,9 @@ static int regulator_balance_voltage(struct regulator_dev *rdev,
 			 * max_spread constraint in order to balance
 			 * the coupled voltages.
 			 */
-			int optimal_uV, current_uV;
+			int optimal_uV, current_uV;;
 
-			optimal_uV = regulator_get_optimal_voltage(c_rdevs[i]);
+			optimal_uV = regulator_get_optimal_voltage(c_rdevs[i], &max_uV);
 			if (optimal_uV < 0) {
 				ret = optimal_uV;
 				goto out;
@@ -3337,6 +3339,10 @@ static int regulator_balance_voltage(struct regulator_dev *rdev,
 				best_rdev = c_rdevs[i];
 				best_uV = optimal_uV;
 			}
+
+			rdev_err(rdev,
+				"optimal uV: %d current uV: %d, max uV: %d\n",
+				 optimal_uV, current_uV, max_uV);
 		}
 
 		/* Nothing to change, return successfully */
@@ -3346,7 +3352,7 @@ static int regulator_balance_voltage(struct regulator_dev *rdev,
 		}
 
 		ret = regulator_set_voltage_rdev(best_rdev, best_uV,
-						 best_uV, state);
+						 max_uV, state);
 
 		if (ret < 0)
 			goto out;
@@ -3378,7 +3384,7 @@ int regulator_set_voltage(struct regulator *regulator, int min_uV, int max_uV)
 {
 	int ret = 0;
 
-	rdev_err(regulator->rdev, "%s: %d\n", __func__, __LINE__);
+	dev_err(regulator->dev, "%s: %d\n", __func__, __LINE__);
 	regulator_lock_dependent(regulator->rdev);
 
 	ret = regulator_set_voltage_unlocked(regulator, min_uV, max_uV,
-- 
2.7.4


WARNING: multiple messages have this Message-ID (diff)
From: m.purski@samsung.com (Maciej Purski)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH] regulator: core: Pass max_uV value to regulator_set_voltage_rdev
Date: Mon, 18 Jun 2018 16:08:33 +0200	[thread overview]
Message-ID: <1529330913-11152-1-git-send-email-m.purski@samsung.com> (raw)
In-Reply-To: <20180615112916.GK112168@atomide.com>

If the regulator is not coupled, balance_voltage() should preserve
its desired max uV, instead of setting the exact value like in
coupled regulators case.

Remove debugs, which are not necessary for now.

Signed-off-by: Maciej Purski <m.purski@samsung.com>
---
 drivers/regulator/core.c | 26 ++++++++++++++++----------
 1 file changed, 16 insertions(+), 10 deletions(-)

diff --git a/drivers/regulator/core.c b/drivers/regulator/core.c
index 266f4eb..9894f4e 100644
--- a/drivers/regulator/core.c
+++ b/drivers/regulator/core.c
@@ -2245,7 +2245,6 @@ static int _regulator_enable(struct regulator_dev *rdev)
 {
 	int ret;
 
-	rdev_err(rdev, "%s: %d\n", __func__, __LINE__);
 	lockdep_assert_held_once(&rdev->mutex);
 
 	/* check voltage and requested load before enabling */
@@ -2294,7 +2293,6 @@ int regulator_enable(struct regulator *regulator)
 	struct regulator_dev *rdev = regulator->rdev;
 	int ret = 0;
 
-	rdev_err(rdev, "%s: %d\n", __func__, __LINE__);
 	if (rdev->coupling_desc.n_resolved != rdev->coupling_desc.n_coupled) {
 		rdev_err(rdev, "not all coupled regulators registered\n");
 		return -EPERM;
@@ -2319,7 +2317,6 @@ int regulator_enable(struct regulator *regulator)
 	if (ret != 0 && rdev->supply)
 		regulator_disable(rdev->supply);
 
-	rdev_err(rdev, "%s: %d\n", __func__, __LINE__);
 	return ret;
 }
 EXPORT_SYMBOL_GPL(regulator_enable);
@@ -2418,7 +2415,6 @@ int regulator_disable(struct regulator *regulator)
 	struct regulator_dev *rdev = regulator->rdev;
 	int ret = 0;
 
-	rdev_err(rdev, "%s: %d\n", __func__, __LINE__);
 	if (regulator->always_on)
 		return 0;
 
@@ -2431,7 +2427,6 @@ int regulator_disable(struct regulator *regulator)
 	if (ret == 0 && rdev->supply)
 		regulator_disable(rdev->supply);
 
-	rdev_err(rdev, "%s: %d\n", __func__, __LINE__);
 	return ret;
 }
 EXPORT_SYMBOL_GPL(regulator_disable);
@@ -3112,6 +3107,8 @@ static int regulator_set_voltage_rdev(struct regulator_dev *rdev, int min_uV,
 	int supply_change_uV = 0;
 	int ret;
 
+	rdev_err(rdev, "%s: %d\n", __func__, __LINE__);
+
 	if (rdev->supply &&
 	    regulator_ops_is_valid(rdev->supply->rdev,
 				   REGULATOR_CHANGE_VOLTAGE) &&
@@ -3175,7 +3172,8 @@ static int regulator_set_voltage_rdev(struct regulator_dev *rdev, int min_uV,
 	return ret;
 }
 
-static int regulator_get_optimal_voltage(struct regulator_dev *rdev)
+static int
+regulator_get_optimal_voltage(struct regulator_dev *rdev, int *max_uV)
 {
 	struct coupling_desc *c_desc = &rdev->coupling_desc;
 	struct regulator_dev **c_rdevs = c_desc->coupled_rdevs;
@@ -3200,6 +3198,7 @@ static int regulator_get_optimal_voltage(struct regulator_dev *rdev)
 	 */
 	if (n_coupled == 1) {
 		ret = desired_min_uV;
+		*max_uV = desired_max_uV;
 		goto out;
 	}
 
@@ -3274,6 +3273,7 @@ static int regulator_get_optimal_voltage(struct regulator_dev *rdev)
 		goto out;
 	}
 	ret = possible_uV;
+	*max_uV = ret;
 
 out:
 	return ret;
@@ -3303,6 +3303,8 @@ static int regulator_balance_voltage(struct regulator_dev *rdev,
 	 * if there isn't any possible change.
 	 */
 	while (1) {
+		int max_uV;
+
 		best_delta = 0;
 		best_uV = 0;
 		best_rdev = NULL;
@@ -3318,9 +3320,9 @@ static int regulator_balance_voltage(struct regulator_dev *rdev,
 			 * max_spread constraint in order to balance
 			 * the coupled voltages.
 			 */
-			int optimal_uV, current_uV;
+			int optimal_uV, current_uV;;
 
-			optimal_uV = regulator_get_optimal_voltage(c_rdevs[i]);
+			optimal_uV = regulator_get_optimal_voltage(c_rdevs[i], &max_uV);
 			if (optimal_uV < 0) {
 				ret = optimal_uV;
 				goto out;
@@ -3337,6 +3339,10 @@ static int regulator_balance_voltage(struct regulator_dev *rdev,
 				best_rdev = c_rdevs[i];
 				best_uV = optimal_uV;
 			}
+
+			rdev_err(rdev,
+				"optimal uV: %d current uV: %d, max uV: %d\n",
+				 optimal_uV, current_uV, max_uV);
 		}
 
 		/* Nothing to change, return successfully */
@@ -3346,7 +3352,7 @@ static int regulator_balance_voltage(struct regulator_dev *rdev,
 		}
 
 		ret = regulator_set_voltage_rdev(best_rdev, best_uV,
-						 best_uV, state);
+						 max_uV, state);
 
 		if (ret < 0)
 			goto out;
@@ -3378,7 +3384,7 @@ int regulator_set_voltage(struct regulator *regulator, int min_uV, int max_uV)
 {
 	int ret = 0;
 
-	rdev_err(regulator->rdev, "%s: %d\n", __func__, __LINE__);
+	dev_err(regulator->dev, "%s: %d\n", __func__, __LINE__);
 	regulator_lock_dependent(regulator->rdev);
 
 	ret = regulator_set_voltage_unlocked(regulator, min_uV, max_uV,
-- 
2.7.4

  parent reply	other threads:[~2018-06-18 14:09 UTC|newest]

Thread overview: 81+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-05-29 22:15 Regression in Linux next again Tony Lindgren
2018-05-29 22:15 ` Tony Lindgren
2018-05-30  9:13 ` Mark Brown
2018-05-30  9:13   ` Mark Brown
2018-05-30 14:03   ` Maciej Purski
2018-05-30 14:03     ` Maciej Purski
2018-05-30 14:33     ` Mark Brown
2018-05-30 14:33       ` Mark Brown
2018-05-30 14:45       ` Tony Lindgren
2018-05-30 14:45         ` Tony Lindgren
     [not found]         ` <CGME20180604135952eucas1p292f7bcec405e6a1a6261031df36cad32@eucas1p2.samsung.com>
2018-06-04 13:59           ` Maciej Purski
2018-06-04 13:59             ` Maciej Purski
     [not found]             ` <CGME20180604135952eucas1p2d76b6aa5d8fc9912113d519b48f7e99a@eucas1p2.samsung.com>
2018-06-04 13:59               ` [PATCH 1/7] regulator: core: Add debug messages Maciej Purski
2018-06-04 13:59                 ` Maciej Purski
     [not found]             ` <CGME20180604135952eucas1p2e3fdb68bf31e32b7c9557051671885a9@eucas1p2.samsung.com>
2018-06-04 13:59               ` [PATCH 2/7] regulator: core: Add regulator_set_voltage_rdev() Maciej Purski
2018-06-04 13:59                 ` Maciej Purski
     [not found]             ` <CGME20180604135953eucas1p2f2c9dd9581cd114d323c3d64afe5c308@eucas1p2.samsung.com>
2018-06-04 13:59               ` [PATCH 3/7] regulator: core: Use re-entrant locks Maciej Purski
2018-06-04 13:59                 ` Maciej Purski
     [not found]             ` <CGME20180604135953eucas1p2ec281df0793bc73e79f3000837abcb04@eucas1p2.samsung.com>
2018-06-04 13:59               ` [PATCH 4/7] regulator: core: Implement voltage balancing algorithm Maciej Purski
2018-06-04 13:59                 ` Maciej Purski
2018-06-04 13:59                 ` Maciej Purski
     [not found]             ` <CGME20180604135954eucas1p2156fed3300b5514a4efa2baf9e7b9bc5@eucas1p2.samsung.com>
2018-06-04 13:59               ` [PATCH 5/7] regulator: core: Lock dependent regulators Maciej Purski
2018-06-04 13:59                 ` Maciej Purski
2018-06-04 13:59                 ` Maciej Purski
2018-06-04 14:20                 ` Lucas Stach
2018-06-04 14:20                   ` Lucas Stach
2018-06-18 12:37                   ` Maciej Purski
2018-06-18 12:37                     ` Maciej Purski
     [not found]             ` <CGME20180604135954eucas1p2eeb77ada3ca97fecc6caec20d7e8397a@eucas1p2.samsung.com>
2018-06-04 13:59               ` [PATCH 6/7] regulator: core: Lock dependent regulators on regulator_enable() Maciej Purski
2018-06-04 13:59                 ` Maciej Purski
     [not found]             ` <CGME20180604135954eucas1p2bebd1c4970401bb957da228056f9a662@eucas1p2.samsung.com>
2018-06-04 13:59               ` [PATCH 7/7] regulator: core: Enable voltage balancing Maciej Purski
2018-06-04 13:59                 ` Maciej Purski
2018-06-04 23:13                 ` kbuild test robot
2018-06-04 23:13                   ` kbuild test robot
2018-06-04 23:13                   ` kbuild test robot
2018-06-04 23:54                 ` kbuild test robot
2018-06-04 23:54                   ` kbuild test robot
2018-06-04 23:54                   ` kbuild test robot
2018-06-05  4:45             ` Regression in Linux next again Tony Lindgren
2018-06-05  4:45               ` Tony Lindgren
     [not found]               ` <CGME20180613103622eucas1p1778ba2c2e5dd85ccb4c488bd0a38386d@eucas1p1.samsung.com>
2018-06-13 10:33                 ` [PATCH v2] regulator: core: Enable voltage balancing Maciej Purski
2018-06-13 10:33                   ` Maciej Purski
2018-06-15 11:29                   ` Tony Lindgren
2018-06-15 11:29                     ` Tony Lindgren
2018-06-18 13:17                     ` Maciej Purski
2018-06-18 13:17                       ` Maciej Purski
     [not found]                     ` <CGME20180618140856eucas1p281619f9bf003655a3c2eac356216ab25@eucas1p2.samsung.com>
2018-06-18 14:08                       ` Maciej Purski [this message]
2018-06-18 14:08                         ` [PATCH] regulator: core: Pass max_uV value to regulator_set_voltage_rdev Maciej Purski
2018-07-02  8:05                         ` Tony Lindgren
2018-07-02  8:05                           ` Tony Lindgren
2018-09-28 20:09                           ` Dmitry Osipenko
2018-09-28 20:09                             ` Dmitry Osipenko
2018-09-28 20:09                             ` Dmitry Osipenko
2018-09-28 20:09                             ` Dmitry Osipenko
2018-09-28 20:22                             ` Tony Lindgren
2018-09-28 20:22                               ` Tony Lindgren
2018-09-28 20:36                               ` Dmitry Osipenko
2018-09-28 20:36                                 ` Dmitry Osipenko
2018-09-28 22:26                               ` Dmitry Osipenko
2018-09-28 22:26                                 ` Dmitry Osipenko
2018-09-28 22:26                                 ` Dmitry Osipenko
2018-09-28 22:41                                 ` Tony Lindgren
2018-09-28 22:41                                   ` Tony Lindgren
2018-09-28 23:17                                   ` Dmitry Osipenko
2018-09-28 23:17                                     ` Dmitry Osipenko
2018-09-28 23:17                                     ` Dmitry Osipenko
2018-09-28 23:51                                     ` Dmitry Osipenko
2018-09-28 23:51                                       ` Dmitry Osipenko
2018-09-28 23:51                                       ` Dmitry Osipenko
2018-09-29  0:27                                       ` Tony Lindgren
2018-09-29  0:27                                         ` Tony Lindgren
2018-09-29  0:44                                         ` Dmitry Osipenko
2018-09-29  0:44                                           ` Dmitry Osipenko
2018-10-01  7:25                                           ` Maciej Purski
2018-10-01  7:25                                             ` Maciej Purski
2018-10-01 13:34                                             ` Dmitry Osipenko
2018-10-01 13:34                                               ` Dmitry Osipenko
2018-05-30 14:53       ` Regression in Linux next again Naresh Kamboju
2018-05-30 14:53         ` Naresh Kamboju
2018-05-31  5:44         ` Naresh Kamboju
2018-05-31  5:44           ` Naresh Kamboju

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=1529330913-11152-1-git-send-email-m.purski@samsung.com \
    --to=m.purski@samsung.com \
    --cc=broonie@kernel.org \
    --cc=ceh@ti.com \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-omap@vger.kernel.org \
    --cc=m.szyprowski@samsung.com \
    --cc=tony@atomide.com \
    /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.