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-next>] [day] [month] [year] [list]
Message-Id: <1341353014-13005-1-git-send-email-swarren@wwwdotorg.org>
Date:	Tue,  3 Jul 2012 16:03:34 -0600
From:	Stephen Warren <swarren@...dotorg.org>
To:	Mark Brown <broonie@...nsource.wolfsonmicro.com>
Cc:	linux-kernel@...r.kernel.org, Stephen Warren <swarren@...dia.com>
Subject: [PATCH] regulator: don't fail to apply_uV for fixed regulators without set_voltage

From: Stephen Warren <swarren@...dia.com>

When instantiating a regulator from device tree,
of_get_regulation_constraints() sets apply_uV=true when min_uV==max_uV.
If the regulator only supports that one voltage, it may not implement
set_voltage or set_voltage_sel. If so, the call from
machine_constraints_voltage() to _regulator_do_set_voltage() will fail,
since the latter requires one of those ops to be implemented. Avoid this
problem by avoiding the call to _regulator_do_set_voltage() if the
regulator is already set of the specified voltage.

Signed-off-by: Stephen Warren <swarren@...dia.com>
---
Are regulators required to implement get_voltage()? If not, this change
would cause a regression.

An alternative might be to just implement set_voltage*() in the relevant
regulator driver, although it seem like it'd intended to be optional.
Would that be preferable? The driver in question is for the MAX8907 which
isn't upstream yet, but I'll be sending patches for it as soon as I have
legal approval; the code is written and working.

 drivers/regulator/core.c |    3 ++-
 1 files changed, 2 insertions(+), 1 deletions(-)

diff --git a/drivers/regulator/core.c b/drivers/regulator/core.c
index ef07b62..8196764 100644
--- a/drivers/regulator/core.c
+++ b/drivers/regulator/core.c
@@ -790,7 +790,8 @@ static int machine_constraints_voltage(struct regulator_dev *rdev,
 
 	/* do we need to apply the constraint voltage */
 	if (rdev->constraints->apply_uV &&
-	    rdev->constraints->min_uV == rdev->constraints->max_uV) {
+	    rdev->constraints->min_uV == rdev->constraints->max_uV &&
+	    _regulator_get_voltage(rdev) != rdev->constraints->min_uV) {
 		ret = _regulator_do_set_voltage(rdev,
 						rdev->constraints->min_uV,
 						rdev->constraints->max_uV);
-- 
1.7.0.4

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ