From: Axel Lin <axel.lin@gmail.com>
Date: Thu, 7 Jun 2012 02:05:14 +0000 (+0800)
Subject: regulator: core: Handle fixed voltage in map_voltage_linear
X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=5a6881e8e134ea636bbc8423049e84638dbb7106;p=GitHub%2Fexynos8895%2Fandroid_kernel_samsung_universal8895.git

regulator: core: Handle fixed voltage in map_voltage_linear

Fixed voltage is a kind of linear mapping where n_voltages is 1.
This change allows [list|map]_voltage_linear to be used for fixed
voltage.

For fixed voltage, n_voltages is 1 and the only valid selector is 0.
Thus we actually don't care the uV_step setting.

Signed-off-by: Axel Lin <axel.lin@gmail.com>
Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
---

diff --git a/drivers/regulator/core.c b/drivers/regulator/core.c
index 8521e0d6b3bc..5c6aedaa934d 100644
--- a/drivers/regulator/core.c
+++ b/drivers/regulator/core.c
@@ -2070,6 +2070,14 @@ int regulator_map_voltage_linear(struct regulator_dev *rdev,
 {
 	int ret, voltage;
 
+	/* Allow uV_step to be 0 for fixed voltage */
+	if (rdev->desc->n_voltages == 1 && rdev->desc->uV_step == 0) {
+		if (min_uV <= rdev->desc->min_uV && rdev->desc->min_uV <= max_uV)
+			return 0;
+		else
+			return -EINVAL;
+	}
+
 	if (!rdev->desc->uV_step) {
 		BUG_ON(!rdev->desc->uV_step);
 		return -EINVAL;