linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Axel Lin <axel.lin@ingics.com>
To: Mark Brown <broonie@kernel.org>
Cc: Philipp Zabel <p.zabel@pengutronix.de>,
	Steve Twiss <stwiss.opensource@diasemi.com>,
	Support Opensource <support.opensource@diasemi.com>,
	Liam Girdwood <lgirdwood@gmail.com>,
	linux-kernel@vger.kernel.org, Axel Lin <axel.lin@ingics.com>
Subject: [PATCH 2/2] regulator: da9052: Simplify checking DVC controlled regulators
Date: Fri, 18 Jun 2021 22:14:12 +0800	[thread overview]
Message-ID: <20210618141412.4014912-2-axel.lin@ingics.com> (raw)
In-Reply-To: <20210618141412.4014912-1-axel.lin@ingics.com>

Only DVC controlled regulators have activate_bit set, so just check
activate_bit we can know if the regulator is DVC controlled.

Signed-off-by: Axel Lin <axel.lin@ingics.com>
---
 drivers/regulator/da9052-regulator.c | 20 ++------------------
 1 file changed, 2 insertions(+), 18 deletions(-)

diff --git a/drivers/regulator/da9052-regulator.c b/drivers/regulator/da9052-regulator.c
index 23fa429ebe76..74ab8d615d1f 100644
--- a/drivers/regulator/da9052-regulator.c
+++ b/drivers/regulator/da9052-regulator.c
@@ -207,7 +207,6 @@ static int da9052_regulator_set_voltage_sel(struct regulator_dev *rdev,
 {
 	struct da9052_regulator *regulator = rdev_get_drvdata(rdev);
 	struct da9052_regulator_info *info = regulator->info;
-	int id = rdev_get_id(rdev);
 	int ret;
 
 	ret = da9052_reg_update(regulator->da9052, rdev->desc->vsel_reg,
@@ -218,16 +217,9 @@ static int da9052_regulator_set_voltage_sel(struct regulator_dev *rdev,
 	/* Some LDOs and DCDCs are DVC controlled which requires enabling of
 	 * the activate bit to implment the changes on the output.
 	 */
-	switch (id) {
-	case DA9052_ID_BUCK1:
-	case DA9052_ID_BUCK2:
-	case DA9052_ID_BUCK3:
-	case DA9052_ID_LDO2:
-	case DA9052_ID_LDO3:
+	if (info->activate_bit)
 		ret = da9052_reg_update(regulator->da9052, DA9052_SUPPLY_REG,
 					info->activate_bit, info->activate_bit);
-		break;
-	}
 
 	return ret;
 }
@@ -238,22 +230,14 @@ static int da9052_regulator_set_voltage_time_sel(struct regulator_dev *rdev,
 {
 	struct da9052_regulator *regulator = rdev_get_drvdata(rdev);
 	struct da9052_regulator_info *info = regulator->info;
-	int id = rdev_get_id(rdev);
 	int ret = 0;
 
 	/* The DVC controlled LDOs and DCDCs ramp with 6.25mV/µs after enabling
 	 * the activate bit.
 	 */
-	switch (id) {
-	case DA9052_ID_BUCK1:
-	case DA9052_ID_BUCK2:
-	case DA9052_ID_BUCK3:
-	case DA9052_ID_LDO2:
-	case DA9052_ID_LDO3:
+	if (info->activate_bit)
 		ret = DIV_ROUND_UP(abs(new_sel - old_sel) * info->step_uV,
 				   6250);
-		break;
-	}
 
 	return ret;
 }
-- 
2.25.1


  reply	other threads:[~2021-06-18 14:14 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-06-18 14:14 [PATCH 1/2] regulator: da9052: Ensure enough delay time for .set_voltage_time_sel Axel Lin
2021-06-18 14:14 ` Axel Lin [this message]
2021-06-22 12:50   ` [PATCH 2/2] regulator: da9052: Simplify checking DVC controlled regulators Mark Brown
2021-06-23 16:08 ` (subset) [PATCH 1/2] regulator: da9052: Ensure enough delay time for .set_voltage_time_sel Mark Brown

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=20210618141412.4014912-2-axel.lin@ingics.com \
    --to=axel.lin@ingics.com \
    --cc=broonie@kernel.org \
    --cc=lgirdwood@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=p.zabel@pengutronix.de \
    --cc=stwiss.opensource@diasemi.com \
    --cc=support.opensource@diasemi.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).