diff mbox

[v2] regulator: treat regulators with constant volatage as fixed

Message ID 1352799334-13898-1-git-send-email-m.szyprowski@samsung.com (mailing list archive)
State New, archived
Headers show

Commit Message

Marek Szyprowski Nov. 13, 2012, 9:35 a.m. UTC
Some drivers has additional logic for fixed regulators. Let regulator core
to treat 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 |    6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

Comments

Mark Brown Nov. 13, 2012, 9:42 a.m. UTC | #1
On Tue, Nov 13, 2012 at 10:35:34AM +0100, Marek Szyprowski wrote:

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

The idea here was to avoid the ternery operator completely.
diff mbox

Patch

diff --git a/drivers/regulator/core.c b/drivers/regulator/core.c
index 042c1ff..78b34b7 100644
--- a/drivers/regulator/core.c
+++ b/drivers/regulator/core.c
@@ -1872,7 +1872,11 @@  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 ? rdev->desc->n_voltages :
+		       -EINVAL;
+	else
+		return 1;
 }
 EXPORT_SYMBOL_GPL(regulator_count_voltages);