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-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20210618141412.4014912-2-axel.lin@ingics.com>
Date:   Fri, 18 Jun 2021 22:14:12 +0800
From:   Axel Lin <axel.lin@...ics.com>
To:     Mark Brown <broonie@...nel.org>
Cc:     Philipp Zabel <p.zabel@...gutronix.de>,
        Steve Twiss <stwiss.opensource@...semi.com>,
        Support Opensource <support.opensource@...semi.com>,
        Liam Girdwood <lgirdwood@...il.com>,
        linux-kernel@...r.kernel.org, Axel Lin <axel.lin@...ics.com>
Subject: [PATCH 2/2] regulator: da9052: Simplify checking DVC controlled regulators

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@...ics.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

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ