diff mbox

[2/3] regulator: threat regulators with constant volatage as fixed

Message ID 1352796533-12350-3-git-send-email-m.szyprowski@samsung.com (mailing list archive)
State New, archived
Headers show

Commit Message

Marek Szyprowski Nov. 13, 2012, 8:48 a.m. UTC
Some drivers has additional logic for fixed regulators. Let regulator core
to threat regulators which cannot change their voltage due to applied
constraints as fixed.

Signed-off-by: Marek Szyprowski <m.szyprowski@samsung.com>
---
 drivers/regulator/core.c |    5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

Comments

Mark Brown Nov. 13, 2012, 9 a.m. UTC | #1
On Tue, Nov 13, 2012 at 09:48:52AM +0100, Marek Szyprowski wrote:

> Some drivers has additional logic for fixed regulators. Let regulator core
> to threat regulators which cannot change their voltage due to applied

YM "treat".

> +	if (rdev->constraints->valid_ops_mask & REGULATOR_CHANGE_VOLTAGE)
> +		return rdev->desc->n_voltages ? : -EINVAL;

Please don't perpetuate the use of ? : as it's not a triumph of
legibility (even worse than the regular ternery operator).  I realise
that the original code did this but there's no need to carry on doing
the same thing.
diff mbox

Patch

diff --git a/drivers/regulator/core.c b/drivers/regulator/core.c
index 042c1ff..271182e 100644
--- a/drivers/regulator/core.c
+++ b/drivers/regulator/core.c
@@ -1872,7 +1872,10 @@  int regulator_count_voltages(struct regulator *regulator)
 {
 	struct regulator_dev	*rdev = regulator->rdev;
 
-	return rdev->desc->n_voltages ? : -EINVAL;
+	if (rdev->constraints->valid_ops_mask & REGULATOR_CHANGE_VOLTAGE)
+		return rdev->desc->n_voltages ? : -EINVAL;
+	else
+		return 1;
 }
 EXPORT_SYMBOL_GPL(regulator_count_voltages);